create-sensor
Skill này làm gì
Skill đặt cảm biến lên một xe hoặc actor khác trong mô phỏng CARLA. Skill dành cho lập trình viên thu thập dữ liệu cảm biến để kiểm thử lái xe tự động.
Khi nào nên dùng
- ✓Khi bạn muốn có camera, lidar hoặc cảm biến khác trên một xe mô phỏng.
- ✓Khi bạn muốn đặt vị trí, độ phân giải hoặc tần suất cập nhật của cảm biến.
- ✓Khi bạn muốn cảm biến publish dữ liệu sang ROS 2.
Liên kết skill
https://github.com/carla-simulator/carla/blob/ue58-dev/Skills/python-api/create-sensor/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
“Hãy thêm một camera phía trước 800 x 600 vào xe ego và một lidar trên nóc xe, rồi cho tôi ID của chúng.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Agent tạo blueprint cảm biến, gắn nó vào actor đã chọn với một vị trí lắp, và đặt các thuộc tính như độ phân giải, góc nhìn và tần suất cập nhật. Agent in ra id của cảm biến để bạn đọc dữ liệu sau này.
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.
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
Câu hỏi thường gặp
Skill này có đọc dữ liệu cảm biến không?
Không. Skill chỉ đặt và quản lý cảm biến, còn đọc đầu ra là một skill riêng.
Vị trí lắp mặc định là gì?
Mặc định là 1,5 mét về phía trước và 2,4 mét lên cao trên xe.
Làm sao xem các loại cảm biến có sẵn?
Skill có lệnh types liệt kê các blueprint cảm biến.
Chi tiết
Mô tả gốc của tác giả
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
Độ phổ biến
- Sao GitHub
- 15k
- Vị trí xếp hạng
- #11090
- 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ự
blucli
394kGiúp agent của bạn tìm, phát, tạm dừng, nhóm và chỉnh âm lượng loa Bluesound và NAD qua lệnh blu.
camsnap
394kGiúp agent của bạn chụp ảnh, quay clip ngắn hoặc lấy sự kiện chuyển động từ camera mạng và webcam nội bộ mà bạn đã thiết lập.
eightctl
394kGiúp agent của bạn kiểm tra và điều khiển thiết bị Eight Sleep pod, gồm nhiệt độ, báo thức và lịch ngủ.