control-vehicle
它能做什么
该技能直接控制 CARLA 模拟中的一辆车。适合希望亲自驾驶汽车或测试特定控制命令的人。
适用场景
- ✓当你想手动操纵、加速或刹车某辆特定汽车的时候。
- ✓当你想设置速度目标,或打开或关闭车门的时候。
- ✓当你需要停止对某辆车的手动驾驶的时候。
技能链接
https://github.com/carla-simulator/carla/blob/ue58-dev/Skills/python-api/control-vehicle/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“让自车以一半油门向前行驶三秒,然后刹车。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会把控制输入发送给选定的车辆,并先为该车关闭自动驾驶。它可以把一条命令保持设定的时间,而停止命令会结束手动驾驶。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Control a vehicle directly
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.
Drive one vehicle yourself: control input, Ackermann speed target, lights, doors,
physics. It targets the ego (role_name = hero) by default, or any vehicle by
--id / --role / --filter. This is manual control — control and
ackermann turn autopilot off first; for autonomous traffic use the
control-traffic skill instead.
Instructions
Progress:
- [ ] Step 1: Check prerequisites (bash scripts/check_env.sh), clear FAILs
- [ ] Step 2: Ensure a target vehicle exists (spawn-vehicles ego)
- [ ] Step 3: Apply the command (control / ackermann / lights / door / physics)
- [ ] Step 4: Confirm on a rendered server; `stop` to halt manual driving
Commands need CARLA_HOST/CARLA_PORT/TM_PORT from scripts/env.sh.
Step 1: Check prerequisites
bash scripts/check_env.sh
Step 3: Control
source scripts/env.sh
# drive the ego forward for 3 s, then it brakes
python3 scripts/vehicle_control.py control --throttle 0.5 --hold 3
# turn while creeping forward
python3 scripts/vehicle_control.py control --throttle 0.3 --steer -0.4 --hold 2
# hold a target speed (built-in controller does throttle/brake for you)
python3 scripts/vehicle_control.py ackermann --speed 8
# lights: headlights + brake on; position off
python3 scripts/vehicle_control.py lights --on LowBeam,Brake --off Position
# left blinker on a specific car
python3 scripts/vehicle_control.py lights --filter '*prius*' --on LeftBlinker
# doors
python3 scripts/vehicle_control.py door --open FL,FR
python3 scripts/vehicle_control.py door --close All
# physics: read, then make it heavier / draggier
python3 scripts/vehicle_control.py physics --show
python3 scripts/vehicle_control.py physics --mass 2200 --drag 0.4
# emergency stop
python3 scripts/vehicle_control.py stop
# what ROS 2 topics drive this vehicle (read-only)
python3 scripts/vehicle_control.py ros-info
Driving it from ROS 2
On a server started with --ros2 ([[run-carla-server]] ROS2=1), the hero
vehicle exposes two command topics — the server subscribes, so the commands come
from outside this skill:
| Topic (DDS name) | Message | Maps to |
|---|---|---|
rt/carla/<ros_name>/vehicle_control_cmd |
carla_msgs/CarlaEgoVehicleControl |
carla.VehicleControl (throttle, steer, brake, hand_brake, reverse, gear, manual_gear_shift) |
rt/carla/<ros_name>/ackermann_control_cmd |
ackermann_msgs/AckermannDriveStamped |
carla.VehicleAckermannControl (steering_angle, speed, acceleration, jerk) |
ros-info prints them for the resolved vehicle plus a ready-to-run
ros2 topic pub line, and says so plainly when the target cannot be driven
from ROS: only role_name = hero gets subscribers (the server tests that string
in ActorDispatcher), so ordinary traffic never does. Spawn the hero with
[[spawn-vehicles]] ego --ros-name <name>.
You need the message definitions to publish. Verified: neither type ships with
a stock ROS 2 install, so ros2 topic pub carla_msgs/msg/... fails with an unknown
type until you provide them:
| Type | Where it comes from |
|---|---|
ackermann_msgs/AckermannDriveStamped |
sudo apt install ros-$ROS_DISTRO-ackermann-msgs |
carla_msgs/CarlaEgoVehicleControl |
not an apt package — build carla_msgs from carla-ros-bridge, or hand-write a one-message package (below) |
A minimal carla_msgs is enough and takes a minute — this exact recipe was used to
drive the hero from ROS (0 → 64 km/h) on a packaged server:
mkdir -p ws/src/carla_msgs/msg
cat > ws/src/carla_msgs/msg/CarlaEgoVehicleControl.msg <<'EOF'
std_msgs/Header header
float32 throttle
float32 steer
float32 brake
bool hand_brake
bool reverse
int32 gear
bool manual_gear_shift
EOF
# + a standard ament_cmake package.xml / CMakeLists.txt calling
# rosidl_generate_interfaces(${PROJECT_NAME} "msg/CarlaEgoVehicleControl.msg"
# DEPENDENCIES std_msgs)
colcon build --packages-select carla_msgs && source install/setup.bash
ros2 topic pub -r 20 /carla/hero/vehicle_control_cmd \
carla_msgs/msg/CarlaEgoVehicleControl "{throttle: 0.8}"
Field order is the contract, not the field names: CDR is positional
常见问题
它会关闭自动驾驶吗?
会。手动控制会先为该车关闭自动驾驶。
默认控制哪辆车?
自车,即角色名称为 hero 的车辆。
我可以从 ROS 控制这辆车吗?
可以。该技能会报告 hero 车辆的 ROS 2 命令话题,以便你从 ROS 发送命令。
详情
作者的原始描述
Directly drives a specific vehicle on a running CARLA server — raw VehicleControl (throttle/steer/brake/reverse/hand-brake), Ackermann speed control, vehicle lights, opening/closing doors, and physics-control tuning; ros-info reports the native ROS 2 command topics (vehicle_control_cmd, ackermann_control_cmd) for the hero. Targets the ego by default. Use when the user asks to "drive/steer the car", "accelerate/brake/reverse", "set a target speed", "turn on the headlights/blinkers/brake lights", "open a door", "drive the car from ROS", or "change the vehicle's mass/drag/physics". This is manual
repo: carla-simulator/carla
热度
- GitHub 星标
- 15k
- 排名
- #11089
- 许可证
- 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 评估器,先检查设置,并保存可以恢复的检查点。