Libraries for developing web-based interfaces for controlling robots, visualizing data, and interacting with robot systems directly from a web browser
- rosbridge: A middleware/JSON API that allows non-ROS clients to communicate with ROS through Websockets
- roslibjs: A JavaScript API client library that allows web applications to interact with ROS via the rosbridge WebSocket connection.
- It handles publishing and subscribing to ROS topics, calling services, and interacting with action servers.
- web_video_server: A tool that streams video from ROS to a web browser.
- robot_pose_publisher: A tool that publishes the robot’s position and orientation in a format accessible via the web.
Rosbridge
- See ROS Web Tutorial for a more complete guide
rosbridge_suite for ROS2- Quick Setup
- Install
rosbridge_suite
for ROS2 humble
sudo apt update
sudo apt install ros-humble-rosbridge-suite
- Launch
rosbridge_websocket
server (Note: humble uses Python v10)
ros2 launch rosbridge_server rosbridge_websocket_launch.xml
# [rosbridge_websocket-1] [INFO] [1726600761.629841995] [rosbridge_websocket]: Rosbridge WebSocket server started on port 9090
By default, this will expose a WebSocket on port 9090 (reserved for ROS communication)
To customize the WebSocket port, add a port argument
ros2 launch rosbridge_server rosbridge_websocket_launch.xml port:=8080
[5050] - Web GUI - [9090] <-----> [9090] - rosbridge
- Verify that the server is listening on the specified port
netstat -an | grep 9090
tcp 0 0 0.0.0.0:9090 0.0.0.0:* LISTEN
tcp6 0 0 :::9090 :::* LISTEN
- Test the WebSocket connection in the console
- This script will try to open a WebSocket connection to ws://localhost:9090 and log the status in the console.
var ws = new WebSocket('ws://localhost:9090');
ws.onopen = function() {
console.log('WebSocket connection opened.');
};
ws.onerror = function(error) {
console.error('WebSocket error: ', error);
};
ws.onmessage = function(event) {
console.log('WebSocket message: ', event.data);
};