Skip to content
Skillpedia
Agents15k · #11083

write-leaderboard-agent

What it does

The skill creates a starting driving agent for the CARLA Leaderboard and checks its sensors. It is for developers writing their own autonomous driving agent for the simulator.

When to use it

  • ✓When you want to write a new driving agent for the CARLA Leaderboard.
  • ✓When you need to choose a sensor setup that fits the limits of a track.
  • ✓When your agent fails to load and the class name may be wrong.

Skill link

https://github.com/carla-simulator/carla/blob/ue58-dev/Skills/leaderboard/write-leaderboard-agent/SKILL.md

Copy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.

How to use

The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.

Ready-to-paste message

Use this skill to help me: https://github.com/carla-simulator/carla/blob/ue58-dev/Skills/leaderboard/write-leaderboard-agent/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
Want your AI to find skills like this on its own?Install the free Skillpedia MCP: one line, and it searches 15,000+ skills before each task.Install in 1 minute →

Example of what to ask your AI

“Write a camera and lidar driving agent for the Leaderboard sensor track, with a working starting file.”

5 new skills a week. 1 minute to read.

How it works

The agent generates a skeleton class with setup, sensor, and step functions, uses the constructor that fits your leaderboard version, and checks the sensor setup against the track limits before any test run.

Technical content (original SKILL.md)

Original text by the author, straight from GitHub.

Write a Leaderboard agent

Paths. scripts/… and references/… 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 id must be unique — duplicates are rejected outright.
  • Mount radius ≤ 3.0 m from the ego origin: sqrt(x²+y²+z²) > 3.0 is rejected.
  • sensor.opendrive_map on 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
FAQ

Why does my agent not load?

The file name must match the class name, so my_agent.py needs a class named MyAgent.

Do the leaderboard versions use the same constructor?

No. Versions 1.0 and 2.x differ, so the skill generates the one that fits your version.

Does it cover ROS?

Yes. It covers the agent base classes for ROS 1 and ROS 2.

Details

Original description by the author

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

Popularity

GitHub stars
15k
Ranking position
#11083
License
MIT
Updated
11/2/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills