Skip to content

MasoudJTehrani/PCLA

Repository files navigation

PCLA: Pretrained CARLA Leaderboard Agents

A framework for testing autonomous agents in the CARLA simulator
A versatile framework for deploying and evaluating autonomous driving agents (ADAs) from the CARLA Leaderboard on your own vehicle.

FSE 2025 Paper CARLA Leaderboard Python 3.8+ GitHub stars

Supported Autonomous Agents

PCLA currently supports 27 agents and 24 additional training seeds from 12 major autonomous driving projects:

SimLingo | LMDrive | Transfuser | Transfuser++ | CaRL | Roach | PlanT | Interfuser | NEAT | WoR | LBC | LAV


Why Use PCLA?

PCLA (Pretrained CARLA Leaderboard Agents) is a versatile framework designed to decouple the autonomous driving agents (ADAs) from the restrictive CARLA Leaderboard codebase.

  • Decoupled Deployment: Deploy high-performing ADAs onto a vehicle without relying on the original Leaderboard core codebase.
  • Easy Switching: Effortlessly switch between 27 different agents and their 24 additional training seeds without requiring changes to CARLA versions or programming environments.
  • Version Independent: Fully compatible with the latest version of CARLA, independent of the Leaderboard’s specific CARLA version.
  • Multi-Agent Support: Run multiple vehicles with different autonomous agents simultaneously (note: requires high graphical memory).
  • CARLA Action Access: Retrieve the computed CARLA movement action from the chosen agent for use in any custom application.

The corresponding paper is available at Foundations of Software Engineering (FSE).


Compatibility & Video

PCLA was tested on Linux Ubuntu 22 and CARLA 0.9.16 (Unreal Engine 4).

A video tutorial on how to use PCLA is available below (an updated version is coming soon).

PCLA Video Tutorial


Table of Contents

  1. Setup
  2. Pre-Trained Weights
  3. Autonomous Agents
  4. How to Use
  5. Navigation
  6. Sample Code
  7. FAQ
  8. Citation

1. Setup

Prerequisites

  1. Download and install the CARLA simulator from the official website (quick installation or build from source).
  2. Ensure CUDA and PyTorch are installed on your system.

Installation Steps

  1. Clone the repository and build the Conda environment:

    git clone https://github.com/MasoudJTehrani/PCLA
    cd PCLA
    conda env create -f environment.yml
    conda activate PCLA
  2. Install torch-scatter:

    Note: Please make sure to install torch-scatter according to your specific CUDA version. You can check your CUDA version using the included python cuda.py script.

  3. Additional setup for LMDrive agent:

    conda activate PCLA
    
    # 1. Vision Encoder
    cd pcla_agents/lmdrive/vision_encoder
    pip uninstall timm
    python setup.py develop
    
    # 2. LAVIS
    cd ../LAVIS
    python setup.py develop
    
    # 3. Fix ftfy dependency
    pip uninstall ftfy -y
    pip install "ftfy==6.1.1"
    cd ../../../
  4. CARLA 0.9.16 Specific Installation: If you intend to use PCLA with CARLA 0.9.16, you need to install the wheel from the dist folder:

    cd dist
    python3 -m pip install carla-0.9.16-cp38-cp38-linux_x86_64.whl

    Warning: Some agents may act weird when used with CARLA 0.9.16.


2. Pre-Trained Weights

You have two options to download the required pre-trained model weights:

Option 1: Automatic Download

Run the following script to automatically download and unzip the weights into the correct location:

python pcla_functions/download_weights.py

Option 2: Manual Download

  1. Manually download the pretrained.zip file from Hugging Face.

  2. Extract the contents into the PCLA/pcla_agents/ directory.

Directory Structure

Ensure that the downloaded pre-trained weight folders are placed directly next to their respective model's folder. The final pcla_agents directory should look like this:

├── pcla_agents/
│   ├── transfuserpp/
│   ├── transfuserpp_pretrained/
│   ├── interfuser/
│   ├── interfuser_pretrained/
│   ├── ...

3. Autonomous Agents

PCLA includes 27 different autonomous agents and 24 additional training seeds to choose from.

Find the repository of each agent at the top this page.

SimLingo (CarLLava)

  • simlingo_simlingo: The best-performing agent, which secured first place at CARLA Leaderboard 2 SENSORS track (previously named CarLLava).

LMDrive

  • lmdrive_llava: Best performing LMDrive agent.

  • lmdrive_vicuna: Second best performing LMDrive agent.

  • lmdrive_llama: Third best performing LMDrive agent.

Transfuser

  • tf_tf: The main Transfuser agent.

  • tf_ltf: The LatentTF agent.

  • tf_lf: The Late_Fusion agent.

  • tf_gf: The Geometric_Fusion agent.

Transfuser++

  • Seeds: Replace # with the seed number from 0 to 2 (e.g., tfpp_l6_0).

  • tfpp_l6_#: Best performing Transfuser++ agent. Second place at CARLA Leaderboard 2 SENSORS track.

  • tfpp_lav_#: Transfuser++ not trained on Town02 and Town05.

  • tfpp_wp_#: Transfuser++ WP from their paper's appendix.

  • tfpp_aim_#: Reproduction of the AIM method.

