Develop from an external device (ROS2 and 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 ROS2 network on the robot (or Origin) is separated from the ROS2 network of external devices, such as a user’s laptop or another compute module, to ensure that any ROS2 overhead on the user-side does not affect the QoS and performance of the robot’s ROS2 network. To maintain this separation, the robot uses a Zenoh-Bridge, which funnels the robot’s ROS2 network to that of the user. The standard ROS2 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 ROS2 network reliably.

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

Warning

The Zenoh-server on the robot is cannot cope with AND a Zenoh-client running on a user or companion PC AND Cerebra Studio sending jobs to and requesting information from the robot. Therefore, NEVER have both a Zenoh-client and Cerebra Studio connected to the robot simultaneously. It shall crash the Zenoh-server resulting in a loss of the ROS2 network between robot and user/companion PC. In case you notice that no ROS2 topics are received on the user/companion PC, then it is best to restart the Zenoh-server on the robot. To do so, ssh into the robot and run the following commands:

docker stop zenoh
docker start zenoh

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

Ros2Connection

  1. Install CycloneDDS

    CycloneDDS is an alternative to the default ROS2 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 on your devices (and companion PC if applicable) using the following command:

    sudo apt install ros-*distro*-rmw-cyclonedds-cpp
    
    The value *distro* needs to be replaced by the ROS2 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 own device (or companion PC mounted on the robot). 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 for using ROS2.

    From now on your ROS2 system will exploit CycloneDDS instead of FastDDS as its underlying communication protocol. You may then still use ROS2 as you were used to. Next step is to connect the ROS2 network of your device to that of the robot by completing the client part of the Zenoh bridge on your device.

  3. Install the Zenoh bridge

    To start a Zenoh-client you must first install 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=1.4.0
    
    The version of zenoh-bridge-ros2dds in the example above is equal to the version that the robot uses. If you have another version installed, then please check online sources on the backwards compatibility of zenoh-bridge-ros2dds.

  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 the following command in terminal on your device (or companion PC).

    export ROS_DISTRO=humble
    zenoh-bridge-ros2dds -m client -e tcp/<robot-ip>:7447
    
    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 of the robot will be available in your ROS environments. You can use the same commands as you would use on the robot to interact with the ROS2 network from an external device. Applications like Rviz2 also work when connected to the Zenoh bridge (try it by by running rviz2 in the a (new) terminal). Rviz will show all the ROS2 topics that are available on the robot.

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 device, or companion PC, you can also use a Zenoh container to automate the launching of the Zenoh bridge. In that case, make ensure to use the eclipse/zenoh-bridge-ros2dds:1.4.0 image with version 1.4.0 such that it is compatible with the Origin One. Please refer to the official Zenoh documentation for more information.

Continue to development ROS2 API definition