1. 安装

  1. 下载:注意需要下载对应carla版本的Scenario Runner (SR)

Releases · carla-simulator/scenario_runner

  1. 安装依赖: 建议使用conda环境
cd xxx/scenario_runner-0.9.11

#Python 2.x
sudo apt remove python-networkx #if installed, remove old version of networkx
pip2 install --user -r requirements.txt
#Python 3.x
sudo apt remove python3-networkx #if installed, remove old version of networkx
pip3 install --user -r requirements.txt
  1. 添加环境变量
export CARLA_ROOT=/path/to/your/carla/installation
export PYTHONPATH=$PYTHONPATH:${CARLA_ROOT}/PythonAPI/carla/dist/carla-<VERSION>.egg:${CARLA_ROOT}/PythonAPI/carla/agents:${CARLA_ROOT}/PythonAPI/carla
export SCENARIO_RUNNER_PATH=<path_to_scenario_runner>

2. 运行 SR example

./CarlaUE4.sh
python scenario_runner.py --scenario FollowLeadingVehicle_1 --reloadWorld
python manual_control.py

这只是相当于生成了world环境,车辆控制还需要运行自己的程序调用carla pythonAPI 进行控制

python scenario_runner.py --list 
可以看到所有的场景

也可以通过Group:运行一类场景。命令如下;

python scenario_runner.py --scenario group:FollowLeadingVehicle

下面是所有场景类型

此外,在运行时可以对运行情况进行录制,并在Carla中回放

python scenario_runner.py --scenario <scenario_name> --record <path/to/save/the/recorder/file>
在python脚本中通过
client.replay_file("recording01.log", start, duration, camera)
进行回放

3. 场景设置

SR 有两种模式,一种是继承基类自己写脚本,还没试过,详见官方doc