How to Integrate a ROS2 Robot with the ASI Biont AI Agent: Remote Control, Sensor Monitoring, and Autonomous Task Execution Without Coding

Introduction

Robotic systems built on ROS (Robot Operating System) and its modern successor ROS2 have become the backbone of research labs, industrial automation, and even home-built hobby projects. ROS2 provides a powerful middleware for distributed robotics — nodes publish topics, subscribe to messages, and coordinate complex behaviors. However, controlling a ROS2 robot from the cloud, combining its sensor data with an AI reasoning engine, and giving it high-level commands through a natural language interface has traditionally required significant custom development: writing a bridge server, handling authentication, and coding decision logic.

ASI Biont changes this. The platform acts as an AI agent that connects to virtually any device — including ROS2 robots — through a simple chat conversation. Instead of building dashboards or writing glue code, you describe your robot and its connection parameters in the chat, and the AI writes the integration script for you. This article walks through a concrete scenario: connecting a ROS2 robot (simulated or physical) to ASI Biont via WebSocket, sending movement commands, receiving LiDAR data, and enabling the AI to autonomously navigate the robot — all without manually writing a single line of bridge code.

Why Connect a ROS2 Robot to an AI Agent?

A standalone ROS2 robot can already execute pre-programmed behaviors, but adding an AI agent unlocks:
- Natural language control: "Move the robot to the kitchen and check the temperature on the table."
- Context-aware decision making: The AI can combine LiDAR scans with a camera feed (via a separate MQTT camera node) to decide if a path is clear.
- Remote monitoring: The robot’s sensor data (battery, odometry, point cloud) is available in the chat, stored, and analyzed over time.
- No-code automation: You can set up triggers like "If the LiDAR detects an obstacle closer than 0.5m, stop and notify me." All logic is written by the AI on the fly.

Connection Method: WebSocket via execute_python

ASI Biont does not have a native ROS2 plugin. Instead, it uses its universal execute_python mechanism — the AI writes a Python script that runs in a sandboxed environment on the ASI Biont cloud server. The script can use any of the supported libraries (see documentation). For ROS2, the most practical approach is connecting via WebSocket to the ROS2 robot’s rosbridge_server package.

rosbridge_server is an official ROS2 package that exposes ROS topics and services over WebSocket. It is widely used for web-based robot control. The robot runs ros2 launch rosbridge_server rosbridge_websocket_launch.xml on its onboard computer (e.g., Raspberry Pi, Jetson). Once the WebSocket server is up (default port 9090), any client — including ASI Biont’s execute_python sandbox — can connect, subscribe to topics, and publish messages.

Concrete Use Case: WebSocket-Based Robot Control

Scenario: You have a ROS2 robot with a differential drive base (publishing /cmd_vel for velocity commands) and a LiDAR that publishes /scan messages. You want the AI agent to:
1. Receive the LiDAR data every 5 seconds.
2. Check if any obstacle is within 0.5 meters.
3. If no obstacle, publish a forward velocity command.
4. If obstacle detected, stop and ask you for instructions.

Step 1: User Describes the Robot in Chat

You start a chat with the ASI Biont AI agent and say:

"Connect to my ROS2 robot. The rosbridge WebSocket server is at ws://192.168.1.100:9090. Subscribe to the /scan topic (type: sensor_msgs/LaserScan). Every 10 seconds, check if any range value is below 0.5 meters. If clear, publish a Twist message to /cmd_vel with linear.x=0.2. If obstacle, publish zero velocity and send me a Telegram alert. Use the aiohttp library to connect to the WebSocket."

Step 2: AI Writes the execute_python Script

ASI Biont generates a Python script that runs in the cloud sandbox. Here is a simplified version of what the AI produces:

import asyncio
import json
import aiohttp
from aiohttp import ClientWebSocketResponse

# Configuration provided by user in chat
WS_URL = "ws://192.168.1.100:9090"

def create_twist(linear_x, angular_z=0.0):
    return {
        "op": "publish",
        "topic": "/cmd_vel",
        "msg": {
            "linear": {"x": linear_x, "y": 0.0, "z": 0.0},
            "angular": {"x": 0.0, "y": 0.0, "z": angular_z}
        }
    }

def create_subscribe():
    return {
        "op": "subscribe",
        "topic": "/scan",
        "type": "sensor_msgs/LaserScan"
    }

