Carla ROS Scenario Runner

The CARLA ROS Scenario Runner package is a wrapper to execute OpenScenarios with the CARLA Scenario Runner via ROS.


Before you begin

  • Follow the Scenario Runner "Getting started' tutorial to install Scenario Runner.
  • Install the Python module Pexpect:
sudo apt install python-pexpect

Using ROS Scenario Runner

The ROS Scenario Runner is best used from within the rviz_carla_plugin.

Note

It is currently not supported to change the map. Each scenario will need to use the currently active map.

An example scenario is found here. Of particular importance is the setup of the ROS controller:

<Controller name="EgoVehicleAgent">
    <Properties>
        <Property name="module" value="carla_ros_scenario_runner.ros_vehicle_control" />
        <Property name="launch" value="carla_ad_agent.launch"/>
        <Property name="launch-package" value="carla_ad_agent"/>
        <Property name="path_topic_name" value="waypoints"/>
    </Properties>
</Controller>

The above code example shows an instance of carla_ad_agent being launched. Any additional <Property> should be appended as a ROS parameter (name:=value).


Run ROS Scenario Runner

1. Run the ROS Scenario Runner package:

# ROS 1
roslaunch carla_ros_scenario_runner carla_ros_scenario_runner.launch scenario_runner_path:=<path_to_scenario_runner>

# ROS 2
ros2 launch carla_ros_scenario_runner carla_ros_scenario_runner.launch.py scenario_runner_path:=<path_to_scenario_runner>

2. Run a scenario:

# ROS 1
rosservice call /scenario_runner/execute_scenario "{ 'scenario': { 'scenario_file': '<full_path_to_openscenario_file>' } }"

# ROS 2
ros2 service call /scenario_runner/execute_scenario carla_ros_scenario_runner_types/srv/ExecuteScenario "{ 'scenario': { 'scenario_file': '<full_path_to_openscenario_file>' } }"

ROS API

Services

Service Type Description
/scenario_runner/execute_scenario carla_ros_scenario_runner_types.ExecuteScenario Execute a scenario. If another scenario is currently running, it gets stopped.


Publications

Topic Type Description
/scenario_runner/status carla_ros_scenario_runner_types.CarlaScenarioRunnerStatus The current status of the scenario runner execution (used by the rviz_carla_plugin)

The controller ros_vehicle_control provides the following topics: | Topic | Type | Description | |-------|------|-------------| | /carla/<ROLE NAME>/waypoints | nav_msgs.Path | the path defined within the scenario. Note: The topic name can be changed by modifying the parameter path_topic_name | | /carla/<ROLE NAME>/target_speed | std_msgs.Float64 | the target speed as defined within the scenario |