Latest News / April ‘23 / Indy Autonomous Challenge (IAC) joined the Autoware Foundation!

Driving Autoware with Zenoh

Author: ADMIN
Driving Autoware with Zenoh

written by,

ChenYing Kuo* and William Liang**

* ADLINK and Autoware Foundation

** ADLINK and ZettaScale

Communication is a crucial topic in robotics and automotive domains. ROS is one of the famous frameworks for these domains, and ROS 2 relies on DDS as its communication layer. ROS 2 / DDS usually works well, but sometimes it faces some limitations. While Autoware is based on ROS 2 / DDS, these limitations might be problems for Autoware.

We’ll list some limitations here. First, ROS 2 / DDS only works inside a local network (LAN) and cannot cross the Internet without dedicated support from each DDS vendor. Secondly, ROS 2 / DDS needs multicast capability, so it can’t work well in some network environments, such as 4G / 5G. Finally, DDS multicast packets might also become a problem in WiFi since it generates too many discovery packets. Those are the reasons why Zenoh can help.

Zenoh is an open-source data-centric protocol based on pub/sub/query operations. While using Zenoh, users can focus more on the data and not worry about how communication works. The significant difference between Zenoh and other protocols is that Zenoh has higher performance and scalability and supports complete decentralization. These features make Zenoh suitable for IIoT, robotics, and automotive.

To help Autoware / ROS 2 / DDS get rid of the limitations mentioned above, zenoh-bridge-dds was created to seamlessly convert the underlying DDS packets into the Zenoh protocol to extend the connection to the Internet scale, to support the data links without multicast capability, to reduce the traffic to a minimum, and to double the throughput.

The following figure shows how zenoh-bridge-dds works with ROS 2 / DDS. We still run ROS 2 / DDS inside the host, but we’ll use Zenoh to communicate between hosts. To convert ROS 2 / DDS and Zenoh messages, zenoh-bridge-dds should be installed and run on each host. zenoh-bridge-dds in every host will connect to each together based on the Zenoh protocol. Now that the two machines can communicate with ROS, no matter where they are, whether multicast capability exists or a wireless environment is used.

 

How to run on my host

 

Scenario

Now let’s control the vehicles remotely with the help of zenoh-bridge-dds. Our scenario is shown in the following figure: Run Autoware in Host 1 and then control it from Host 2 with a remote keyboard controller. A router is set up between the hosts to emulate the environment crossing the networks or the Internet. Since DDS cannot get across routers without vendor-dependent settings, we’ll use zenoh-bridge-dds to connect hosts separated by the router.

 

Prerequisite

First, you need to install zenoh-bridge-dds and rocker for Host1 and Host2. rocker is a tool to run docker containers with more accessible options.

Download the necessary packages.

$ sudo apt install llvm-dev libclang-dev cmake
$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

Then, reopen the terminal to make the Rust environment effective.

Build zenoh-bridge-dds

$ cd ~
$ git clone https://github.com/eclipse-zenoh/zenoh-plugin-dds.git
$ cd zenoh-plugin-dds
$ cargo build --release -p zenoh-bridge-dds

Note: zenoh-bridge-dds is also available as a Debian package. If you use any Debian-based Linux distribution, you can install the executable program by `apt` following the instructions.

Create zenoh-bridge-dds config

$ vim ~/zenoh-plugin-dds/myconfig.json

{

 plugins: {
  dds: { 
   allow: "/external/selected/control_cmd|/external/selected/gear_cmd|/control/gate_mode_cmd|/api/autoware/set/engage|/control/current_gate_mode|/api/autoware/get/engage|/vehicle/status/velocity_status|/vehicle/status/gear_status"      
  }  
 } 
}                                                                               

Install rocker

$ sudo apt install docker.io python3-rocker
$ sudo groupadd docker
$ sudo gpasswd -a $USER docker

and reboot your system.

Run Autoware and RViz in Host 1

Download the Autoware map.

$ gdown -O ~/autoware_map/
'https://docs.google.com/uc?export=download&id=1499_nsbUbIeturZaDj7jhUownh5fvXHd'
$ unzip -d ~/autoware_map ~/autoware_map/sample-map-planning.zip

Run Planning Simulation in Host 1.

$ rocker --network host --privileged --x11 --user --volume $HOME/autoware_map -- ghcr.io/autowarefoundation/autoware-universe:latest-prebuilt bash
$ ros2 launch autoware_launch planning_simulator.launch.xml map_path:=$HOME/autoware_map/sample-map-planning vehicle_model:=sample_vehicle sensor_model:=sample_sensor_kit

After the Rviz appears, follow the instruction to give the initial pose on RViz.

 

Run the remote keyboard controller in Host 2

We’ve written a remote keyboard controller using ROS 2 to control the vehicle in RViz.

Compile and run the keyboard controller in Host 2.

$ mkdir -p $HOME/autoware_manual_control_ws/src
$cd $HOME/autoware_manual_control_ws/src
$ git clone https://github.com/evshary/autoware_manual_control.git

Build the keyboard controller.

$ rocker --network host --privileged --x11 --user --volume $HOME/autoware_manual_control_ws -- ghcr.io/autowarefoundation/autoware-universe:latest-prebuilt bash
$ cd $HOME/autoware_manual_control_ws
$ colcon build

Run the keyboard controller.

$ source install/local_setup.bash
$ ros2 run autoware_manual_control keyboard_control

Run zenoh-bridge-dds to bridge the two hosts.

Now, we still can not control the vehicle. So, we need to use zenoh-bridge-dds to bridge the DDS network.

In Host 1, we run zenoh-bridge-dds and make it listen to TCP port 7447.

$ ~/zenoh-plugin-dds/target/release/zenoh-bridge-dds -l tcp/0.0.0.0:7447 -c ~/zenoh-plugin-dds/myconfig.json5

In Host 2, we run zenoh-bridge-dds and make it connect to Host 1 with port 7447.

$ ~/zenoh-plugin-dds/target/release/zenoh-bridge-dds -e tcp/<Host 1 IP>:7447 -c 
~/zenoh-plugin-dds/myconfig.json5

Enjoy driving.

After giving the 2D Pose Estimate on RViz, you can toggle to External mode and change to Drive type. Then, control the speed and steering angle. Now you can use the remote keyboard controller to control the vehicle in RViz!

The following video illustrates how it works on two machines in different networks.

https://www.youtube.com/watch?v=S7TdJAO3-Og

At the beginning of the video, we connected to a remote server and ran the keyboard controller to control Autoware running on the local system. Since they were on different networks, they could not reach each other. After running zenoh-bridge-dds on each machine, the vehicle in RViz could be controlled by the remote keyboard controller.

Conclusion

This blog shows the power of Zenoh and demonstrates an example of how to run Autoware with Zenoh. We believe that Zenoh can help Autoware with external communication, such as FLM, HMI, V2X, etc. This way, external applications can also be developed using ROS 2 and access the same topics and data types. In the future, we’ll demo more use cases to show how to integrate Zenoh into Autoware.