Skip to main content

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 FieldWhat to EnterExample
IP Addressrosbridge_server host192.168.0.30
Portrosbridge WebSocket port9090 (ws default) / 9443 (wss default)
Path (rosbridge)WebSocket endpoint path — optional path/ (default)
TLSfalse = ws / true = wss — optional tlsfalse (default)
Write Not Supported

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 :).

NotationMeaning
/temperature:dataThe data field of std_msgs/Float64
/imu:orientation.zNested field of sensor_msgs/Imu (dot-path)
/scan:ranges.0Array element — numeric segment is the index
/odomEntire 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 fieldData Type
float fields (data, orientation.z …)Float / Double
int / enum fieldsInteger
bool fieldsBoolean
string / entire msg (JSON)String

Frequently Used Topic Mappings (Reference)​

AddressMeaningRecommended Format
/battery_state:percentageBattery level (sensor_msgs/BatteryState)Float
/odom:pose.pose.position.xRobot position x (nav_msgs/Odometry)Float
/odom:twist.twist.linear.xForward velocity (nav_msgs/Odometry)Float
/diagnosticsFull diagnostic messageString (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​

SymptomPossible CauseSolution
Empty value right after registrationLazy subscribe — the first read only performs the subscriptionWait until the next collection cycle (one timecycle)
Connection failed (connect failed)rosbridge_server not running / port mismatchRun rosbridge_server on the ROS 2 side and verify the port (9090)
wss connection failureTLS settings / certificatesIf tls=true, rosbridge must also run with TLS (wss default port 9443)
Value updates then stopsWebSocket disconnection — the driver switches to disconnected immediately (does not keep returning stale cached values)Check network / restart rosbridge
Topic name is correct but empty valueField 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.

SituationAlternative
Multiple robots + cloud collection neededMQTT bridge → Sparkplug B / MQTT Client
Industrial robot controllers (ABB / KUKA / UR)OPC UA Robotics Companion → OPC-UA