This ROS package aims at providing a simple ROS/ROS2 bridge for CARLA simulator.
This version requires CARLA 0.9.11
- Provide Sensor Data (Lidar, Semantic lidar, Cameras (depth, segmentation, rgb, dvs), GNSS, Radar, IMU)
- Provide Object Data (Transforms (via tf), Traffic light status, Visualization markers, Collision, Lane invasion)
- Control AD Agents (Steer/Throttle/Brake)
- Control CARLA (Play/pause simulation, Set simulation parameters)
Beside the bridging functionality, there are many more features provided in separate packages.
Name | Description |
---|---|
Carla Spawn Actors | Provides a generic way to spawn actors |
Carla Manual Control | A ROS-based visualization and control tool for an ego vehicle (similar to carla_manual_control.py provided by CARLA) |
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 Ackermann Control | A controller to convert ackermann commands to steer/throttle/brake |
Carla AD Agent | A basic AD agent, that follows a route, avoids collisions with other vehicles and stops on red traffic lights. |
Carla Walker Agent | A basic walker agent, that follows a route. |
RVIZ Carla Plugin | A RVIZ plugin to visualize/control CARLA. |
RQT Carla Plugin | A RQT plugin to control CARLA. |
For a quick overview, after following the Setup section, please run the CARLA AD Demo. It provides a ready-to-use demonstrator of many of the features.
ROS and ROS2 are supported by using separate implementations with a common interface.
Please follow the instructions:
Certain parameters can be set within the launch file carla_ros_bridge.launch.
If the rolename is within the list specified by argument ego_vehicle_role_name
, it is interpreted as an controllable ego vehicle and all relevant ROS topics are created.
The bridge is able to load a CARLA map by setting the launch-file parameter town
. Either specify an available CARLA Town (e.g. 'Town01') or a OpenDRIVE file (with ending '.xodr').
The bridge operates by default in CARLA synchronous mode, waiting for all sensor data that is expected within the current frame to ensure reproducible results. The bridge should only be used in this mode.
CAUTION: In synchronous mode, only one CARLA client is allowed to tick. The ROS bridge will by default be the only client allowed to tick the CARLA server unless passive mode is enabled. Enabling passive mode will make the ROS bridge step back and allow another client to tick the CARLA server.
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.
The usage of the asynchronous mode is discouraged. Users may enable this mode running the bridge in the following way:
# ROS1
roslaunch carla_ros_bridge carla_ros_bridge.launch synchronous_mode:=False
# ROS2
ros2 launch carla_ros_bridge carla_ros_bridge.launch.py synchronous_mode:=False
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.
Sensor data is provided via topic with prefix /carla/[<PARENTS ROLE NAME>]/<SENSOR ROLE NAME>/[<TOPIC NAME>]
The following sensors are available:
Topic | Type |
---|---|
/carla/[<PARENT ROLE NAME>]/<SENSOR ROLE NAME>/image |
sensor_msgs.Image |
/carla/[<PARENT ROLE NAME>]/<SENSOR ROLE NAME>/camera_info |
sensor_msgs.CameraInfo |
Topic | Type |
---|---|
/carla/[<PARENT ROLE NAME>]/<SENSOR ROLE NAME>/image |
sensor_msgs.Image |
/carla/[<PARENT ROLE NAME>]/<SENSOR ROLE NAME>/camera_info |
sensor_msgs.CameraInfo |
Topic | Type |
---|---|
/carla/[<PARENT ROLE NAME>]/<SENSOR ROLE NAME>/image |
sensor_msgs.Image |
/carla/[<PARENT ROLE NAME>]/<SENSOR ROLE NAME>/camera_info |
sensor_msgs.CameraInfo |
Topic | Type |
---|---|
/carla/[<PARENT ROLE NAME>]/<SENSOR ROLE NAME>/events |
sensor_msgs.PointCloud2 |
/carla/[<PARENT ROLE NAME>]/<SENSOR ROLE NAME>/image |
sensor_msgs.Image |
/carla/[<PARENT ROLE NAME>]/<SENSOR ROLE NAME>/camera_info |
sensor_msgs.CameraInfo |
Topic | Type |
---|---|
/carla/[<PARENT ROLE NAME>]/<SENSOR ROLE NAME> |
sensor_msgs.PointCloud2 |
Topic | Type |
---|---|
/carla/[<PARENT ROLE NAME>]/<SENSOR ROLE NAME> |
sensor_msgs.PointCloud2 |
Topic | Type |
---|---|
/carla/[<PARENT ROLE NAME>]/<SENSOR ROLE NAME> |
sensor_msgs.PointCloud2 |
Topic | Type |
---|---|
/carla/[<PARENT ROLE NAME>]/<SENSOR ROLE NAME> |
sensor_msgs.Imu |
Topic | Type | Description |
---|---|---|
/carla/[<PARENT ROLE NAME>]/<SENSOR ROLE NAME> |
sensor_msgs.NavSatFix | publish gnss location |
Topic | Type | Description |
---|---|---|
/carla/[<PARENT ROLE NAME>]/<SENSOR ROLE NAME> |
carla_msgs.CarlaCollisionEvent | publish collision events |
Topic | Type | Description |
---|---|---|
/carla/[<PARENT ROLE NAME>]/<SENSOR ROLE NAME> |
carla_msgs.CarlaLaneInvasionEvent | publish events on lane-invasion |
The tf data for the ego vehicle is published when this pseudo sensor is spawned.
Note: Sensors publish the tf data when the measurement is done. The child_frame_id
corresponds with the prefix of the sensor topics.
Topic | Type | Description |
---|---|---|
/carla/<PARENT ROLE NAME>/<SENSOR ROLE NAME> |
nav_msgs.Odometry | odometry of the parent actor |
Topic | Type | Description |
---|---|---|
/carla/<PARENT ROLE NAME>/<SENSOR ROLE NAME> |
std_msgs.Float32 | speed of the parent actor. Units: m/s |
Topic | Type | Description |
---|---|---|
/carla/[<PARENT ROLE NAME>]/<SENSOR ROLE NAME> |
std_msgs.String | provides the OpenDRIVE map as a string on a latched topic. |
Topic | Type | Description |
---|---|---|
/carla/[<PARENT ROLE NAME>]/<SENSOR ROLE NAME> |
derived_object_msgs.ObjectArray | publishes all vehicles and walker. If attached to a parent, the parent is not contained. |
Topic | Type | Description |
---|---|---|
/carla/[<PARENT ROLE NAME>]/<SENSOR ROLE NAME> |
visualization_msgs.Marker | visualization of vehicles and walkers |
Topic | Type | Description |
---|---|---|
/carla/[<PARENT ROLE NAME>]/<SENSOR ROLE NAME>/status |
carla_msgs.CarlaTrafficLightStatusList | list of all traffic lights with their status |
/carla/[<PARENT ROLE NAME>]/<SENSOR ROLE NAME>/info |
carla_msgs.CarlaTrafficLightInfoList | static information for all traffic lights (e.g. position) |
Topic | Type | Description |
---|---|---|
/carla/[<PARENT ROLE NAME>]/<SENSOR ROLE NAME> |
carla_msgs.CarlaActorList | list of all carla actors |
This pseudo-sensor allows to control the position and velocity of the actor it is attached to (e.g. an ego_vehicle) by publishing pose and velocity within Pose and Twist datatypes. CAUTION: This control method does not respect the vehicle constraints. It allows movements impossible in the real world, like flying or rotating. Currently this sensor applies the complete linear vector, but only the yaw from angular vector.
Topic | Type | Description |
---|---|---|
/carla/[<PARENT ROLE NAME>]/<SENSOR ROLE NAME>/set_transform |
geometry_msgs.Pose | transform to apply to the sensor's parent |
/carla/[<PARENT ROLE NAME>]/<SENSOR ROLE NAME>/set_target_velocity |
geometry_msgs.Twist | velocity (angular and linear) to apply to the sensor's parent |
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:
# for ros1
rostopic pub /carla/ego_vehicle/vehicle_control_cmd carla_msgs/CarlaEgoVehicleControl "{throttle: 1.0, steer: 0.0}" -r 10
# for ros2
ros2 topic 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:
# for ros1
rostopic pub /carla/ego_vehicle/vehicle_control_cmd carla_msgs/CarlaEgoVehicleControl "{throttle: 1.0, steer: 1.0}" -r 10
# for ros2
ros2 topic 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
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/weather_control |
carla_msgs.CarlaWeatherParameters | set the CARLA weather parameters |
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/<ID>/walker_control_cmd (subscriber) |
carla_msgs.CarlaWalkerControl | Control a walker |
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 |
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.