跳到正文
Skillpedia
测试15k · #11112

run-scenario

它能做什么

这项技能启动 CARLA 模拟器中一个现成的驾驶测试场景,并可列出你所用版本的 CARLA 支持运行的场景。适合想测试自动驾驶软件如何应对特定情况的人。

适用场景

  • ✓当你想运行标准测试,例如跟随前车行驶时。
  • ✓当你在选择场景之前,想查看已安装版本支持哪些场景时。
  • ✓当你希望测试接管主车,或让你自己的程序驾驶它时。

技能链接

https://github.com/carla-simulator/carla/blob/ue58-dev/Skills/scenario-runner/run-scenario/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/carla-simulator/carla/blob/ue58-dev/Skills/scenario-runner/run-scenario/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“你能在 CARLA 中运行 FollowLeadingVehicle 测试,并告诉我我的汽车是否通过了吗?”

每周 5 个新技能,1 分钟读完。

工作原理

智能体会通过配置名称选择场景,检查地图是否匹配,然后开始运行。如有需要,它会重新加载地图,并在测试结束时报告结果。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Run a scenario

Paths. scripts/… and references/… below are relative to the directory holding this SKILL.md. Your working directory is the user's project, not that directory, so prefix them with its absolute path or the command is not found.

A "scenario" here is a Python class in srunner/scenarios/ plus an XML config in srunner/examples/ that gives it a town, an ego spawn point and parameters. You select it by the config name (FollowLeadingVehicle_1), not the class name.

Two things decide whether a run works, and both are silent when wrong:

  • the branch — which scenarios and which towns exist at all,
  • the map — a scenario declares its town, and ScenarioRunner refuses to run if the server is on a different one unless you let it reload.

Instructions

Progress:
- [ ] Step 1: Check prerequisites (bash scripts/check_env.sh), clear FAILs
- [ ] Step 2: List what this checkout can run
- [ ] Step 3: Run it, with --reloadWorld unless the map already matches
- [ ] Step 4: Give the ego a driver (manual_control or an agent) if it needs one
- [ ] Step 5: Read the result; reset the world to async when done

Step 1-2: What can I run

source scripts/env.sh
bash scripts/check_env.sh

python3 scripts/list_scenarios.py                 # every config, its type and town
python3 scripts/list_scenarios.py --town Town04_Opt   # only what fits the loaded map
python3 scripts/list_scenarios.py --check             # configs whose type or town does not resolve
python3 scripts/list_scenarios.py --here          # only what fits the *running* server's map
python3 scripts/list_scenarios.py --types         # class -> configs, incl. route-only classes

list_scenarios.py parses the XML directly, so it works with no server and no carla import — unlike scenario_runner.py --list, which constructs a client first.

Step 3: Run

source scripts/env.sh

# the canonical smoke test
bash scripts/run_scenario.sh FollowLeadingVehicle_1

# every config of one class, in sequence
bash scripts/run_scenario.sh group:FollowLeadingVehicle

# deterministic: 20 Hz synchronous, results printed and written as JSON
SYNC=1 FRAME_RATE=20 OUTPUT=1 JSON=1 OUTPUT_DIR=./results \
    bash scripts/run_scenario.sh ControlLoss_1

# repeat with randomised parameters, and record for later analysis
REPETITIONS=3 RANDOMIZE=1 RECORD=recordings bash scripts/run_scenario.sh DynamicObjectCrossing_1

Or call ScenarioRunner directly — the wrapper only adds the env, the map check and the async reset:

python3 "$SCENARIO_RUNNER_ROOT/scenario_runner.py" --scenario FollowLeadingVehicle_1 --reloadWorld

Knobs (all env vars on run_scenario.sh):

Var Effect
RELOAD=0 do not reload the world (default reloads; needed when the map differs)
SYNC=1 synchronous mode at FRAME_RATE Hz — required for reproducibility
FRAME_RATE sync tick rate, default 20
OUTPUT=1 / FILE=1 / JSON=1 / JUNIT=1 result to stdout / .txt / .json / .xml
OUTPUT_DIR where those files land
REPETITIONS / RANDOMIZE=1 repeat count / randomise scenario parameters
AGENT / AGENT_CONFIG drive the ego with an agent (route mode only — see below)
RECORD=dir CARLA recorder log + a criteria JSON, relative to $SCENARIO_RUNNER_ROOT
WAIT_FOR_EGO=1 attach to an ego someone else spawned instead of spawning one
DEBUG=1 print the behaviour tree every tick
TIMEOUT client timeout, default 120 s — an editor map switch needs it
MAX_WALL wall-clock guard, default 1800 s; 0 disables. ScenarioRunner can print its verdict and never exit

Step 4: Somebody has to drive

Most scenarios spawn the ego and then wait for it to move. Nothing drives it by itself. If you see

Preparing scenario: FollowLeadingVehicle_1
ScenarioManager: Running scenario FollowVehicle
No more scenarios .... Exiting

with nothing happening, that is the symptom. Options:

# keyboard control, in a second terminal
python3 "$SCENARIO_RUNNER_ROOT/manual_control.py"

# or hand the ego to the autopilot instead of driving it
python3 "$SCENARIO_RUNNER_ROOT/manual_control.py" -a

manual_control.py attaches to the vehicle whose role_name equals --rolename, default hero, which is the ego role ScenarioRunner uses, so no flag is needed to find the ego. -a/--autopilot only switches on the autopilot. It needs pygame, which `requirement

常见问题

为什么场景有时无法启动?

通常是因为模拟器所用的地图与场景要求的不同,或者该场景不在你安装的软件版本中。

我可以录制这次运行吗?

可以。运行可以被保存,以便之后回放。

主车需要驾驶员吗?

有些场景需要,因此你可以选择手动控制或自动智能体。

详情

作者的原始描述

Runs a single ScenarioRunner Python scenario (or a whole group) against a running CARLA server — FollowLeadingVehicle, ControlLoss, DynamicObjectCrossing, SignalizedJunctionLeftTurn and the rest of srunner/examples — in sync or async mode, with result output, recording and manual/agent control of the ego. Lists what is runnable on the checked-out branch and on the loaded map. Use when the user asks to "run a scenario", "test FollowLeadingVehicle", "list scenarios", "run a CARLA traffic scenario", or reports a scenario that is "not supported".

repo: carla-simulator/carla

热度

GitHub 星标
15k
排名
#11112
许可证
MIT
更新时间
2026/11/2

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能