write-leaderboard-agent
它能做什么
该技能为 CARLA Leaderboard 创建一个驾驶智能体起始文件,并检查其传感器。适合为模拟器编写自己的自动驾驶智能体的开发者。
适用场景
- ✓当你想为 CARLA Leaderboard 编写新的驾驶智能体的时候。
- ✓当你需要选择符合赛道限制的传感器配置的时候。
- ✓当你的智能体无法加载,并且类名可能有误的时候。
技能链接
https://github.com/carla-simulator/carla/blob/ue58-dev/Skills/leaderboard/write-leaderboard-agent/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请为 Leaderboard 传感器赛道编写一个摄像头和激光雷达驾驶智能体,并提供一个可运行的起始文件。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会生成一个包含设置、传感器和步进函数的骨架类,使用适合你的 leaderboard 版本的构造函数,并在任何测试运行之前检查传感器配置是否符合赛道限制。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Write a Leaderboard agent
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.
An agent is one Python file with one class. The Leaderboard imports it by path and instantiates it by a name derived from the file name:
module_name = os.path.basename(args.agent).split('.')[0] # my_agent.py -> my_agent
# ... the evaluator then looks for the TitleCase, underscore-stripped class
so my_agent.py must contain class MyAgent. That is the first thing that goes
wrong, and the error is a bare AttributeError.
Instructions
Progress:
- [ ] Step 1: Check prerequisites (bash scripts/check_env.sh) — confirms the LB version
- [ ] Step 2: Generate the skeleton for your track and version
- [ ] Step 3: Declare sensors inside the budget; validate offline
- [ ] Step 4: Implement run_step
- [ ] Step 5: Smoke-test on routes_devtest.xml
Step 2: Skeleton
source scripts/env.sh
python3 scripts/agent_tools.py scaffold --name MyAgent --track SENSORS --out ~/team_code
python3 scripts/agent_tools.py scaffold --name MyMapAgent --track MAP --out ~/team_code
The scaffold reads the detected leaderboard version and emits the correct constructor for it — this is the one hard API break between 1.0 and 2.x:
# 1.0 — the base class calls setup() from __init__
def __init__(self, path_to_conf_file): ...
# 2.0 / 2.1 — the evaluator constructs, then calls setup() itself
def __init__(self, carla_host, carla_port, debug=False): ...
A 1.0 agent run under a 2.x evaluator receives a host string where it expects a
config path. If you override __init__ at all, match the version; if you do not
override it, both work.
Step 3: Sensors
def sensors(self):
return [
{'type': 'sensor.camera.rgb', 'id': 'Center',
'x': 0.7, 'y': 0.0, 'z': 1.60, 'roll': 0.0, 'pitch': 0.0, 'yaw': 0.0,
'width': 800, 'height': 600, 'fov': 100},
{'type': 'sensor.lidar.ray_cast', 'id': 'LIDAR',
'x': 0.7, 'y': 0.0, 'z': 1.60, 'roll': 0.0, 'pitch': 0.0, 'yaw': 0.0},
{'type': 'sensor.other.imu', 'id': 'IMU', 'x': 0.7, 'y': 0.0, 'z': 1.60,
'roll': 0.0, 'pitch': 0.0, 'yaw': 0.0},
{'type': 'sensor.other.gnss', 'id': 'GPS', 'x': 0.7, 'y': -0.4, 'z': 1.60},
{'type': 'sensor.speedometer', 'id': 'Speed'},
]
python3 scripts/agent_tools.py validate --agent ~/team_code/my_agent.py --track SENSORS
validate runs the actual validate_sensor_configuration() from your
checkout, so it enforces the real budget for your version and track rather than a
copy of it. Budgets (2.0/2.1; qualifier tracks halve them, and match 1.0's):
| Sensor | SENSORS / MAP | *_QUALIFIER and LB 1.0 |
|---|---|---|
sensor.camera.rgb |
8 | 4 |
sensor.lidar.ray_cast |
2 | 1 |
sensor.other.radar |
4 | 2 |
sensor.other.gnss |
1 | 1 |
sensor.other.imu |
1 | 1 |
sensor.speedometer |
1 | 1 |
sensor.opendrive_map |
1 (MAP tracks only) | 1 |
Three constraints beyond the counts:
- Every
idmust be unique — duplicates are rejected outright. - Mount radius ≤ 3.0 m from the ego origin:
sqrt(x²+y²+z²) > 3.0is rejected. sensor.opendrive_mapon a SENSORS track is rejected, which is the entire difference between the SENSORS and MAP tracks.
You do not control sensor attributes except camera resolution/fov and the mount.
agent_wrapper.py hard-codes the rest: lidar is always 64 channels, 85 m range,
10 Hz, 600k points/s with fixed dropoff; radar 1500 points, 100 m; GNSS and IMU
noise are fixed. Setting range or channels in your sensor dict is silently
ignored. That is deliberate — it is what makes submissions comparable.
Step 4: run_step
def run_step(self, input_data, timestamp):
# input_data is {id: (frame, data)} for every sensor in sensors()
frame, img = input_data['Center'] # numpy BGRA, (height, width, 4)
_, gnss = input_data['GPS'] # [lat, lon, alt]
_, imu = input_data['IMU'] # [ax, ay, az, gx, gy, gz, compass]
_, speed = input_data['Speed'] # {'speed': m/s}
control = carla.VehicleControl()
control.steer, control.throttle, control.brake = 0.0, 0.5, 0.0
return control
- Return a `carla.VehicleContro
常见问题
为什么我的智能体无法加载?
文件名必须与类名对应,例如 my_agent.py 需要一个名为 MyAgent 的类。
不同 leaderboard 版本的构造函数相同吗?
不同。1.0 版本和 2.x 版本有所区别,因此该技能会生成与你的版本相符的那一个。
它涵盖 ROS 吗?
涵盖。它涵盖 ROS 1 和 ROS 2 的智能体基类。
详情
作者的原始描述
Writes an autonomous agent for the CARLA Leaderboard — an AutonomousAgent subclass with setup/sensors/run_step/destroy, a sensor suite inside the track's budget, and the right constructor signature for the leaderboard version (1.0 and 2.x differ). Generates a working skeleton, validates the sensor configuration against the real per-track limits offline, and covers the ROS1/ROS2 agent base classes. Use when the user asks to "write a leaderboard agent", "make my agent work with the leaderboard", "add sensors to my agent", "port my agent to 2.1", or hits SensorConfigurationInvalid.
repo: carla-simulator/carla
热度
- GitHub 星标
- 15k
- 排名
- #11083
- 许可证
- 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 评估器,先检查设置,并保存可以恢复的检查点。