본문으로 건너뛰기
cccskills
무료GitHub에 공개

write-leaderboard-agent

Creates a Python agent skeleton for CARLA Leaderboard and checks its sensor configuration offline against the installed version’s rules. Covers version-specific initialization, driving logic, and ROS1 or ROS2 agent integration.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

원문원문 설명 보기

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.

설치 방법 보기

이럴 때 유용합니다

  • Creating an agent with a front camera and lidar
  • Checking sensor limits and configuration errors
  • Porting a Leaderboard 1.0 agent to 2.1
  • Building a ROS1 or ROS2 agent

포함된 파일(5)

  • SKILL.md9.5 KB
  • references/sensors.md6.9 KB
  • scripts/agent_tools.py18.2 KB
  • scripts/check_env.sh7.6 KB
  • scripts/env.sh5.0 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

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):

SensorSENSORS / MAP*_QUALIFIER and LB 1.0
sensor.camera.rgb84
sensor.lidar.ray_cast21
sensor.other.radar42
sensor.other.gnss11
sensor.other.imu11
sensor.speedometer11
sensor.opendrive_map1 (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.VehicleControl every tick. Returning None is a crash.
  • self._global_plan (GPS waypoints + RoadOption) and self._global_plan_world_coord (world transforms) are set before the first run_step. On the MAP track you also get the OpenDRIVE string through sensor.opendrive_map.
  • Camera images are BGRA, not RGB. Slice [:, :, :3] and reverse if you need RGB.
  • The agent runs inside a watchdog. An overrun is Agent crashed / Agent took longer than Xs, not a warning — the route is scored as a failure.
  • destroy() is called between routes; release models and close windows there or the next route starts with the memory still held.

Step 5: Smoke test

cd ../run-leaderboard-evaluation
TEAM_AGENT=~/team_code/my_agent.py bash scripts/run_leaderboard.sh --routes-subset 0

Compare against leaderboard/autoagents/npc_agent.py first: if the NPC agent completes and yours does not, the problem is your agent, not the setup.

Examples

Example 1: "write me a leaderboard agent with a front camera and lidar"

scaffold --name MyAgent --track SENSORS, add the two sensors, validate, then smoke-test on route 0 of routes_devtest.xml.

Example 2: "my agent is rejected: Too many sensor.camera.rgb used"

You are on a qualifier track (4 cameras) or LB 1.0 (4 cameras), not the 8-camera main track. validate --track SENSORS_QUALIFIER shows the budget being applied.

Example 3: "port my 1.0 agent to 2.1"

Change __init__(self, path_to_conf_file) to __init__(self, carla_host, carla_port, debug=False) and move the setup work into setup(path_to_conf_file) — the evaluator calls it with --agent-config. Then re-check the sensor budget: 2.x is more generous, so nothing breaks there, but the qualifier tracks are not the main tracks.

Example 4: "I want to drive with ROS"

Subclass ROS1Agent or ROS2Agent from leaderboard/autoagents/ros_base_agent.py instead of AutonomousAgent, implement sensors() and get_ros_entrypoint(). The harness starts your stack and bridges the sensors as ROS topics. The old RosAgent from ScenarioRunner is deleted — do not follow Docs/ros_agent.md.

Troubleshooting

Problem: AttributeError: module 'my_agent' has no attribute 'MyAgent' Cause: class name must be the file name TitleCased with underscores removed. Solution: rename one of them.

Problem: SensorConfigurationInvalid: Duplicated sensor tag [X] Cause: two sensors share an id. Solution: unique ids; they are also the input_data keys.

Problem: SensorConfigurationInvalid: Illegal sensor extrinsics ... Max allowed radius is 3.0m Cause: the mount is more than 3 m from the ego origin. Solution: bring it in. A roof mount is about x=0.7, z=1.6.

Problem: SensorConfigurationInvalid: You are submitting to the wrong track Cause: self.track in setup() disagrees with --track / CHALLENGE_TRACK_CODENAME. Solution: set self.track = Track.SENSORS (or MAP/…) to match.

Problem: Illegal sensor 'sensor.opendrive_map' used for Track [Track.SENSORS] Cause: map sensor on a sensors-only track. Solution: switch to MAP, or drop the sensor.

Problem: my lidar settings are ignored Cause: attributes are fixed by agent_wrapper._preprocess_sensor_spec. Solution: expected — only camera width/height/fov and the mount transform are yours.

Problem: Agent took longer than Xs to setup / Agent crashed Cause: watchdog. Model loading in run_step instead of setup, or a per-tick overrun. Solution: load in setup; keep run_step bounded; raise --timeout while debugging (but the submitted limit is fixed).

Problem: black or empty images Cause: reading input_data for a sensor id that is not in sensors(), or expecting RGB. Solution: keys come from sensors(); data is BGRA.

Outputs

An agent .py (plus an optional config file) that the evaluator can load, verified against the real sensor validator for your version and track. validate exits non-zero and names the violated rule when the configuration would be rejected.

Sensor semantics, data shapes, pseudo-sensors and the ROS agents are detailed in references/sensors.md.

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Add a message type to CARLA's native ROS 2 interface. Create its C++ data structure, serialization code for transmission, type identity hash, registration, and tests, with Docker-based hash calculation and build checks.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Adding a standard ROS 2 message type missing from CARLA
  • Defining a custom carla_msgs message
  • Investigating type-hash warnings
carla-simulator/carla1.5만2026년 10월 18일 업데이트

Extend CARLA’s native ROS 2 interface to publish sensor data or receive vehicle commands. Covers topic implementation, registration, data connections, and verification, plus adding middleware, the communication layer used to exchange messages.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Publish obstacle sensor data to ROS 2
  • Add a topic for vehicle speed commands
  • Integrate another communication middleware
carla-simulator/carla1.5만2026년 10월 18일 업데이트

Summarize ScenarioRunner results to see which scenarios passed and which checks failed. Compare runs before and after changes, or analyze recorded driving to produce measurements and plots of vehicle distance and deviation from the lane center.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Checking scenario pass and fail results
  • Comparing results before and after controller changes
  • Plotting vehicle distances from a recorded run
carla-simulator/carla1.5만2026년 10월 18일 업데이트

Checks a local CARLA checkout for missing API documentation, outdated references, broken links, and pages absent from navigation. Produces a grouped Markdown report without building the project or running the simulator.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Reviewing documentation before a release
  • Finding missing or outdated API references
  • Checking broken links and navigation gaps
carla-simulator/carla1.5만2026년 10월 18일 업데이트

Read and display CARLA object bounding boxes, then project them onto a camera image as 2D rectangles. Export an annotated PNG and box coordinates in JSON for object detection annotation work.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Adding vehicle boxes to a camera image
  • Exporting box coordinates for detection annotations
  • Checking vehicle dimensions
carla-simulator/carla1.5만2026년 10월 18일 업데이트

Builds CARLA's ue4-dev branch on Linux, producing the Unreal Engine 4.26 editor, server modules, and an installed Python client package. Fetches required content, optionally compiles native ROS 2 support, and verifies the build against a source-built server.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Building CARLA ue4-dev from source
  • Compiling CARLA with native ROS 2 support
  • Building the Python client for an existing environment
carla-simulator/carla1.5만2026년 10월 18일 업데이트

carla-simulator의 스킬 모두 보기

이 스킬의 문제 신고