Robot Web Tools

  • Robot Web Tools- libraries for developing web-based interfaces for controlling robots, visualizing data, and interacting with robot systems directly from a web browser
    • rosbridge: A middleware that translates ROS messages into JSON and exposes a WebSocket interface.
    • Robot Web Tools: A JavaScript library that allows communication with ROS from a web browser via WebSockets.
      • It handles publishing and subscribing to ROS topics, calling services, and interacting with action servers.
      • This allows non-ROS platforms, like web browsers, to communicate with ROS nodes.
    • 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

Setup rosbridge_suite for ROS2

https://medium.com/@rafaazahra_93357/how-setup-rosbridge-suite-for-ros2-roslib-js-library-74b918db1a64

  • 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
  • To customize the WebSocket port, add a port argument
ros2 launch rosbridge_server rosbridge_websocket_launch.xml port:=8080
  • 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);
};

https://wiki.ros.org/roslibjs