async def main():
    async with aiohttp.ClientSession() as session:
        async with session.ws_connect(WS_URL) as ws:
            # Subscribe to /scan
            await ws.send_json(create_subscribe())
            print("Subscribed to /scan")

            while True:
                msg = await ws.receive()
                if msg.type == aiohttp.WSMsgType.TEXT:
                    data = json.loads(msg.data)
                    if "msg" in data and "ranges" in data["msg"]:
                        ranges = data["msg"]["ranges"]
                        min_range = min(ranges)
                        print(f"Min range: {min_range:.2f} m")

                        if min_range > 0.5:
                            # Publish forward command
                            await ws.send_json(create_twist(0.2))
                            print("Path clear. Moving forward.")
                        else:
                            # Stop
                            await ws.send_json(create_twist(0.0))
                            print("Obstacle detected! Stopped.")
                            # In real scenario, AI would also send a Telegram message via a separate script
                elif msg.type == aiohttp.WSMsgType.CLOSED:
                    break
                elif msg.type == aiohttp.WSMsgType.ERROR:
                    break

asyncio.run(main())

Important notes:
- The script runs in a sandbox with a 30-second timeout. For continuous control, the AI would set up an external cron-style trigger (e.g., via the industrial_command tool every 30 seconds) or use the Hardware Bridge with a local agent.
- In practice, the AI would wrap the control loop inside a single execute_python call that returns after a few iterations, and the user would schedule repeated executions via the chat ("Run this every 30 seconds").

Step 3: AI Executes and Tests

After writing the script, the AI runs it in the sandbox. If the robot is reachable (IP correct, rosbridge running), the script connects, subscribes, and starts reacting. The AI reports back to the chat:

"Connected to ROS2 robot at 192.168.1.100:9090. Subscribed to /scan. Current min range is 1.2m — path clear, publishing forward velocity. I will continue checking every 10 seconds."

Step 4: User Combines with Other Devices

Because ASI Biont can connect to multiple devices in the same chat, you can add a temperature sensor (ESP32 via MQTT) and a camera (Raspberry Pi via SSH). The AI can then orchestrate all of them:
- "When the LiDAR sees a person, take a photo with the camera and send it to me."
- "If the temperature in the room exceeds 30°C, move the robot there and report the exact value."

Comparing Connection Methods for ROS2

Method Pros Cons Best for
WebSocket (execute_python) Simple, no extra bridge software; works with rosbridge_server Requires rosbridge running on robot; sandbox timeout limits long loops Quick prototyping, periodic checks, command publishing
SSH (execute_python) Direct shell access; can launch/stop ROS nodes Requires SSH credentials; no direct topic subscription Running scripts on the robot, editing launch files, fetching logs
MQTT (execute_python) Lightweight, pub/sub pattern; can bridge ROS topics Need a ROS-to-MQTT bridge node (e.g., mqtt_bridge) Integrating with other MQTT devices (sensors, actuators)
Hardware Bridge (COM port) Real-time local control Only if robot is connected via serial (e.g., Arduino base) Low-level motor control via serial protocol

For most ROS2 scenarios, WebSocket via execute_python is the recommended starting point because it requires no additional software on the robot beyond the widely used rosbridge_server.

How to Get Started

  1. Run rosbridge on your robot: On the ROS2 computer, run ros2 launch rosbridge_server rosbridge_websocket_launch.xml. Ensure port 9090 is accessible from the internet (use a VPN or port forwarding for remote access).
  2. Open chat on asibiont.com: Start a new conversation with the AI agent.
  3. Describe your robot: Provide the WebSocket URL, the topics you want to monitor, and what actions you want the AI to take. For example: "Connect to ws://:9090, subscribe to /odom and /scan, and every 30 seconds tell me the robot's position and whether the path is clear."
  4. Let the AI do the rest: The AI writes the execute_python script, runs it, and starts interacting with your robot. You can refine the behavior with follow-up messages.

Benefits of This Approach

  • Zero manual coding: You don't need to write a WebSocket client, parse JSON, or handle reconnections. The AI does it all.
  • Instant deployment: No need to install libraries on your local machine — everything runs in the cloud sandbox.
  • Flexible integration: Change the topics, thresholds, or actions by simply typing a new instruction.
  • Combined device control: Mix your ROS2 robot with MQTT sensors, SSH cameras, or Modbus PLCs in one conversation.

Conclusion

Integrating a ROS2 robot with an AI agent no longer requires a dedicated bridge server or weeks of development. Using ASI Biont’s execute_python mechanism and the robot’s rosbridge_server, you can establish a WebSocket connection, subscribe to sensor data, and publish movement commands — all through a chat conversation. The AI writes the code, handles errors, and adapts to your requests.

Whether you are a robotics researcher automating lab experiments, a hobbyist building a home robot, or an engineer deploying autonomous guided vehicles in a warehouse, ASI Biont turns your ROS2 robot into a remotely controllable, AI-powered system with minimal effort.

Try it now: Go to asibiont.com, start a chat, and tell the AI: "Connect to my ROS2 robot via WebSocket at ws://192.168.1.100:9090 and monitor the LiDAR for obstacles." Experience the future of robot control today.

← All posts

Comments