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, and action communication over DDS (Data Distribution Service, RTPS over UDP/TCP). The typical approach is to subscribe to topics (e.g., /odom, /imu, /battery_state) to monitor robot status.
The gateway's ROS2 driver is a real implementation driver that connects to the JSON over WebSocket endpoint of the standard ROS 2 bridge rosbridge_suite (rosbridge_server) to subscribe to topics. As it does not connect directly to DDS, you only need to run rosbridge_server on the ROS 2 side. It is read-only.
Prerequisites — rosbridge_server
Install and run the standard package rosbridge_suite on the ROS 2 side (on the robot itself or 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 Input Values
| Input 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 — optional path | / (default) |
| TLS | false = ws / true = wss — optional tls | false (default) |
The ROS 2 driver is read-only. Topic publishing (e.g., /cmd_vel motion commands) is not supported because it requires rosbridge advertise. Use a separate route for sending robot commands.
PLC Address Notation for Tags
The address uses <topic>:<field.dot.path> — the first : separates the topic from the field path (ROS topics include / but have no :).
| Notation | Meaning |
|---|---|
/temperature:data | The data field of std_msgs/Float64 |
/imu:orientation.z | Nested field of sensor_msgs/Imu (dot-path) |
/scan:ranges.0 | Array element — numeric segment is the index |
/odom | Entire msg if : is omitted (JSON string) |
- Leaf fields are returned as text values; objects/arrays are returned as JSON strings.
- Lazy subscribe — the topic is subscribed once on the first read, and rosbridge then pushes new samples. Therefore the first value arrives from the next collection cycle.
Data Type Matching
| msg field | Data Type |
|---|---|
float fields (data, orientation.z …) | Float / Double |
| int / enum fields | Integer |
| bool fields | Boolean |
| string / entire msg (JSON) | String |
Frequently Used 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 | Full diagnostic message | String (JSON) |
For large messages like /scan (raw LiDAR), avoid collecting the entire msg and register only the necessary elements (e.g., /scan:ranges.0).
Common Issues
| Symptom | Possible Cause | Solution |
|---|---|---|
| Empty value right after registration | Lazy subscribe — the first read only performs the subscription | Wait until the next collection cycle (one timecycle) |
| Connection failed (connect failed) | rosbridge_server not running / port mismatch | Run rosbridge_server on the ROS 2 side and verify the port (9090) |
wss connection failure | TLS settings / certificates | If tls=true, rosbridge must also run with TLS (wss default port 9443) |
| Value updates then stops | WebSocket disconnection — the driver switches to disconnected immediately (does not keep returning stale cached values) | Check network / restart rosbridge |
| Topic name is correct but empty value | Field dot-path typo (path not present in msg) | Check the msg structure with ros2 topic echo <topic> and fix the path |
Other Integration Routes (Reference)
If rosbridge cannot be used, the following routes are also available.
| Situation | Alternative |
|---|---|
| Multiple robots + cloud collection needed | MQTT bridge → Sparkplug B / MQTT Client |
| Industrial robot controllers (ABB / KUKA / UR) | OPC UA Robotics Companion → OPC-UA |