This ROS package aims at providing a custom ROS bridge for the CARLA simulator used during the spring 2020 Intro to Self-Driving Cars course at Western Michigan University.
Important Note: This documentation is for CARLA version 0.9.8
#Setup directory
mkdir ~/CARLA_0.9.8
#Download CARLA_0.9.8.tar.gz from https://github.com/carla-simulator/carla/releases
# and place in ~/CARLA_0.9.8
cd ~/CARLA_0.9.8
tar xvf CARLA_0.9.8.tar.gz
#OPTIONAL STEP: Download additional maps (AdditionalMaps_0.9.8.tar.gz)
# from https://github.com/carla-simulator/carla/releases
# Place AdditionalMaps_0.9.8.tar.gz in ~/CARLA_0.9.8/Import
tar xvf AdditionalMaps_0.9.8.tar.gz
cd ..
./ImportAssets.sh
#setup folder structure
mkdir -p ~/CARLA_0.9.8/ros-bridge/src
cd ~/CARLA_0.9.8/ros-bridge/
git clone https://github.com/nickgoberville/carla-ros-bridge.git
cd src
ln -s ../carla-ros-bridge
cd carla-ros-bridge
cat PATH >> ~/.bashrc
source ~/.bashrc
#install required ros-dependencies
cd ~/CARLA_0.9.8/ros-bridge
rosdep update
rosdep install --from-paths src --ignore-src -r
#build
catkin_make
For more information about configuring a ROS environment see http://wiki.ros.org/ROS/Tutorials/InstallingandConfiguringROSEnvironment
First run the simulator (choose one option):
# Option 1: Run carla like normal
cd ~/CARLA_0.9.8
./CarlaUE4.sh
# Option 2: Run carla in background
cd ~/CARLA_0.9.8
export SDL_VIDEODRIVER=offscreen
./CarlaUE4.sh -opengl
Wait a few seconds, then make custom map/weather/etc changes using config.py:
# Recommended: Change map to Town04 with Clear and Sunny weather
#(may need to change spawn_point arg in me5950/carla_ego_vehicle/launch/carla_example_ego_vehicle if NOT using Town04)
**New terminal**
cd ~/CARLA_0.9.8/PythonAPI/util
./config.py -m Town04 --weather ClearNoon
start the ros-bridge and ego vehicle:
# Option 1: Start ros-bridge node WITHOUT rviz
source ~/CARLA_0.9.8/ros-bridge/devel/setup.bash
roslaunch carla_ros_bridge carla_ros_bridge.launch
# Option 2: Start the ros-bridge node WITH rviz
source ~/CARLA_0.9.8/ros-bridge/devel/setup.bash
roslaunch carla_ros_bridge carla_ros_bridge_with_rviz.launch
# Start ego_vehicle node
**New termianl**
source ~/CARLA_0.9.8/ros-bridge/devel/setup.bash
roslaunch carla_ego_vehicle carla_example_ego_vehicle.launch
You can setup the ros bridge configuration carla_ros_bridge/config/settings.yaml.
If the rolename is within the list specified by ROS parameter /carla/ego_vehicle/rolename
, the client is interpreted as an controllable ego vehicle and all relevant ROS topics are created.
In default mode (synchronous_mode: false
) data is published:
- on every
world.on_tick()
callback - on every
sensor.listen()
callback
CAUTION: In synchronous mode, only the ros-bridge is allowed to tick. Other CARLA clients must passively wait.
In synchronous mode (synchronous_mode: true
), the bridge waits for all sensor data that is expected within the current frame. This might slow down the overall simulation but ensures reproducible results.
Additionally you might set synchronous_mode_wait_for_vehicle_control_command
to true
to wait for a vehicle control command before executing the next tick.
It is possible to control the simulation execution:
- Pause/Play
- Execute single step
The following topic allows to control the stepping.
Topic | Type |
---|---|
/carla/control |
carla_msgs.CarlaControl |
A CARLA Control rqt plugin is available to publish to the topic.
The ego vehicle sensors are provided via topics with prefix /carla/ego_vehicle/<sensor_topic>
Currently the following sensors are supported:
Topic | Type |
---|---|
/carla/<ROLE NAME>/camera/rgb/<SENSOR ROLE NAME>/image_color |
sensor_msgs.Image |
/carla/<ROLE NAME>/camera/rgb/<SENSOR ROLE NAME>/camera_info |
sensor_msgs.CameraInfo |
Topic | Type |
---|---|
/carla/<ROLE NAME>/lidar/<SENSOR ROLE NAME>/point_cloud |
sensor_msgs.PointCloud2 |
Topic | Type |
---|---|
/carla/<ROLE NAME>/radar/<SENSOR ROLE NAME>/radar |
ainstein_radar_msgs.RadarTargetArray |
Radar data can be visualized on rviz using ainstein_radar_rviz_plugins.
Topic | Type |
---|---|
/carla/<ROLE NAME>/imu |
sensor_msgs.Imu |
Topic | Type | Description |
---|---|---|
/carla/<ROLE NAME>/gnss/<SENSOR ROLE NAME>/fix |
sensor_msgs.NavSatFix | publish gnss location |
Topic | Type | Description |
---|---|---|
/carla/<ROLE NAME>/collision |
carla_msgs.CarlaCollisionEvent | publish collision events |
Topic | Type | Description |
---|---|---|
/carla/<ROLE NAME>/lane_invasion |
carla_msgs.CarlaLaneInvasionEvent | publish events on lane-invasion |
Topic | Type | Description |
---|---|---|
/carla/<ROLE NAME>/objects |
derived_object_msgs.ObjectArray | all vehicles and walkers, except the ego vehicle |
Topic | Type |
---|---|
/carla/<ROLE NAME>/vehicle_control_cmd (subscriber) |
carla_msgs.CarlaEgoVehicleControl |
/carla/<ROLE NAME>/vehicle_control_cmd_manual (subscriber) |
carla_msgs.CarlaEgoVehicleControl |
/carla/<ROLE NAME>/vehicle_control_manual_override (subscriber) |
std_msgs.Bool |
/carla/<ROLE NAME>/vehicle_status |
carla_msgs.CarlaEgoVehicleStatus |
/carla/<ROLE NAME>/vehicle_info |
carla_msgs.CarlaEgoVehicleInfo |
There are two modes to control the vehicle.
- Normal Mode (reading commands from
/carla/<ROLE NAME>/vehicle_control_cmd
) - Manual Mode (reading commands from
/carla/<ROLE NAME>/vehicle_control_cmd_manual
)
This allows to manually override a Vehicle Control Commands published by a software stack. You can toggle between the two modes by publishing to /carla/<ROLE NAME>/vehicle_control_manual_override
.
carla_manual_control makes use of this feature.
For testing purposes, you can stear the ego vehicle from the commandline by publishing to the topic /carla/<ROLE NAME>/vehicle_control_cmd
.
Examples for a ego vehicle with role_name 'ego_vehicle':
Max forward throttle:
rostopic pub /carla/ego_vehicle/vehicle_control_cmd carla_msgs/CarlaEgoVehicleControl "{throttle: 1.0, steer: 0.0}" -r 10
Max forward throttle with max steering to the right:
rostopic pub /carla/ego_vehicle/vehicle_control_cmd carla_msgs/CarlaEgoVehicleControl "{throttle: 1.0, steer: 1.0}" -r 10
The current status of the vehicle can be received via topic /carla/<ROLE NAME>/vehicle_status
.
Static information about the vehicle can be received via /carla/<ROLE NAME>/vehicle_info
Topic | Type |
---|---|
/carla/<ROLE NAME>/twist_cmd (subscriber) |
geometry_msgs.Twist |
CAUTION: This control method does not respect the vehicle constraints. It allows movements impossible in the real world, like flying or rotating.
You can also control the vehicle via publishing linear and angular velocity within a Twist datatype.
Currently this method applies the complete linear vector, but only the yaw from angular vector.
In certain cases, the Carla Control Command is not ideal to connect to an AD stack.
Therefore a ROS-based node carla_ackermann_control
is provided which reads AckermannDrive messages.
You can find further documentation here.
Topic | Type | Description |
---|---|---|
/carla/objects |
derived_object_msgs.ObjectArray | all vehicles and walkers |
/carla/marker |
visualization_msgs.Marker | visualization of vehicles and walkers |
/carla/actor_list |
carla_msgs.CarlaActorList | list of all carla actors |
/carla/traffic_lights |
carla_msgs.CarlaTrafficLightStatusList | list of all traffic lights with their status |
Topic | Type | Description |
---|---|---|
/carla/status |
carla_msgs.CarlaStatus | |
/carla/world_info |
carla_msgs.CarlaWorldInfo | Info about the CARLA world/level (e.g. OPEN Drive map) |
Topic | Type | Description |
---|---|---|
/carla/walker/<ID>/walker_control_cmd (subscriber) |
carla_msgs.CarlaWalkerControl | Control a walker |
/carla/walker/<ID>/odometry |
nav_msgs.Odometry | odometry of walker |
Topic | Type | Description |
---|---|---|
/carla/vehicle/<ID>/odometry |
nav_msgs.Odometry | odometry of vehicle |
It is possible to draw markers in CARLA.
Caution: Markers might affect the data published by sensors.
The following markers are supported in 'map'-frame:
- Arrow (specified by two points)
- Points
- Cube
- Line Strip
Topic | Type | Description |
---|---|---|
/carla/debug_marker (subscriber) |
visualization_msgs.MarkerArray | draw markers in CARLA world |
Name | Description |
---|---|
Carla Ego Vehicle | Provides a generic way to spawn an ego vehicle and attach sensors to it. |
Carla Infrastructure | Provides a generic way to spawn a set of infrastructure sensors defined in a config file. |
Carla Waypoint Publisher | Provide routes and access to the Carla waypoint API |
Carla ROS Scenario Runner | ROS node that wraps the functionality of the CARLA scenario runner to execute scenarios. |
Carla AD Agent | A basic AD agent, that can follow a route and avoid collisions with other vehicles and stop on red traffic lights. |
Carla AD Demo | A meta package that provides everything to launch a CARLA ROS environment with an AD vehicle. |
RVIZ Carla Plugin | A RVIZ plugin to visualize/control CARLA. |
RQT Carla Plugin | A RQT plugin to control CARLA. |
You're missing Carla Python. Please execute:
export PYTHONPATH=$PYTHONPATH:<path/to/carla/>/PythonAPI/carla/dist/<your_egg_file>
Please note that you have to put in the complete path to the egg-file including the egg-file itself. Please use the one, that is supported by your Python version. Depending on the type of CARLA (pre-build, or build from source), the egg files are typically located either directly in the PythonAPI folder or in PythonAPI/dist.
Check the installation is successfull by trying to import carla from python:
python -c 'import carla;print("Success")'
You should see the Success message without any errors.