create-sensor
它能做什么
这项技能把传感器安装在 CARLA 模拟中的车辆或其他角色上。适合为自动驾驶测试收集传感器数据的开发者。
适用场景
- ✓当你想在模拟汽车上安装摄像头、激光雷达或其他传感器时。
- ✓当你想设置传感器的位置、分辨率或更新频率时。
- ✓当你想让传感器把数据发布到 ROS 2 时。
技能链接
https://github.com/carla-simulator/carla/blob/ue58-dev/Skills/python-api/create-sensor/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请帮我在主车前方加一个 800 乘 600 的摄像头,并在车顶加一个激光雷达,然后告诉我它们的 ID。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会生成传感器蓝图,按设定的安装位置把它挂到所选角色上,并设置分辨率、视场角和更新频率等属性。它会输出传感器的 ID,方便你之后调用。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Create 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.
Spawn a sensor and (usually) attach it to a vehicle so it moves with it. The
sensor persists as an actor; its id is printed so the
read-sensor skill can save or display its data. This
skill is placement/lifecycle only — reading is the other skill.
Instructions
Progress:
- [ ] Step 1: Check prerequisites (bash scripts/check_env.sh), clear FAILs
- [ ] Step 2: Have a parent actor if attaching (spawn-vehicles ego)
- [ ] Step 3: Spawn the sensor with a type, mount transform, and attributes
- [ ] Step 4: Note the printed id; read it with read-sensor; destroy when done
Commands need CARLA_HOST/CARLA_PORT from scripts/env.sh.
Step 1: Check prerequisites
bash scripts/check_env.sh
Step 3: Spawn
source scripts/env.sh
python3 scripts/sensors.py types # list sensor blueprints
# an 800x600 dashcam on the ego (default mount x=1.5, z=2.4)
python3 scripts/sensors.py spawn --type camera.rgb --attach-to hero \
--attr image_size_x=800 --attr image_size_y=600 --attr fov=90
# a lidar on the ego roof
python3 scripts/sensors.py spawn --type lidar.ray_cast --attach-to hero --z 2.5 \
--attr range=50 --attr points_per_second=200000 --attr rotation_frequency=20
# a depth camera; a GNSS; a collision sensor
python3 scripts/sensors.py spawn --type camera.depth --attach-to hero
python3 scripts/sensors.py spawn --type other.gnss --attach-to hero
python3 scripts/sensors.py spawn --type other.collision --attach-to hero
python3 scripts/sensors.py destroy # remove all sensors
# turn ROS publishing on for sensors that already exist
python3 scripts/sensors.py ros --id 123
python3 scripts/sensors.py ros --filter 'sensor.camera.*' --disable
--attach-to <role> attaches to that vehicle (ego = hero); --parent-id N
attaches to any actor; omit both for a world-fixed sensor. --attachment SpringArm
gives a smooth chase mount. Repeat --attr key=value for blueprint attributes.
Publishing to ROS 2
Only meaningful on a server started with --ros2 ([[run-carla-server]] ROS2=1).
# a lidar that publishes on rt/carla/hero/lidar/point_cloud
python3 scripts/sensors.py spawn --type lidar.ray_cast --attach-to hero --z 2.4 \
--ros --ros-name lidar
# a camera with its own TF frame and no transform broadcast
python3 scripts/sensors.py spawn --type camera.rgb --attach-to hero \
--ros --ros-name front --ros-frame-id front_cam --no-ros-tf
--ros is not optional decoration — without it the sensor publishes nothing.
A CARLA sensor is only ticked while something listens to its stream
(ASensor::Tick returns early otherwise), and enable_for_ros() is what marks
the stream as listened-to without a Python client. --ros-name/--ros-frame-id/
--no-ros-tf set the ros_name / ros_frame_id / ros_publish_tf blueprint
attributes, which the server reads once at registration: they cannot be
changed after spawn.
Topic layout (spawn prints the exact list):
| Sensor | Topics under the base name | Type |
|---|---|---|
| any camera | /image, /camera_info |
sensor_msgs/Image, CameraInfo |
camera.dvs |
/image, /camera_info, /point_cloud |
+ PointCloud2 |
lidar.*, other.radar |
/point_cloud |
sensor_msgs/PointCloud2 |
other.imu |
(the base name itself) | sensor_msgs/Imu |
other.gnss |
(the base name itself) | sensor_msgs/NavSatFix |
other.collision |
(the base name itself) | carla_msgs/CarlaCollisionEvent |
other.lane_invasion, other.obstacle, other.rss |
none — no native publisher exists | — |
Base name is rt/carla/<ros_name>, nested as
rt/carla/<parent ros_name>/<ros_name> when attached; unnamed sensors become
actor<id>. Transforms go to the single rt/tf topic, parented to the attach
parent's frame (or map).
All of this is verified against a live server: a lidar spawned as
--attach-to hero --ros-name lidar without --ros produced no topic at all;
ros --id N made /carla/hero/lidar/point_cloud and /tf appear at once —
/tf exists only because a sensor publishes, never from the vehicle alone. Two
practical notes:
- Rates follow the tick. With `s
常见问题
这项技能会读取传感器数据吗?
不会。它只负责放置和管理传感器,读取其输出需要另一项技能。
默认的安装位置是什么?
默认位置在车辆前方 1.5 米、上方 2.4 米处。
如何查看有哪些传感器类型?
这项技能提供一个 types 命令,可以列出所有传感器蓝图。
详情
作者的原始描述
Spawns and attaches sensors on a running CARLA server — cameras (rgb/depth/semantic/instance/optical-flow/normals), lidar, radar, IMU, GNSS, collision/lane-invasion/obstacle — to the ego or any actor, with a mount transform and blueprint attributes (resolution, fov, sensor_tick, lidar range/points, …). Also sets up native ROS 2 publishing (--ros to enable_for_ros, --ros-name/--ros-frame-id topic and TF naming) and prints the topics the sensor will publish. Use when the user asks to "add a camera/lidar/sensor", "put a dashcam on the ego", "attach a depth camera", "mount a sensor", or "publish a
repo: carla-simulator/carla
热度
- GitHub 星标
- 15k
- 排名
- #11090
- 许可证
- 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 评估器,先检查设置,并保存可以恢复的检查点。