Latest News / October ‘24 / Join our panel discussion at the UXL Foundation's oneAPI DevSummit 2024 this week!

Running Multiple Autoware-Powered Vehicles in Carla using Zenoh

Author: ADMIN
Running Multiple Autoware-Powered Vehicles in Carla using Zenoh

Written by ChenYing Kuo* and William Liang**

* ADLINK Technology (and Autoware contributors)

Before running Autoware on an actual vehicle, testing our code in the simulation world is expected. There are several simulators we can use, e.g. AWSIM, Carla. However, most of them only support running a single Autoware on it. Sometimes, we want to experiment with multiple vehicles, especially fleet management systems (FMS) and vehicle interaction (V2X). So, it’s important to run several vehicles in the same simulator. Zenoh can help in this scenario. Therefore, we created autoware_carla_launch, a project to run multiple Autoware with the Carla simulator with the help of Zenoh.

While speaking to multiple Autoware instances, one of the most common issues is that ROS 2 topics from different vehicles will conflict. Traditionally, we might need to rename the topic name or add the namespace, which is tedious sometimes. In our solution, we developed a zenoh_carla_bridge to solve the issues. The bridge will use Carla API to get/set some information and then connect to the Zenoh network. On the other side, zenoh-bridge-dds receives the Zenoh data (which conveys the information from Carla) and transforms it into the Autoware ROS 2 messages for the corresponding topics directly. Similarly, zenoh-bridge-dds can get vehicle control commands and data from Autoware and send them to the Carla simulator through zenoh_carla_bridge. The key point is that we can use one of Zenoh’s feature “scope” to separate identical ROS topics in Autoware. That’s why we need Zenoh here.

Tutorial

In the following tutorial, we’ll guide you to set up the environment and then run the multiple vehicles demo scenario.

Environment Setup

We use the docker container for the bridge and Autoware to make the environment consistent. We need to install the docker and rocker first.

$ sudo apt install docker.io python3-rocker

Then we also need to download Carla. Note that the version used here is 0.9.13. You can follow the tutorial in Carla’s official document.

Now, we can get the code from GitHub.

$ git clone https://github.com/evshary/autoware_carla_launch.git -b humble
$ cd autoware_carla_launch

For the build process, there are two parts. One is our bridge, and the other is Autoware packages. You can run them on different machines.

Let’s build the bridge first. You’ll be in the container after running `run-bridge-docker.sh`. It might take some time to download the docker image for the first time.

$ ./container/run-bridge-docker.sh
# Inside the container
$ cd autoware_carla_launch
$ source env.sh
$ make prepare_bridge
$ make build_bridge

In another machine, let’s build the Autoware packages. You’ll be in the container after running `run-autoware-docker.sh`. It might take some time to download the docker image for the first time.

$ ./container/run-autoware-docker.sh
# Inside the container
$ cd autoware_carla_launch
$ source env.sh
$ make prepare_autoware
$ make build_autoware

Demo Scenario

In the following demo, we run Carla + zenoh_carla_bridge in one host and two Autoware + zenoh-bridge-dds in another host. To emulate two independent Autoware vehicles running on the same host machine, the ROS traffic packets from each Autoware should be constrained in its container and not exposed to each other. We use ROS_LOCALHOST_ONLY to constrain the DDS traffic inside the container. In the bottom half of the following figure, you can see that two hosts are connected with Zenoh.

Let’s run the demo now. First of all, we run the Carla in host1.

$ ./CarlaUE4.sh -quality-level=Epic -world-port=2000 -RenderOffScreen

Then, we run the bridge on host 1. Note that you’ll be in the container after running `run-bridge-docker.sh`.

$ ./run-bridge-docker.sh
# Inside the container
$ cd autoware_carla_launch
$ source env.sh
$ ./script/run-bridge-two-vehicles.sh

In host 2, we’ll run two Autoware. We’ve already set the environmental variables ROS_LOCALHOST_ONLY so they will not conflict with each other. Note that you’ll be in the container after running `run-autoware-docker.sh`. While running `./script/run-autoware.sh`, you need to add the vehicle name (“v1” in this case) and the IP address of host 1 for Zenoh to connect.

# First vehicle v1
$ ./run-autoware-docker.sh
# Inside the container
$ cd autoware_carla_launch
$ source env.sh
$ ./script/run-autoware.sh v1 <host1_IP>

Run another Autoware.

# First vehicle v2
$ ./run-autoware-docker.sh
# Inside the container
$ cd autoware_carla_launch
$ source env.sh
$ ./script/run-autoware.sh v2 <host1_IP>

You can see two RViz popped up, and you can set a goal for each vehicle. The video below shows the result. You can see two vehicles detecting each other at 3’10”.

Conclusion

In this blog, we connect multiple vehicles in Carla to Autoware with the help of Zenoh. In the future, we can test multiple-vehicle communication based on this work. As mentioned in the blog “Driving Autoware with Zenoh”, Zenoh can be used on external communication, such as FMS or V2X. These subjects are exciting and important in autonomous driving, and Zenoh can play an important role!

Special Thanks

Thanks to some community efforts:
* hatem-darweesh: Excellent works on CARLA Simulator + Autoware Universe Tutorials. I used the map he generated and referred to some of his vehicle parameters.
* jerry73204: The zenoh_carla_bridge here is based on the Carla Rust API he provided. He also made some contributions to the zenoh_carla_bridge.