read-sensor
它能做什么
这项技能读取安装在模拟车辆上的传感器输出。适合想查看或保存传感器记录内容的开发者。
适用场景
- ✓当你想查看模拟汽车上摄像头或激光雷达的数据流时。
- ✓当你想把传感器数据保存到文件以便之后使用时。
- ✓当你想快速查看传感器最新数据的摘要时。
技能链接
https://github.com/carla-simulator/carla/blob/ue58-dev/Skills/python-api/read-sensor/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请给我看前置摄像头的实时画面,并把每一帧保存到一个文件夹中。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体先按 ID、类型或所连车辆找到传感器,然后监听其数据流。它可以把摄像头画面保存为 PNG 文件,把激光雷达数据保存为点云文件,或在窗口中显示数据。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Read a sensor
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.
Point this at an existing sensor (make one with create-sensor)
and either show it in a window, save its stream to disk, or get a one-shot
info summary. The goal is: select a sensor → see it.
Selector (any one): --id N · --type sensor.camera.rgb · --attached-to hero.
Capture in lock-step, not as an observer
save takes the world's clock when the world is asynchronous, then ticks it
once per frame: one tick, one frame. --no-sync keeps the old passive
behaviour, and if another client already owns the clock this one observes
instead (the clock rule the spawn skills follow).
This is not a nicety. Capturing as a passive observer wedges the recording client on this build. Measured against a healthy server, with the world ticking and a second client still able to pull frames from the very same sensor:
| write path | frames before it froze |
|---|---|
save_to_disk inside the listen callback, HD |
396 |
| same, 720p | 147 |
save_to_disk moved to the main loop, queued |
222 |
own cv2 encode from raw_data |
248 |
| lock-step, client owns the clock | 401 of 401, no stall |
Every observer variant froze in futex_wait with no error and no further
I/O — so the write path was never the cause, the delivery model was. Replacing
save_to_disk and then the encoder was wasted effort; owning the clock fixed
it outright, and matches the pattern that captured 5388 frames for a video on
this same build.
Two consequences worth knowing:
- Timing is exact. 401 frames over 20.00 s of simulated time at 20 Hz, nothing dropped or duplicated, and the run is reproducible.
save_to_diskis still avoided for camera frames: the buffer is converted and written here (cv2, falling back to PIL). That change did not fix the stall on its own, but it keeps the encode where its cost is visible.
The duration budget is read off the world clock (elapsed_seconds), not summed
from per-frame deltas: summing counts observed frames, so a consumer slower
than the server takes minutes to "reach" 20 seconds.
Live Traffic Manager traffic and a lock-step capture are incompatible
Measured on 0.10.0: with the camera owning a 20 Hz clock and a [[spawn-vehicles]] holder attached as an observer, all 40 vehicles stood still for the whole 500-frame capture. The Traffic Manager lives in the process that created it and only steps when that process ticks the world, so a TM held by one client and a clock owned by another never advances. Traffic moved in earlier tests only because the holder was itself the ticker — and a holder that ticks forces this capture into observer mode, which is what wedges it.
So pick one:
| what you want | how |
|---|---|
| a capture with moving traffic | record the traffic first, then replay it into a lock-step capture. The replayer is server-side, needs no TM, and moved 33 of 50 replayed vehicles under the camera's clock |
| live TM traffic on screen, no frame capture | let the traffic holder own the clock and watch it in the window |
| a capture of a static scene | camera alone, as above |
The replay recipe, in order:
# 1. record the traffic while its holder owns the clock
python3 ../spawn-vehicles/scripts/vehicles.py spawn --count 50 --base-type car --hold &
python3 ../record-simulation/scripts/record.py clip --file /tmp/traffic.log --seconds 20
# 2. stop the holder, clear the scene, spawn the camera
# 3. capture in lock-step while the replay feeds the actors
python3 scripts/read_sensor.py save --id <cam> --out ./frames --seconds 20 &
python3 ../replay-recording/scripts/replay.py play --file /tmp/traffic.log --duration 20 --keep-scene
--keep-scene matters in step 3: without it the replay skill stops holders and
puts the world back to asynchronous, which takes the clock away from the
capture.
Instructions
Progress:
- [ ] Step 1: Check prerequisites (bash scripts/check_env.sh), clear FAILs
- [ ] Step 2: Make sure the sensor exists (create-sensor) and the world is ticking
- [ ] Step 3: info (sanity) → show (window) or save (dataset)
Commands need CARLA_HOST/CARLA_PORT from scripts/env.sh.
Step 1: Check prerequisites
bash scripts/
常见问题
保存时会让模拟保持同步吗?
会。当世界以异步方式运行时,这项技能会接管时钟,使每个时钟周期对应保存一帧。
它保存哪些格式?
摄像头保存为 PNG 文件,激光雷达保存为 PLY 点云文件。
我可以改用 ROS 读取传感器吗?
可以。这项技能可以列出某个传感器的 ROS 2 话题,方便你在 ROS 中读取。
详情
作者的原始描述
Listens to a CARLA sensor and either saves its data to files, shows it live in a window, prints a one-shot summary, or (ros-info) reports the native ROS 2 topics, QoS and enabled-for-ROS state so you can echo it from ROS instead. Cameras save as PNG (depth/semantic auto-colourised) and display in a pygame window; lidar saves as .ply and shows as a top-down scatter; IMU/GNSS/radar/collision stream to JSONL or the console. Use when the user asks to "show/view the camera", "display the lidar", "save the sensor data / capture a dataset", or "what is this sensor reading". Select the sensor by id, t
repo: carla-simulator/carla
热度
- GitHub 星标
- 15k
- 排名
- #11097
- 许可证
- 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 评估器,先检查设置,并保存可以恢复的检查点。