spawn-vehicles
它能做什么
这项技能在运行中的 CARLA 道路模拟中添加汽车,并在你完成后将其移除。适合需要路上有车流的自动驾驶软件开发和测试人员。
适用场景
- ✓当你想让繁忙的道路上有自动驾驶汽车时。
- ✓当你需要在路上放置一辆测试车,供你的软件控制时。
- ✓当你想清理添加的汽车,让模拟恢复为空时。
技能链接
https://github.com/carla-simulator/carla/blob/ue58-dev/Skills/python-api/spawn-vehicles/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“你能在我的 CARLA 道路模拟中加入 40 辆自动驾驶汽车,等我完成后再把它们移除吗?”
每周 5 个新技能,1 分钟读完。
工作原理
智能体把汽车放置在地图的生成点上,并将每辆车交给交通系统,由它沿道路行驶。移除汽车会将这些车辆从模拟中删除。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Spawn autopilot vehicles
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.
Populate the roads with self-driving traffic. Vehicles are placed at the map's
predefined spawn points and, by default, handed to the Traffic Manager
autopilot at spawn time so they drive the road network autonomously. destroy
removes them.
spawn and line make the world synchronous. The Traffic Manager is not
reliable driving an asynchronous server: it runs its own loop against a server
advancing at whatever rate it likes. Measured on 0.10.0, async, 50 autopilot
vehicles with the spawning client alive and holding the TM: only 24 were
moving, and the actor count decayed on its own — 50 vehicles down to 39 and 15
walkers down to 5 over a couple of minutes. With a fixed timestep and the TM in
sync, 37 of 50 move and nothing decays. --no-sync keeps the old behaviour.
The TM cannot be driven by another client's tick
The Traffic Manager steps only when the process that created it ticks the world. Measured on 0.10.0: with a camera client owning a 20 Hz clock and this skill attached as an observer, its 40 vehicles never moved at all — no error, just a frozen scene. So a held traffic pool and a lock-step frame capture cannot share a world; record the traffic here and replay it into the capture instead ([[read-sensor]] has the recipe).
The clock rule
The world settings are read before anything else happens:
- asynchronous — this client switches it to synchronous (
--delta, default 0.05 s = 20 Hz), puts the TM in sync, and becomes the ticker. - already synchronous — another client owns the clock. This one never calls
tick(); it observes withwait_for_tick(). Ticking a world you do not own silently drops commands — it is what stoppedspawn-walkers'start()from landing.
The previous settings are restored on release, because a synchronous world with
nothing ticking does not advance and looks exactly like a hung server. Stop a
holder with Ctrl+C, never kill -9: the restore is in a finally.
The Traffic Manager lives in the client process that created it. So a
spawn that exits leaves the vehicles registered with a dead TM: they sit at
throttle 0.00 for ever, in async and sync. Pass --hold to keep the TM
open (Ctrl+C releases it, and the vehicles then coast to a stop). Measured on
0.10.0: without --hold, 0/50 vehicles move; with it, 49/50 move.
The same is true of controller.ai.walker in [[spawn-walkers]] — its
controllers stop when their client exits — so a scene with both wants two
resident processes: this one owning the clock, the walker one held as an
observer.
Instructions
Progress:
- [ ] Step 1: Check prerequisites (bash scripts/check_env.sh), clear FAILs
- [ ] Step 2: Spawn N vehicles with --hold (the TM dies with the process without it)
- [ ] Step 3: Verify visually / via the world-data skill; spawn reports its count
- [ ] Step 4: Ctrl+C the held process, then destroy when done
Commands need CARLA_HOST/CARLA_PORT/TM_PORT from scripts/env.sh.
Negative coordinates: pass --at with an = (--at=-24,-57,0.6) so the
leading minus isn't parsed as a flag.
Step 1: Check prerequisites
bash scripts/check_env.sh
Step 2-4: Spawn / list / destroy
source scripts/env.sh
# 40 vehicles driving around on autopilot — --hold keeps the TM (and so the
# driving) alive; without it they spawn, then freeze when this command returns.
# The world is put in sync at 20 Hz and this client ticks it.
python3 scripts/vehicles.py spawn --count 40 --hold
# leave the world asynchronous (the old behaviour; the TM misbehaves)
python3 scripts/vehicles.py spawn --count 40 --hold --no-sync
# a different fixed timestep
python3 scripts/vehicles.py spawn --count 40 --hold --delta 0.033
# four-wheeled cars only, reproducible
python3 scripts/vehicles.py spawn --count 30 --safe --seed 42
# only Teslas, parked (no autopilot)
python3 scripts/vehicles.py spawn --count 10 --filter 'vehicle.tesla.*' --no-autopilot
# 5 vehicles in one lane, 15 m apart, starting near (x,y,z)
python3 scripts/vehicles.py line --at 30,20,0 --count 5 --gap 15
# ...as a static queue (no autopilot), laid behind the point
python3 scripts/vehicles.py line --at 30,20,0 --count 5 --gap 15 --
常见问题
我可以选择出现的汽车类型吗?
可以。这项技能可以筛选使用的汽车型号,让你选择特定类型而不是随机类型。
这适用于缓慢或不稳定的模拟器吗?
这项技能会把模拟器设为逐步模式,交通系统需要这种模式才能可靠地行驶。
我能放置一辆特定的车而不是交通车流吗?
可以。可以放置单个英雄车或自车,并可为其命名,以便 ROS 2 发布。
详情
作者的原始描述
Spawns vehicles on a running CARLA server and destroys them — scattered across the map's spawn points on Traffic Manager autopilot, a row queued in a single lane at a fixed spacing, or a single hero/ego vehicle (optionally named for native ROS 2 publishing with --ros-name). Covers blueprint filtering, the atomic autopilot hand-off, and cleanup. Use when the user asks to "spawn vehicles/cars/traffic", "add N cars driving around", "put cars in a lane 15 m apart", "spawn the ego/hero vehicle", or "remove the vehicles".
repo: carla-simulator/carla
热度
- GitHub 星标
- 15k
- 排名
- #11102
- 许可证
- 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 评估器,先检查设置,并保存可以恢复的检查点。