Skip to content

AuroAi/carla_apollo_bridge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Carla Apollo Bridge

This python package provides a bridge for communicating between Apollo's Python API and Carla. Besides the source code, a Dockerfile and scripts are provided for getting setup quickly and easily. This package was tested with Carla version 0.9.6, and Apollo v5.0.0.

Apollo runs on the Cyber RT framework. This is a cyber port of the work done here: https://github.com/carla-simulator/ros-bridge

Installation

Pre-requisites

For the simplest setup, we will run Carla in Docker. You can run Carla from source if you would like, but the setup is more involved: https://carla.readthedocs.io/en/latest/how_to_build_on_linux/

docker

https://docs.docker.com/install/linux/docker-ce/ubuntu/

nvidia-docker

https://github.com/nvidia/nvidia-docker

Setup / Getting Started

The following commands will be run with 3 containers:

  • carla-server: this container will run the Carla simulator
  • carla-apollo: bridge between apollo and carla-server containers, has cyber_py and carla python packages installed and unlike apollo container, can easily display gui applications on local machine
  • apollo_dev_user: runs the apollo stack

containers-diagram

Clone and build Apollo

Our fork of Apollo has a few changes that make it work with this Carla bridge. You can see those changes here: https://github.com/ApolloAuto/apollo/compare/v5.0.0...AuroAi:carla

# run on local machine:

git clone https://github.com/auroai/apollo --single-branch -b carla
cd apollo
./docker/scripts/dev_start.sh
./docker/scripts/dev_into.sh

Now in the apollo container, build apollo...

# run in apollo_dev_user container:

./apollo.sh build_gpu

Run Carla docker container

This container will run the carla simulator.

# run on local machine:

docker run --gpus=all --name=carla-server --net=host -d carlasim/carla:0.9.6

Build docker image / run container for Carla-Apollo bridge

This container will run the bridge and sim clients.

# run on local machine, starting from the root of this repo:

cd docker
./build_docker.sh
./run_docker.sh

Usage

Run Carla client and bridge

Enter carla-apollo docker container

# run on local machine:

docker exec -ti carla-apollo bash

Update /apollo/cyber/setup.bash

Change CYBER_IP in /apollo/cyber/setup.bash to the carla-apollo container IP address

To find out the ip address to use, run this command outside of the container:

# run on local machine:

docker inspect carla-apollo | grep IPAddress

Then update the file in your preferred editor

# run in carla-apollo container:

vim /apollo/cyber/setup.bash
# and so on to edit the text file

# then source your ~/.bashrc file to apply the changes:
source ~/.bashrc

Create an ego vehicle and client

Run these commands inside the carla-apollo container

# run in carla-apollo container:

cd ~/carla_apollo_bridge
python examples/run_bridge.py

In another terminal...

# run in carla-apollo container in another terminal:

cd ~/carla_apollo_bridge
python examples/manual_control.py

Interfacing with the simulation

For interfacing with the simulator, a copy of the Carla PythonAPI is included in the carla-apollo container. Some uses:

# run in another carla-apollo container terminal:
cd ~/carla_apollo_bridge/carla-python-0.9.6

# change the map
python util/config.py -m Town04 --host 172.17.0.1

# spawn traffic
python examples/spawn_npc.py -n 50 --host 172.17.0.1

Run Apollo Dreamview & modules

Now, in the apollo container, run dreamview:

# run in apollo_dev_user container:

. /apollo/scripts/dreamview.sh start_fe

Then, in a web browser, go to: localhost:8888

View camera feed

Click the 'Tasks' button on the sidebar to open the Tasks Toolbar. Click the 'Camera Sensor' switch. camera

View point cloud

Click the 'Layer Menu' button on the sidebar. Click the 'Point Cloud' switch under 'Perception'. pointcloud

Routing

Click the 'Module Controller' button on the sidebar. Click the 'Routing' switch to enable Routing. routing

Click the 'Route Editing' button on the sidebar. Click on the map to place points. Place one point to route from the vehicle's current location. Place two points to route from the first point to the second. Then, click 'Send Routing Request'. If routing is successful, a red line appears showing the planned route. route_editing

Perception

Ground truth obstacle sensor

The example scripts use a ground truth obstacle sensor instead of Apollo perception. This is enable by including object_sensor in config/settings.yaml. groundtruth

Apollo perception module

To use Apollo perception, remove obstacle_sensor from config/settings.yaml and enable the 'Transform' and 'Perception' modules. apollo_percpetion

Prediction

Once obstacles are being published, either from Apollo perception or the ground truth obstacle sensor, you can enable the 'Prediction' module. prediction

Planning

Once a route has been planned, and prediction output is received you can enable the 'Planning' module. The bridge will automatically move the vehicle along the planned path unless output from the 'Control' module is received. planning

Control

If the 'Control' module is enabled, the bridge will apply its output to the ego vehicle, but this feature has not been fully developed yet. So, the ego's movement may be erratic. The recommended way to use the bridge is to allow it to use the planner output for moving the vehicle.

Known Issues

  • Traffic lights, stop signs not in the HD Map. This is because they are not included in the Carla OpenDRIVE maps.
  • When closing the bridge sometimes objects aren't cleaned up properly and cyber will error due to duplicate nodes. The easiest solution is to reload the map in Carla:
root@7243ed7667bd:~/carla_apollo_bridge# python carla-python-0.9.6/util/config.py --host 172.17.0.1 -r
  • Running the Carla server and Apollo on the same machine requires a lot of resources, so performance may be choppy.
  • Ego vehicle movement sometimes gets jumpy when being moved along planned trajectory.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages