CARLA is an open source autonomous driving research simulator developed on Unreal Engine. It provides a flexible platform for researchers to develop, train, and validate autonomous driving systems.CARLA supports a wide range of sensor simulations such as cameras, LIDAR, and radar, and provides rich digital assets such as city maps, vehicles, and pedestrians. Users can control the simulation environment and adjust conditions such as weather, traffic, and scenarios via Python API or C++. CARLA is designed to support testing of complex traffic scenarios and multi-intelligence body interaction research, and is widely used in academia and industry. Its open source nature allows users to use and contribute code for free, making it suitable for autonomous driving algorithm development and testing.
Function List
- Sensor simulation: Supports a wide range of sensors such as RGB cameras, LIDAR, radar, depth sensors, and GPS to generate photorealistic sensory data.
- Traffic Scene Generation: Provides a variety of maps for cities, suburbs and highways, and supports dynamic traffic flow and pedestrian behavior simulation.
- Flexible API: Control the simulation environment, including vehicles, pedestrians, weather and traffic rules, via Python and C++ APIs.
- Map Editor: Supports the creation of custom maps based on the ASAM OpenDRIVE standard, which can be generated by tools such as RoadRunner.
- Scene Recording and Playback: Allows to record the simulation process and play it back accurately, making it easy to compare the results of different configurations.
- Multi-Client Architecture: Support multiple clients to control different intelligences at the same time, suitable for multi-intelligence research.
- ROS Integration: Seamlessly connects to the robot operating system through the ROS bridge and supports frameworks such as AutoWare.
- traffic management: Built-in Traffic Manager controls the behavior of NPCs (non-player characters) to simulate real traffic challenges.
- physical simulation: Integrated Chrono library for highly accurate vehicle dynamics and multibody dynamics simulations.
Using Help
Installation process
To use CARLA locally, users need to install and configure the environment. Below are the installation steps for Ubuntu systems, Windows users can refer to the official documentation.
- Checking system requirements
CARLA supports Unreal Engine version 4.26 or 5.5. Recommended hardware configuration is Intel i7/i9 (9th-11th generation) or AMD Ryzen 7/9, with a graphics card supporting DirectX 11 or above, at least 16GB of RAM and 50GB of disk space. - Download CARLA
Users can choose to download pre-compiled packages from GitHub or source-compiled:- precompiled package: Visit the official CARLA website (http://carla.org) or the GitHub release page (https://github.com/carla-simulator/carla/releases) to download the latest version (e.g. 0.9.15). Unzip it and use it.
- source code compilation: Clone a GitHub repository:
git clone -b ue5-dev https://github.com/carla-simulator/carla.git CarlaUE5
A GitHub account needs to be associated with Epic Games to access the Unreal Engine 5.5 repositories.
- Installation of dependencies
Go to the CARLA root directory and run the installation script:cd CarlaUE5 sudo -E env GIT_LOCAL_CREDENTIALS=github_username@github_token ./CarlaSetup.sh
The script automatically downloads Unreal Engine 5.5 and dependencies, and may require GitHub credentials to be entered. Windows users will need to run a similar command using the x64 Native Tools command prompt in Visual Studio 2022.
- Compiled by CARLA
Run in the CARLA root directory:cmake -G Ninja -S . -B Build --toolchain=$PWD/CMake/Toolchain.cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_ROS2=ON
After compiling, run
./CarlaUE4.sh
Start the simulator. - Installing the Python Client Library
CARLA provides a Python API and requires the installation of a client library:pip3 install carla
It is recommended to install it in a virtual environment to avoid version conflicts. Python 2.7, 3.6, 3.7, and 3.8 are supported.
Using the main functions
- Start the simulator
(of a computer) run./CarlaUE4.sh -quality-level=epic
(high quality) or-quality-level=low
(Low-end hardware). The simulator starts up showing the city view and waiting for the client to connect. - Run the sample script
CARLA provides several Python example scripts located in thePythonAPI/examples
Catalog. Example:- Generating Traffic: Run
python3 generate_traffic.py
, generating dynamic vehicles and pedestrians in the simulator. - manual control: Run
python3 manual_control.py
The vehicle is controlled by keyboard and mouse, WASD keys to move and mouse to adjust the view. - Sensor Data Acquisition: Run
python3 03_RGB_camera.py
If you want to save the image data from the RGB camera, you can use the RGB camera to acquire the image data and save it.
- Generating Traffic: Run
- Operating Traffic Manager
Traffic Manager controls NPC behavior. Example:tm = client.get_trafficmanager() tm.set_desired_speed(vehicle, 30.0) # 设置车辆速度为 30 km/h tm.set_percentage_random_left_lanechange(vehicle, 20.0) # 20% 概率随机左换道
NPC's speed, lane changing behavior, etc. can be set via API.
- Customized Maps
Users can create maps with RoadRunner or OpenDRIVE. Import maps to CARLA:python3 import_map.py --path /path/to/your_map.xodr
Then load the new map in the emulator.
- Record and Playback
Start recording:client.start_recorder("recording01.log")
Playback recording:
client.replay_file("recording01.log", start_time=0.0, duration=60.0)
- ROS Integration
Install the ROS bridge (https://github.com/carla-simulator/ros-bridge):git clone https://github.com/carla-simulator/ros-bridge.git
After starting a ROS node, CARLA can interact with frameworks such as AutoWare.
Featured Function Operation
- Sensor Configuration: Add sensors to the vehicle via the Python API. For example, add an RGB camera:
blueprint_library = world.get_blueprint_library() camera_bp = blueprint_library.find('sensor.camera.rgb') camera = world.spawn_actor(camera_bp, carla.Transform(carla.Location(x=1.5, z=1.4))) camera.listen(lambda image: image.save_to_disk('output/%06d.png' % image.frame))
- Multi-intelligence body simulation: With the multi-client architecture, multiple Python scripts can control different vehicles at the same time. Each client connects to an emulator port (default 2000-2002).
- Chrono Physics Simulation: Enabling the Chrono library makes the vehicle dynamics more realistic and suitable for studying vehicle control and dynamic response. Refer to the official documentation (https://carla.readthedocs.io/en/latest/adv_chrono/) for the configuration method.
application scenario
- Autonomous Driving Algorithm Development
Researchers use CARLA to test perception, planning, and control algorithms. For example, deep learning models were trained for target detection and path planning by simulating LiDAR and camera data. - Traffic Scenario Testing
Developers can create complex traffic scenarios in CARLA, such as intersection crash tests or driving in inclement weather, to validate the robustness of autonomous driving systems. - Education and training
Universities and training organizations use CARLA to teach the principles of autonomous driving. Students implement simple control algorithms via Python APIs and learn about sensor data processing and vehicle control. - Multi-intelligence research
CARLA's multi-client architecture is suitable for studying multi-vehicle cooperative driving, simulating fleet communication or competitive driving scenarios.
QA
- What operating systems does CARLA support?
CARLA officially supports Ubuntu 18.04 and 20.04, Windows 7 and above. macOS is not officially supported, but the community has some unofficial solutions. - How to resolve dependencies during compilation?
Make sure all dependencies (e.g. CMake, Ninja) are installed. RunCarlaSetup.sh
The script will automatically install the missing dependencies. If it fails, check the official FAQ (https://carla.readthedocs.io/en/latest/faq/). - Is it possible to run CARLA offline?
Yes, CARLA supports offline running. After downloading the pre-compiled package or compiling the source code, you can run the emulator and scripts without an internet connection. - How do I get more maps?
Download additional map packages (e.g., Town06, Town07) or use RoadRunner to create custom maps to import OpenDRIVE files into CARLA.