ROS 2 — Robot / AGV Middleware
ROS 2 (Robot Operating System 2) is the standard middleware for mobile robots, AGVs, collaborative robots, and drones. It provides publish / subscribe / service / action semantics on top of DDS (Data Distribution Service, RTPS over UDP/TCP). Monitoring robot status by subscribing to topics (for example /odom, /imu, /battery_state) is the common approach.
The gateway's ROS2 driver is a fully implemented driver that connects to the JSON over WebSocket endpoint of rosbridge_suite (rosbridge_server), the standard ROS 2 bridge, and subscribes to topics. It does not attach to DDS directly, so all you need on the ROS 2 side is a running rosbridge_server. It is read-only.
Prerequisite — rosbridge_server
Install and run the standard rosbridge_suite package on the ROS 2 side (on the robot itself or on a PC on the same network).
# 예: ROS 2 Humble
sudo apt install ros-humble-rosbridge-suite
ros2 launch rosbridge_server rosbridge_websocket_launch.xml # 기본 ws 포트 9090
Registration form entries
| Field | What to enter | Example |
|---|---|---|
| IP address | rosbridge_server host | 192.168.0.30 |
| Port | rosbridge WebSocket port | 9090 (ws default) / 9443 (wss default) |
| Path (rosbridge) | WebSocket endpoint path — option path | / (default) |
| Use TLS | false = ws / true = wss — option tls | false (default) |
The ROS 2 driver is read-only. Publishing to topics (for example /cmd_vel motion commands) requires rosbridge advertise and is not supported. Use a separate path for sending robot commands.
PLC address notation for tags
The address format is <topic>:<field.dot.path> — the first : separates the topic from the field path (ROS topics contain / but no :).
| Notation | Meaning |
|---|---|
/temperature:data | The data field of std_msgs/Float64 |
/imu:orientation.z | A nested field of sensor_msgs/Imu (dot-path) |
/scan:ranges.0 | Array element — the numeric segment is the index |
/odom | Without :, the entire msg (JSON string) |
- Leaf fields are returned as text values; objects and arrays are returned as JSON strings.
- lazy subscribe — a topic is subscribed once on the first read, after which rosbridge pushes new samples. The first value therefore arrives from the next collection cycle onward.
Data format matching
| msg field | Data format |
|---|---|
float fields (data, orientation.z …) | Float / Double |
| int / enum fields | Integer |
| bool fields | Boolean |
| String / entire msg (JSON) | String |
Common topic mappings (reference)
| Address | Meaning | Recommended format |
|---|---|---|
/battery_state:percentage | Battery level (sensor_msgs/BatteryState) | Float |
/odom:pose.pose.position.x | Robot position x (nav_msgs/Odometry) | Float |
/odom:twist.twist.linear.x | Forward velocity (nav_msgs/Odometry) | Float |
/diagnostics | Entire diagnostics message | String (JSON) |
For large messages such as /scan (LiDAR raw), avoid collecting the entire msg and register only the elements you need (for example /scan:ranges.0).
Common problems
| Symptom | Possible cause | Resolution |
|---|---|---|
| Value is empty right after registration | lazy subscribe — the first read only performs the subscription | Wait until the next collection cycle (one timecycle) |
| Connection failure (connect failed) | rosbridge_server not running / port mismatch | Verify that rosbridge_server is running on the ROS 2 side and check the port (9090) |
wss connection failure | TLS settings / certificate | If tls=true, rosbridge must also run with TLS (wss default port 9443) |
| Values update, then stop | WebSocket dropped — the driver immediately switches to disconnected (it does not keep returning stale cached values) | Check the network / restart rosbridge |
| Topic name is correct but the value is empty | Typo in the field dot-path (path does not exist in the msg) | Check the msg structure with ros2 topic echo <topic> and correct the path |
Alternative integration paths (reference)
Where rosbridge cannot be used, the following paths are also possible.
| Situation | Alternative |
|---|---|
| Many robots plus cloud collection required | MQTT bridge → Sparkplug B / MQTT client |
| Industrial robot controllers (ABB / KUKA / UR) | OPC UA Robotics Companion → OPC-UA |