Implementation:CARLA simulator Carla Client Start Recorder
| Knowledge Sources | |
|---|---|
| Domains | Simulation, Recording |
| Last Updated | 2026-02-15 00:00 GMT |
Overview
Concrete tool for initiating simulation recording to a binary log file provided by the CARLA simulator.
Description
The Client.start_recorder method instructs the CARLA server to begin capturing all simulation state changes into a binary recording file. Once called, every subsequent simulation tick is logged until stop_recorder is invoked. The method accepts a filename for the output recording and an optional flag to capture additional data such as vehicle light states and bounding box information.
The filename can be an absolute path or a relative filename. When a relative filename is provided, the recording file is saved in the default CARLA recording directory on the server (typically CarlaUE4/Saved/ on the server machine). The method returns a string confirming the recording has started and the path where the file will be written.
If additional_data is set to True, the recorder captures extra per-frame information including vehicle light states, bounding boxes, and kinematics. This increases the file size but provides richer data for post-recording analysis and is required for certain inspection queries.
Usage
Call this method before running any simulation scenario that you want to capture. It should be invoked after connecting to the CARLA server and loading the desired map, but before spawning actors or beginning the simulation loop. The recorder will capture all subsequent events including actor spawns, so starting it early ensures complete coverage.
Code Reference
Source Location
- Repository: CARLA
- File:
PythonAPI/carla/src/Client.cpp:L204,LibCarla/source/carla/client/Client.h:L121-123
Signature
Client.start_recorder(filename: str, additional_data: bool = False) -> str
Import
import carla
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| filename | str | Yes | Path or name of the binary recording file to create. If relative, saved to the server's default recording directory. |
| additional_data | bool | No | When True, records additional per-frame data including vehicle light states, bounding boxes, and kinematics. Defaults to False. |
Outputs
| Name | Type | Description |
|---|---|---|
| return | str | Confirmation string indicating recording has started and the resolved file path on the server. |
Usage Examples
Basic Example
import carla
# Connect to CARLA server
client = carla.Client('localhost', 2000)
client.set_timeout(10.0)
# Load desired map
world = client.load_world('Town03')
# Start recording with a simple filename
result = client.start_recorder("recording_town03_session01.log")
print(result) # Prints confirmation and file path
# ... run simulation scenario ...
# Stop recording when done
client.stop_recorder()
Advanced Example with Additional Data
import carla
import datetime
client = carla.Client('localhost', 2000)
client.set_timeout(10.0)
world = client.load_world('Town05')
# Generate a timestamped filename for organized recording storage
timestamp = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
filename = f"/home/carla/recordings/Town05_{timestamp}.log"
# Start recording with additional data enabled for richer analysis
result = client.start_recorder(filename, additional_data=True)
print(f"Recording started: {result}")
# Configure synchronous mode for deterministic recording
settings = world.get_settings()
settings.synchronous_mode = True
settings.fixed_delta_seconds = 0.05
world.apply_settings(settings)
# Spawn vehicles and run scenario
blueprint_library = world.get_blueprint_library()
spawn_points = world.get_map().get_spawn_points()
vehicles = []
for i in range(20):
bp = blueprint_library.filter('vehicle.*')[i % len(blueprint_library.filter('vehicle.*'))]
vehicle = world.try_spawn_actor(bp, spawn_points[i])
if vehicle is not None:
vehicle.set_autopilot(True)
vehicles.append(vehicle)
# Run simulation for 500 ticks
for _ in range(500):
world.tick()
# Cleanup
client.stop_recorder()
for v in vehicles:
v.destroy()