### Install Launch File Source: https://github.com/robotwebtools/rosbridge_suite/blob/ros2/rosbridge_server/CMakeLists.txt Installs a ROS launch file for rosbridge_server. This is used to start the server within a ROS environment. ```cmake install(FILES launch/rosbridge_websocket_launch.xml DESTINATION share/${PROJECT_NAME}/launch) ``` -------------------------------- ### Install Executable Scripts Source: https://github.com/robotwebtools/rosbridge_suite/blob/ros2/rosbridge_server/CMakeLists.txt Installs Python scripts as executables. These are typically the main entry points for the rosbridge server. ```cmake install(PROGRAMS scripts/rosbridge_websocket.py scripts/rosbridge_websocket DESTINATION lib/${PROJECT_NAME}) ``` -------------------------------- ### Install Python Package Source: https://github.com/robotwebtools/rosbridge_suite/blob/ros2/rosbridge_server/CMakeLists.txt Installs the Python package for rosbridge_server. Ensure ament_cmake_python is found. ```cmake find_package(ament_cmake_python REQUIRED) ament_python_install_package( ${PROJECT_NAME} PACKAGE_DIR "src/${PROJECT_NAME}") ``` -------------------------------- ### Example QoS Profile Object Source: https://github.com/robotwebtools/rosbridge_suite/blob/ros2/ROSBRIDGE_PROTOCOL.md Demonstrates a fully specified QoS profile for an advertise operation. Omitting the 'qos' field falls back to default settings. Individual fields within 'qos' can also be omitted to use system defaults. ```json { "op": "advertise", "topic": "/foo", "type": "std_msgs/msg/String", "qos": { "history": "keep_last", "depth": 10, "reliability": "reliable", "durability": "volatile", "deadline": "infinite", "lifespan": 1.5 } } ``` -------------------------------- ### Check Apt Tornado Version Source: https://github.com/robotwebtools/rosbridge_suite/blob/ros2/TROUBLESHOOTING.md Query the installed version of the python-tornado package via apt. This helps in comparing with the imported version. ```bash apt-cache show python-tornado | grep Version ``` -------------------------------- ### Find Local Tornado Installations Source: https://github.com/robotwebtools/rosbridge_suite/blob/ros2/TROUBLESHOOTING.md If the incorrect Tornado version persists after uninstallation, use this command to locate and manually remove any stray installations within Python's site-packages. ```bash find /usr/local/lib/python*/*-packages/ -type d | grep '/tornado/' ``` -------------------------------- ### Check Imported Tornado Version Source: https://github.com/robotwebtools/rosbridge_suite/blob/ros2/TROUBLESHOOTING.md Use this command to verify the Tornado version currently imported by Python. Ensure it matches the version installed by rosdep. ```python python -c 'import tornado; print tornado.version' ``` -------------------------------- ### Configure rosapi Node with All Resources Source: https://github.com/robotwebtools/rosbridge_suite/blob/ros2/rosapi/README.md Use this launch file configuration to enable all topics, services, and parameters to be returned by the rosapi node. ```xml ``` -------------------------------- ### Configure rosapi Node with Specific Topics Source: https://github.com/robotwebtools/rosbridge_suite/blob/ros2/rosapi/README.md This launch file configuration demonstrates how to enable only specific topics, such as \/rosout and camera-related topics, for the rosapi node. ```xml ``` -------------------------------- ### Configure Launch Tests Source: https://github.com/robotwebtools/rosbridge_suite/blob/ros2/rosbridge_server/CMakeLists.txt Sets up launch tests for various WebSocket scenarios. Each test is run with both SingleThreadedExecutor and EventsExecutor. ```cmake set(TEST_FILES test/websocket/advertise_action.test.py test/websocket/advertise_action_feedback.test.py test/websocket/advertise_publish.test.py test/websocket/advertise_service.test.py test/websocket/call_service.test.py test/websocket/send_action_goal.test.py test/websocket/smoke.test.py test/websocket/transient_local_publisher.test.py test/websocket/best_effort_publisher.test.py test/websocket/multiple_subscribers_raw.test.py ) foreach(TEST_FILE ${TEST_FILES}) # Extract base name for test naming get_filename_component(TEST_NAME ${TEST_FILE} NAME_WE) # Run with SingleThreadedExecutor (default) add_launch_test(${TEST_FILE} TARGET ${TEST_NAME}_singlethreaded ARGS "use_events_executor:=false" ) # Run with EventsExecutor add_launch_test(${TEST_FILE} TARGET ${TEST_NAME}_events ARGS "use_events_executor:=true" ) endforeach() ``` -------------------------------- ### Advertise Topic with QoS and Unadvertise Source: https://context7.com/robotwebtools/rosbridge_suite/llms.txt Register a ROS publisher on a topic using the 'advertise' operation. Optional 'qos' settings can override defaults. 'unadvertise' removes specific or all advertisements for a topic. ```json // Advertise with explicit QoS { "op": "advertise", "id": "adv-1", "topic": "/cmd_vel", "type": "geometry_msgs/msg/Twist", "qos": { "history": "keep_last", "depth": 10, "reliability": "reliable", "durability": "volatile" } } ``` ```json // Unadvertise (remove this specific advertisement only) { "op": "unadvertise", "id": "adv-1", "topic": "/cmd_vel" } ``` ```json // Unadvertise all advertisements for the topic by this client { "op": "unadvertise", "topic": "/cmd_vel" } ``` -------------------------------- ### Uninstall Pip Tornado Source: https://github.com/robotwebtools/rosbridge_suite/blob/ros2/TROUBLESHOOTING.md If a conflicting Tornado version was installed via pip, use this command to uninstall it. This is a common step when versions do not match. ```bash pip uninstall tornado ``` -------------------------------- ### rosapi Services: Get Parameter Source: https://context7.com/robotwebtools/rosbridge_suite/llms.txt Retrieve the value of a ROS parameter using '/rosapi/get_param'. Specify the 'name' of the parameter and an optional 'default' value. ```json // Get a ROS parameter value { "op": "call_service", "id": "q5", "service": "/rosapi/get_param", "args": { "name": "/my_robot_node.max_speed", "default": "1.0" } } // Response: { "value": "0.8" } ``` -------------------------------- ### Launch rosbridge WebSocket Server Source: https://context7.com/robotwebtools/rosbridge_suite/llms.txt Launches the rosbridge WebSocket server and the companion rosapi node. Configuration can be provided via arguments. ```APIDOC ## Launch rosbridge WebSocket Server Start the WebSocket server (default port 9090) and the companion rosapi node using the supplied launch file. The server and `rosapi` share the same glob-filter parameters so access control is configured in one place. ```xml ``` ```bash # From the command line ros2 launch rosbridge_server rosbridge_websocket_launch.xml port:=9090 ``` ``` -------------------------------- ### rosapi Services: List Nodes Source: https://context7.com/robotwebtools/rosbridge_suite/llms.txt Call '/rosapi/nodes' to get a list of all active nodes in the ROS graph. The response contains a 'nodes' array with node names. ```json // List all nodes { "op": "call_service", "id": "q3", "service": "/rosapi/nodes" } // Response: { "nodes": ["/my_robot_node", "/rosbridge_websocket", ...] } ``` -------------------------------- ### Minimal and Correlated rosbridge Messages Source: https://context7.com/robotwebtools/rosbridge_suite/llms.txt Examples of minimal and valid rosbridge messages. The 'id' field is used to correlate requests with their responses, spanning the lifetime of an interaction. ```json // Minimal valid rosbridge message { "op": "subscribe", "topic": "/chatter" } ``` ```json // With correlation ID { "op": "call_service", "id": "req-42", "service": "/rosapi/topics", "args": {} } ``` -------------------------------- ### Launch rosbridge WebSocket Server and rosapi Source: https://context7.com/robotwebtools/rosbridge_suite/llms.txt Launch the rosbridge WebSocket server and the companion rosapi node using a provided XML launch file. Configuration for port and glob filters is done via ROS 2 parameters. ```xml ``` ```bash # From the command line ros2 launch rosbridge_server rosbridge_websocket_launch.xml port:=9090 ``` -------------------------------- ### rosapi Services: Get Node Details Source: https://context7.com/robotwebtools/rosbridge_suite/llms.txt Obtain details about a specific node, including its publishers, subscribers, and services, by calling '/rosapi/node_details'. Provide the 'node' name in 'args'. ```json // Get details for a node (its publishers, subscribers, and services) { "op": "call_service", "id": "q4", "service": "/rosapi/node_details", "args": { "node": "/my_robot_node" } } // Response: { "subscribing": ["/scan"], "publishing": ["/cmd_vel"], "services": [] } ``` -------------------------------- ### Advertise Topic Source: https://github.com/robotwebtools/rosbridge_suite/blob/ros2/ROSBRIDGE_PROTOCOL.md Registers the client as a publisher on a specified topic. This operation allows the server to track publishers and establish the topic with the correct type if it doesn't exist. Deprecated fields `latch` and `queue_size` are superseded by the `qos` object. ```APIDOC ## POST /advertise ### Description Registers the client as a publisher on a topic. This allows the server to track which clients are publishing on which topics, and to establish the topic with the correct type if it does not already exist. ### Method POST ### Endpoint /advertise ### Parameters #### Request Body - **op** (string) - required - Must be "advertise" - **id** (string) - optional - An ID to associate with this advertisement. Useful when multiple components advertise the same topic so that each can be unadvertised independently. - **topic** (string) - required - The name of the topic to advertise. - **type** (string) - required - The type of the topic to advertise. - **qos** (object) - optional - QoS profile for the publisher. See section 4.2.1 for the object format and available fields. If omitted, the default rosbridge QoS is used (see section 4.2.2). If present, `latch` and `queue_size` are ignored. - **latch** (boolean) - optional - Deprecated. Use `qos.durability` instead. Whether to latch the last message published on this topic. - **queue_size** (integer) - optional - Deprecated. Use `qos.depth` instead. The QoS depth policy. ### Request Example ```json { "op": "advertise", "topic": "/foo", "type": "std_msgs/msg/String", "qos": { "history": "keep_last", "depth": 10, "reliability": "reliable", "durability": "volatile", "deadline": "infinite", "lifespan": 1.5 } } ``` ### Response #### Success Response (200) - **op** (string) - Confirmation of the operation, e.g., "advertised" - **id** (string) - The ID associated with the advertisement, if provided. #### Response Example ```json { "op": "advertised", "id": "my_advertisement_id" } ``` **Note:** The operation fails if the topic already exists with a different type or if the specified type cannot be resolved. Only the first advertisement determines the QoS settings for a topic. ``` -------------------------------- ### rosapi Services: Get Topic Type Source: https://context7.com/robotwebtools/rosbridge_suite/llms.txt Retrieve the message type of a specific topic by calling '/rosapi/topic_type' with the topic name. The 'args' field should contain the 'topic' key. ```json // Get type of a specific topic { "op": "call_service", "id": "q2", "service": "/rosapi/topic_type", "args": { "topic": "/scan" } } // Response: { "type": "sensor_msgs/msg/LaserScan" } ``` -------------------------------- ### Configure unregister_timeout in rosbridge_websocket Source: https://github.com/robotwebtools/rosbridge_suite/blob/ros2/rosbridge_server/CHANGELOG.rst Make the unregister_timeout configurable by passing an argument in a launch file. This allows adjustment of the delay for mitigating client unregistration issues. ```xml ``` -------------------------------- ### Base64 Encoding of Byte Arrays Source: https://github.com/robotwebtools/rosbridge_suite/blob/ros2/ROSBRIDGE_PROTOCOL.md Byte arrays (uint8[] or char[]) are base64 encoded when sent by the rosbridge server to reduce message size. This example shows how uint8 arrays are represented as base64 strings. ```json { "data1": "AAAAAA==", "data2": "/////w==" } ```