Carla & Apollo Co-simulation
View Demo
·
Report Bug
·
Request Feature
This project aims to provide a data and control bridge for the communication between Carla and Apollo. It was tested with Carla 0.9.14 and the Apollo master branch (newer than v7.0.0)
We will run Carla and Apollo in docker. Furthermore, NVIDIA Container Toolkit is needed. You can refer to the following link to install NVIDIA Container Toolkit:
Alternatively, simply perform the following steps:
-
docker
sudo apt-get install docker.io
-
NVIDIA Container Toolkit
curl https://get.docker.com | sh \ && sudo systemctl --now enable docker
distribution=$(. /etc/os-release;echo $ID$VERSION_ID) \ && curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg \ && curl -s -L https://nvidia.github.io/libnvidia-container/$distribution/libnvidia-container.list | \ sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \ sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
sudo apt-get update
sudo apt-get install -y nvidia-docker2
sudo systemctl restart docker
- Refer to this link:
https://github.com/ApolloAuto/apollo/blob/master/docs/01_Installation%20Instructions/apollo_software_installation_guide.md
-
We patched Apollo in order to work with our bridge, for now please use the guardstrike/apollo_carla_bridge branch from our fork.
# Using SSH git clone --branch guardstrike/apollo_carla_bridge [email protected]:guardstrikelab/apollo.git #Using HTTPS git clone --branch guardstrike/apollo_carla_bridge https://github.com/guardstrikelab/apollo.git
We will be sending this patch upstream soon so that you can just clone the official Apollo next time.
-
Build Apollo
cd apollo echo "export APOLLO_ROOT_DIR=$(pwd)" >> ~/.bashrc && source ~/.bashrc
Then, run:
bash docker/scripts/dev_start.sh
to start Apollo development docker container.
If you encounter any error, trysudo rm -rf /apollo/.cache bash docker/scripts/dev_start.sh
Upon successful execution, you will see the following message
[ OK ] Congratulations! You have successfully finished setting up Apollo Dev Environment. [ OK ] To login into the newly created apollo_dev_lei container, please run the following command: [ OK ] bash docker/scripts/dev_into.sh [ OK ] Enjoy!
Above If you occured error as "ERROR: Config value 'cuda' is not defined in any .rc file",you can try
./apollo.sh config -n
Run this command to enter the container
bash docker/scripts/dev_into.sh
Make the GPU version:
./apollo.sh build_gpu
After successful compilation, the following will be printed:
============================================== [ OK ] Done building apollo. Enjoy! ==============================================
Run this command in the container to start Dreamview
./scripts/bootstrap.sh
Finally, open the link in your browser
http://localhost:8888/
-
Clone the carla_apollo_bridge project
# Using SSH git clone [email protected]:guardstrikelab/carla_apollo_bridge.git #Using HTTPS git clone https://github.com/guardstrikelab/carla_apollo_bridge.git
-
To download and install Compose standalone, run:
sudo curl -L "https://github.com/docker/compose/releases/download/v2.0.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
-
Change File Permission:
sudo chmod +x /usr/local/bin/docker-compose
Apply executable permissions to the standalone binary in the target path for the installation. Test and execute compose commands using docker-compose. Note: If the command docker-compose fails after installation, check your path. You can also create a symbolic link to /usr/bin or any other directory in your path. For example:
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
-
Pull carla image and run
cd carla_apollo_bridge/scripts ./docker_run_carla.sh
-
Run the following to enter the container. Note that
carla_apollo_bridge/src
is mapped to/apollo/cyber/carla_bridge
within the container, this allows you to test any change you make to the bridge.cd carla_apollo_bridge/docker ./build_docker.sh ./run_docker.sh docker exec -ti carla_cyber_0.9.14 bash
-
Compile
Run the following command in the container
./apollo.sh build_cyber opt
The following information is displayed after the compilation is successful:
[INFO] Skipping revision recording ============================ [ OK ] Build passed! [INFO] Took 61 seconds
-
Start the bridge and spawn the ego vehicle
Run the following command in the container.
cd /apollo/cyber/carla_bridge python carla_cyber_bridge/bridge.py
Start a new terminal and run:
docker exec -ti carla_cyber_0.9.14 bash cd /apollo/cyber/carla_bridge python carla_spawn_objects/carla_spawn_objects.py
If everything above goes well, you should see this in Apollo client:
and this in Carla:
- Open apollo client: http://localhost:8888
- (Optional) Select "Task" in the sidebar and turn on "Camera Sensor" in "Others".
- (Optional) Select "Layer Menu" in the sidebar and turn on "Point Cloud" in "Perception".
- Select "Module Controller" in the sidebar and turn on "Routing" module.
- Select "Route Editing" in the sidebar.
- Click "Add Point of Interest" and left click at any point on the road to set the destination.
- Click "Send Routing Request".
- Select "Tasks" and click "Setup" to start co-simulation.
Deployment Network Introduction
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contribution you make is greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the Apache-2.0 License. See LICENSE
for more information.
This work is based on the following open-source projects,