spawn-vehicles
Skill này làm gì
Skill thêm xe vào một mô phỏng đường phố CARLA đang chạy và xóa chúng khi bạn xong. Skill dành cho người xây dựng hoặc kiểm thử phần mềm lái xe tự động cần có giao thông trên đường.
Khi nào nên dùng
- ✓Khi bạn muốn các con đường đông đúc có xe tự chạy.
- ✓Khi bạn cần một xe thử nghiệm đặt trên đường để phần mềm của bạn điều khiển.
- ✓Khi bạn muốn dọn các xe đã thêm để mô phỏng trống trở lại.
Liên kết skill
https://github.com/carla-simulator/carla/blob/ue58-dev/Skills/python-api/spawn-vehicles/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Bạn có thể thêm 40 xe tự lái vào mô phỏng đường của CARLA rồi xóa chúng khi tôi xong không?”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Agent đặt xe tại các điểm sinh của bản đồ và giao từng xe cho hệ thống giao thông, hệ thống này lái xe dọc đường. Xóa chúng sẽ loại các xe đó khỏi mô phỏng.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
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 --
Câu hỏi thường gặp
Tôi có thể chọn loại xe xuất hiện không?
Có. Skill có thể lọc các mẫu xe được dùng, để bạn chọn loại nhất định thay vì ngẫu nhiên.
Có chạy được với simulator chậm hoặc không ổn định không?
Skill đặt simulator sang chế độ từng bước, điều mà hệ thống giao thông cần để lái ổn định.
Tôi có thể đặt một xe cụ thể thay vì giao thông không?
Có. Có thể đặt một xe hero hoặc ego duy nhất, và nó có thể được đặt tên để publish ROS 2.
Chi tiết
Mô tả gốc của tác giả
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
Độ phổ biến
- Sao GitHub
- 15k
- Vị trí xếp hạng
- #11102
- Giấy phép
- MIT
- Cập nhật
- 2/11/2026
Bình luận
- …
Thêm skill từ kho mã này
create-leaderboard-route
15kGiúp agent của bạn tạo file tuyến đường CARLA Leaderboard bằng cách đặt các điểm waypoint và trigger kịch bản từ camera của simulator, rồi kiểm tra và sắp xếp chúng.
package-leaderboard-agent
15kGiúp agent của bạn đóng gói một agent lái xe thành image Docker để nộp lên CARLA Leaderboard, kiểm tra cấu trúc thư mục và thử rằng image nạp được agent.
read-leaderboard-results
15kGiúp agent của bạn đọc file kết quả CARLA Leaderboard, giải thích điểm và vi phạm của từng tuyến, và chấm lại một lần chạy theo phiên bản luật khác.
run-leaderboard-evaluation
15kGiúp agent của bạn chạy bộ đánh giá CARLA Leaderboard trên một tập tuyến với agent lái xe, kiểm tra thiết lập trước và lưu checkpoint để có thể tiếp tục.
Skill tương tự
test-driven-development
311kDạy agent của bạn viết kiểm thử thất bại trước, xem nó thất bại, rồi viết đoạn mã ngắn nhất để vượt qua trước khi làm bất kỳ tính năng hay bản sửa nào.
verification-before-completion
311kDạy agent của bạn chạy kiểm tra thực tế và đọc kết quả đầu ra trước khi khẳng định một việc, bản sửa hoặc bản build đã hoàn thành hay vượt qua.
migrate-to-shoehorn
310kThay các ép kiểu rủi ro trong tệp kiểm thử bằng thư viện shoehorn, để các bài kiểm thử dùng dữ liệu một phần vẫn qua được kiểm tra kiểu.