CaRL

  • carl_carl_#: CaRL agent with a driving score of 64. Replace # with 0 or 1.

  • carl_carlv11: The best CaRL agent with a driving score of 73. Best open-source RL planner on longest6 v2 and nuPlan.

Roach

  • carl_roach_#: The Roach planner agent (paper) reproduced by the authors of CaRL. Replace # with a number from 0 to 4 for the 5 available seeds.

PlanT

  • carl_plant_#: The PlanT planner agent (paper) reproduced by the authors of CaRL. Replace # with a number from 0 to 4 for the 5 available seeds.

NEAT

  • neat_neat

  • neat_aimbev

  • neat_aim2dsem

  • neat_aim2ddepth

Interfuser

Learning from All Vehicles (LAV)

  • lav_lav: The original LAV agent.

  • lav_fast: Leaderboard submission optimized for inference speed with temporal LiDAR scans.

Learning By Cheating (LBC)

  • lbc_nc: Learning By Cheating, the NoCrash model.

  • lbc_lb: Learning By Cheating, the Leaderboard model.

World on Rails (WoR)

  • wor_nc: World on Rails, the NoCrash model.

  • wor_lb: World on Rails, the Leaderboard model.


4. How to Use

Step 1: Run CARLA

Start the CARLA simulator. You only need the -vulkan flag for LBC, WoR, and LAV agents.

./CarlaUE4.sh -vulkan

Step 2: Integrate PCLA in Your Script

Open a new terminal and run your custom Python code. To use PCLA, import the library, define your agent and route, and initialize the PCLA class.

Core Usage Snippet:

from PCLA import PCLA

# 1. Define Agent and Route
agent = "tf_tf" # e.g., Transfuser
route = "./sample_route.xml"

# 2. Initialize PCLA (requires a CARLA client and a vehicle object)
pcla = PCLA(agent, vehicle, route, client)

# 3. Get action and apply control (within your simulation loop)
ego_action = pcla.get_action()
vehicle.apply_control(ego_action)

# 4. Cleanup when done
pcla.cleanup()

Explaining the Arguments:

  • agent: Your chosen autonomous agent string (e.g., "tf_tf"). See Autonomous Agents.

  • route: The path to an XML file defining the vehicle's route, formatted according to the Leaderboard waypoints.

  • client & vehicle: The standard CARLA client and the ego-vehicle actor you wish to control.


5. Navigation

PCLA provides utility functions to help you generate waypoints and routes usable by the agents.

5.1 Finding Spawn Points

To see all available spawn points and their associated index numbers in your current map:

Shell

python pcla_functions/spawn_points.py

5.2 Generating Waypoints

Use the location_to_waypoint() method to generate a sequence of CARLA waypoints between two CARLA locations.

from PCLA import location_to_waypoint
import carla

world = client.get_world()
vehicle_spawn_points = world.get_map().get_spawn_points() # Get CARLA spawn points
startLoc = vehicle_spawn_points[31].location              # Define Start location
endLoc = vehicle_spawn_points[42].location                # Define End location

# Returns a list of CARLA waypoints between the two locations
waypoints = location_to_waypoint(client, startLoc, endLoc) 

5.3 Creating the PCLA Route XML

Pass the generated CARLA waypoints to route_maker() to format them into a Leaderboard-compliant XML file that PCLA can read.

from PCLA import route_maker

route_maker(waypoints, "route.xml")

Full Navigation Example

This combined example demonstrates generating an XML route from two CARLA locations:

from PCLA import route_maker, location_to_waypoint
import carla

client = carla.Client('localhost', 2000)
world = client.get_world()

vehicle_spawn_points = world.get_map().get_spawn_points()
startLoc = vehicle_spawn_points[31].location
endLoc = vehicle_spawn_points[42].location

# 1. Generate waypoints
waypoints = location_to_waypoint(client, startLoc, endLoc)

# 2. Create the PCLA XML route file
route_maker(waypoints, "route.xml")

6. Sample Code

A comprehensive sample script is provided to help you test PCLA immediately.

To run the sample (which uses the LAV agent in Town02):

python sample.py

Attention: You may need to change the vehicle spawn point's index number on line 45 of sample.py based on your specific CARLA version.


7. FAQ

Frequently asked questions and possible issues are addressed and solved in the PCLA issues section.

If you have a request for a new agent to be integrated into the framework, please feel free to open a new issue and ask!


8. Citation

If you find PCLA useful in your research or project, please consider giving it a star ⭐ and citing our published work.

@inproceedings{tehrani2025pcla,
  title={PCLA: A Framework for Testing Autonomous Agents in the CARLA Simulator},
  author={Tehrani, Masoud Jamshidiyan and Kim, Jinhan and Tonella, Paolo},
  booktitle={Proceedings of the 33rd ACM International Conference on the Foundations of Software Engineering},
  pages={1040--1044},
  year={2025}
}

Releases

No releases published

Sponsor this project

  •  

Packages

No packages published