ROS 2 - Develop from an external device (Zenoh Bridge)

Info

This section only applies to Linux-based computers. If you are a Windows user we refer to the options available in Cerebra Studio to interact with the robot.

The ROS 2 network on the robot (or Origin) is separated from the ROS 2 network of external devices, such as a user’s laptop or another compute module, to ensure that any ROS 2 overhead on the user-side does not affect the QoS and performance of the robot’s ROS 2 network. To maintain this separation, the robot uses a Zenoh-Bridge, which funnels the robot’s ROS 2 network to that of the user. The standard ROS 2 middleware, which uses DDS, is known to encounter issues when communicating over wireless networks, which can affect devices outside the robot’s network. The Zenoh-Bridge helps improve communication over both wireless and wired networks, allowing external devices to connect to the ROS 2 network reliably.

As a user, to access the robot’s ROS 2 topics, services, and clients, you need to connect through this Zenoh-Bridge. This is done by running a Zenoh-client on your external device, which then connects to a Zenoh-server on the robot. Only through this connection can you access the ROS 2 network of the robot and, for example, run commands like ros2 topic list or use tools like rviz2. Since the robot’s internal ROS 2 network is configured to be unreachable externally, using the Zenoh-Bridge is the only way to connect from an external device.

The remainder of this section will explain how to install and set up the Zenoh-client, enabling you to interface with the ROS 2 network of the robot from your computer.

Ros2Connection

  1. Install CycloneDDS

    CycloneDDS is an alternative to the default ROS 2 implementation being FastDDS. CycloneDDS was found to be provide a much more stable communication when the number of nodes and messages increase. You may install the CycloneDDS middleware using the following command:

    sudo apt install ros-*distro*-rmw-cyclonedds-cpp
    
    The value *distro* needs to be replaced by the ROS 2 distro you're using. Avular supports using humble.

  2. Export CycloneDDS

    Exporting CycloneDDS to your bashrc script ensures that it is automatically being used when opening a new terminal on your (companion) PC. You may do so by running echo "export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp" >> ~/.bashrc. Alternatively, you may also run export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp in each terminal you open that is related to ROS 2. When using docker you may use the environmental variables option when starting the docker image.

  3. Install the Zenoh bridge

    To start a Zenoh-client you must first install a specific version of the zenoh-bridge-ros2dds. The client can run as a standalone binary or in a docker container. Here, we choose the standalone binary. The official documentation can be found on this website. Yet, in short, it implies running the following commands in a terminal on your (companion) PC.

    echo "deb [trusted=yes] https://download.eclipse.org/zenoh/debian-repo/ /" | sudo tee -a /etc/apt/sources.list > /dev/null
    sudo apt update
    sudo apt install zenoh-bridge-ros2dds=0.11.0
    

  4. Start the Zenoh client

    To start the Zenoh-Client, which will open the bridge with the Zenoh-server on the robot, you should run

    zenoh-bridge-ros2dds -m client -e tcp/<robot-ip>:7447
    
    in a terminal (please first run export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp in case it was not added to you bashrc script). The robot IP address depends on how you are connected to the robot. check section connection address for more information.

  5. Check the connection

    Open a new terminal and run ros2 topic list, for example, you should now see all nodes running on the Origin ROS network (please first run export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp in case it was not added to you bashrc script).

Once you have connected to the Zenoh bridge, all topics, services, and actions will be available in your ROS environments like they are on the robot itself. You can use the same commands as you would use on the robot to interact with the ROS 2 network from an external device. Applications like Rviz2 also work when connected to the Zenoh bridge. You may now also start Rviz by running rviz2 in the same terminal. Rviz will show all the ROS 2 topics that are available on the robot, after which you can start developing your own application.

One important thing to note is that the ROS_DOMAIN_ID in the ROS environment on the external device should be different from the ROS_DOMAIN_ID set on the robot. Else you will receive duplicate messages.

If you are running Docker containers on your Companion PC, you can also use a Zenoh container to automate the launching of the Zenoh bridge. When you proceed with this method, ensure to use the eclipse/zenoh-bridge-ros2dds:0.11.0 image with version 0.11.0 such that it is compatible with the Origin One. Please refer to the official Zenoh documentation for more information.

Info

Details on the interface definition of the Avular SDK are found here

Code

Some code examples to get you up to speed can be found on avular's github page.