ROS bridge installation
The ROS bridge enables two-way communication between ROS and CARLA. The information from the CARLA server is translated to ROS topics. In the same way, the messages sent between nodes in ROS get translated to commands to be applied in CARLA.
- Bridge installation
- Run the ROS bridge
- Setting CARLA
ROS is still experimental for Windows, so the ROS bridge has only been tested for Linux systems.
Make sure that both requirements work properly before continuing with the installation.
- ROS Kinetic/Melodic — Install the ROS version corresponding to your system. Additional ROS packages may be required, depending on the user needs. rviz is highly recommended to visualize ROS data.
- CARLA 0.9.7 or later — Previous versions are not compatible with the ROS bridge. Follow the quick start installation or make the build for Linux.
The Python version needed to run the ROS bridge depends on the ROS version being used.
- ROS Kinetic and ROS Melodic — Python2.
- ROS Noetic — Python3.
CARLA provides different Python support depending on the installation method. Here is a summary.
- CARLA release packages — Provide support for Python2 and Python3, so these can be used with any ROS version.
- Windows build — Provides Support for the default Python installation in the system, so the ROS installation should match this.
- Linux build — Provides support for Python3 by default (ROS Noetic). If Python2 is needed, the PythonAPI can be built for Python2 running the following command in the CARLA root directory.
make PythonAPI ARGS="--python-version=2" # The numeric argument can be changed to build for any specific Python version
To install ROS bridge versions prior to 0.9.10, change to a previous version of the documentation using the pannel in the bottom right corner of the window, and follow the old instructions.
A. Using Debian repository
Set up the Debian repository in the system.
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 1AF1527DE64CB8D9 sudo add-apt-repository "deb [arch=amd64] http://dist.carla.org/carla $(lsb_release -sc) main"
Install the ROS bridge, and check for the installation in the
sudo apt-get update # Update the Debian package index sudo apt-get install carla-ros-bridge # Install the latest ROS bridge version, or update the current installation
This repository contains features from CARLA 0.9.10 and later versions. To install a specific version add the version tag to the installation command.
sudo apt-get install carla-ros-bridge=0.9.10-1 # In this case, "0.9.10" refers to the ROS bridge version, and "1" to the Debian revision
B. Using source repository
A catkin workspace is needed to use the ROS bridge. It should be cloned and built in there. The following code creates a new workspace, and clones the repository in there.
# Setup folder structure mkdir -p ~/carla-ros-bridge/catkin_ws/src cd ~/carla-ros-bridge git clone https://github.com/carla-simulator/ros-bridge.git cd ros-bridge git submodule update --init cd ../catkin_ws/src ln -s ../../ros-bridge source /opt/ros/kinetic/setup.bash # Watch out, this sets ROS Kinetic cd .. # Install required ros-dependencies rosdep update rosdep install --from-paths src --ignore-src -r # Build catkin_make
Run the ROS bridge
1) Run CARLA. The way to do so depends on the CARLA installation.
- Quick start/release package.
- Debian installation.
- Build installation.
2) Add the source path. The source path for the workspace has to be added, so that the ROS bridge can be used from a terminal.
- Source for apt ROS bridge.
source /opt/carla-ros-bridge/<kinetic or melodic>/setup.bash
- Source for ROS bridge repository download.
The source path can be set permanently, but it will cause conflict when working with another workspace.
3) Start the ROS bridge. Use any of the different launch files available to check the installation. Here are some suggestions.
# Option 1: start the ros bridge roslaunch carla_ros_bridge carla_ros_bridge.launch # Option 2: start the ros bridge together with RVIZ roslaunch carla_ros_bridge carla_ros_bridge_with_rviz.launch # Option 3: start the ros bridge together with an example ego vehicle roslaunch carla_ros_bridge carla_ros_bridge_with_example_ego_vehicle.launch
The path to CARLA Python is missing. The apt installation does this automatically, but it may be missing for other installations. Execute the following command with the complete path to the .egg file (included). Use the one supported by the Python version installed.
ImportError: no module named CARLA
Note: .egg files may be either in `/PythonAPI/` or `/PythonAPI/dist/` depending on the CARLA installation.
Import CARLA from Python and wait for a sucess message to check the installation.
python3 -c 'import carla;print("Success")'
To modify the way CARLA works along with the ROS bridge, edit
- Host/port. Network settings to connect to CARLA using a Python client.
- Synchronous mode.
- If false (default). Data is published on every
- If true The bridge waits for all the sensor messages expected before the next tick. This might slow down the overall simulation but ensures reproducible results.
- If false (default). Data is published on every
- Wait for vehicle command. In synchronous mode, pauses the tick until a vehicle control is completed.
- Simulation time-step. Simulation time (delta seconds) between simulation steps. It must be lower than 0.1. Take a look at the documentation to learn more about this.
- Role names for the Ego vehicles. Role names to identify ego vehicles. These will be controllable from ROS and thus, relevant topics will be created.
In synchronous mode only the ros-bridge is allowed to tick. Other clients must passively wait.
To control the step update when in synchronous mode, use the following topic. The message contains a constant named
command that allows to Pause/Play the simulation, and execute a single step.
The Control rqt plugin launches a new window with a simple interface. It is used to manage the steps and publish in the corresponding topic. Simply run the following when CARLA in synchronous mode.
rqt --standalone rqt_carla_control