control-traffic
它能做什么
该技能塑造模拟器中自动交通的行驶方式。适合希望测试场景中的交通更快、更慢或更随机的人。
适用场景
- ✓当你希望自动驾驶车辆行驶得更快或更慢的时候。
- ✓当你希望车辆保持更大或更小的距离,或闯红灯的时候。
- ✓当你希望使用固定种子使交通可以重复的时候。
技能链接
https://github.com/carla-simulator/carla/blob/ue58-dev/Skills/python-api/control-traffic/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请让所有交通提速 30%,保持 3 米的车距,并使用固定种子以便重复运行。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会把设置应用于某个 Traffic Manager 端口上的所有自动驾驶车辆,或其中某一辆。它使用生成车辆时所用的同一端口,并可以设置用于重复运行的种子。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Control the Traffic Manager
Paths.
scripts/…andreferences/…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.
Shape how autopilot vehicles drive — globally (all cars on a TM port) or
per-vehicle. This is the counterpart to control-vehicle:
that skill drives one car manually; this one tunes the autonomous traffic. It
affects cars enrolled in autopilot (see spawn-vehicles),
on the matching --tm-port.
Instructions
Progress:
- [ ] Step 1: Check prerequisites (bash scripts/check_env.sh), clear FAILs
- [ ] Step 2: Have autopilot vehicles on the TM port (spawn-vehicles)
- [ ] Step 3: Apply global and/or per-vehicle settings
- [ ] Step 4: Watch the change on a rendered server
Commands need CARLA_HOST/CARLA_PORT/TM_PORT from scripts/env.sh. Use the
same --tm-port the vehicles were spawned on (default 8000).
Step 1: Check prerequisites
bash scripts/check_env.sh
Step 3: Tune
source scripts/env.sh
# GLOBAL: all traffic 30% faster than the limit, keep 3 m, deterministic
python3 scripts/traffic.py global --speed-diff -30 --distance 3 --seed 42
# EVERY car: run 50% of red lights, allow lane changes
python3 scripts/traffic.py all --ignore-lights 50 --auto-lane-change on
# ONE car (the ego's neighbour): crawl, hug the right, TM manages its lights
python3 scripts/traffic.py vehicle --id 42 --speed-diff 60 --lane-offset 0.5 --lights on
# make the ego's autopilot reckless
python3 scripts/traffic.py vehicle --role hero --ignore-vehicles 40 --ignore-signs 100
# TM sync (only alongside a synchronous world — see set-world-settings)
python3 scripts/traffic.py sync on
Step 4: Verify
Watch the traffic on a rendered server. Settings are write-only on the TM (no read-back), so the command reports what it set and to how many vehicles.
Examples
Example 1: faster traffic
User says: "make the traffic move faster"
global --speed-diff -40 (40% above the limit). Negative = faster.
Example 2: chaos for testing
User says: "make cars run lights and ignore each other"
all --ignore-lights 100 --ignore-vehicles 60 — expect collisions (that's the
point of the test).
Example 3: deterministic traffic run
User says: "same traffic behaviour every run"
global --seed 42, in synchronous mode (sync on + set-world-settings), spawn
with a seed. Seed + sync is what makes it reproducible.
Troubleshooting
Problem: nothing changes
Cause: cars aren't on this TM port, or aren't on autopilot, or you set the ego
(which you're driving manually).
Solution: match --tm-port to the spawn; ensure autopilot is on (spawn-vehicles
default); target autopilot cars.
Problem: cars froze after sync on
Cause: TM sync without a synchronous, ticked world (or vice-versa).
Solution: keep TM sync and world sync in step and tick the world (set-world-settings).
Problem: --speed-diff 30 made them slower, not faster
Cause: the value is % below the limit.
Solution: use a negative value to go faster (-30 = 30% above the limit).
Problem: collisions everywhere
Cause: high --ignore-vehicles / --ignore-lights.
Solution: lower them; 0 restores full caution.
Outputs
Traffic Manager behaviour state (global + per-vehicle). No file, no read-back; the command reports what it applied.
Detail (every setting, the speed-difference sign, hybrid physics, determinism, sync coupling) in references/traffic-manager.md.
常见问题
它能更改哪些设置?
速度、跟车距离、闯红灯或标志、变道、车道偏移,以及确定性种子。
它会控制我自己的车吗?
不会。它调整的是自动驾驶车辆,而手动驾驶由单独的技能负责。
应该使用哪个端口?
生成车辆时所用的同一个 Traffic Manager 端口,默认为 8000。
详情
作者的原始描述
Tunes the CARLA Traffic Manager that drives autopilot vehicles — global and per-vehicle speed, following distance, running lights/signs, lane-change behaviour, lane offset, TM-managed lights, deterministic seed, hybrid physics, and TM sync mode. Use when the user asks to "make the traffic faster/slower", "let cars run red lights", "keep more distance", "stop lane changes", "make traffic deterministic", or otherwise change how autopilot cars behave. For manually driving one car, use control-vehicle.
repo: carla-simulator/carla
热度
- GitHub 星标
- 15k
- 排名
- #11088
- 许可证
- MIT
- 更新时间
- 2026/11/2
评论
- …
同一仓库的更多技能
create-leaderboard-route
15k帮你的智能体通过在模拟器视角中放置路径点和场景触发器,构建 CARLA Leaderboard 路线文件,并对其进行检查和排序。
package-leaderboard-agent
15k帮你的智能体把驾驶智能体打包成 Docker 镜像,用于提交 CARLA Leaderboard,并检查文件夹结构,测试镜像能否加载它。
read-leaderboard-results
15k帮你的智能体阅读 CARLA Leaderboard 结果文件,解释每条路线的得分和违规情况,并按另一规则版本重新计分。
run-leaderboard-evaluation
15k帮你的智能体用你的驾驶智能体在一组路线上运行 CARLA Leaderboard 评估器,先检查设置,并保存可以恢复的检查点。