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 / 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

FieldWhat to enterExample
IP addressrosbridge_server host192.168.0.30
Portrosbridge WebSocket port9090 (ws default) / 9443 (wss default)
Path (rosbridge)WebSocket endpoint path — option path/ (default)
Use TLSfalse = ws / true = wss — option tlsfalse (default)
Write not supported

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

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

Common 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
/diagnosticsEntire diagnostics messageString (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

SymptomPossible causeResolution
Value is empty right after registrationlazy subscribe — the first read only performs the subscriptionWait until the next collection cycle (one timecycle)
Connection failure (connect failed)rosbridge_server not running / port mismatchVerify that rosbridge_server is running on the ROS 2 side and check the port (9090)
wss connection failureTLS settings / certificateIf tls=true, rosbridge must also run with TLS (wss default port 9443)
Values update, then stopWebSocket 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 emptyTypo 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.

SituationAlternative
Many robots plus cloud collection requiredMQTT bridge → Sparkplug B / MQTT client
Industrial robot controllers (ABB / KUKA / UR)OPC UA Robotics Companion → OPC-UA