Principle:CARLA simulator Carla Simulation Recording
| Knowledge Sources | |
|---|---|
| Domains | Simulation, Recording |
| Last Updated | 2026-02-15 00:00 GMT |
Overview
Simulation state capture serializes the complete per-frame state of a CARLA world into a compact binary log file for later replay and analysis.
Description
Simulation recording in CARLA captures a deterministic snapshot of the entire simulation state at every tick. The recorder serializes actor transforms (position, rotation, velocity), actor spawn and destroy events, traffic light state transitions, vehicle control signals, and walker bone transforms into a binary format. This binary log serves as a complete record of everything that happened during a simulation session, enabling exact replay, post-hoc analysis, and scenario debugging.
The recording system operates at the server level, meaning it captures the authoritative state of all actors managed by the CARLA server. This includes vehicles, walkers, traffic lights, and any other actors present in the world. When additional_data is enabled, the recorder also captures supplementary information such as vehicle light states, bounding box geometry, and actor kinematic data, which increases file size but provides richer metadata for analysis tools.
The binary format is designed for efficient sequential writes during simulation and sequential reads during replay, avoiding random-access overhead. Each frame's data is prefixed with a timestamp, enabling time-based seeking during replay operations.
Usage
Use simulation recording when you need to:
- Capture test scenarios for regression testing of autonomous driving algorithms.
- Debug failures by recording a scenario that produced an unexpected result and replaying it for detailed inspection.
- Generate training data by recording diverse traffic scenarios and then replaying them with different sensor configurations.
- Document simulation results for compliance or audit purposes.
- Share scenarios across team members without requiring them to reproduce the exact conditions.
Theoretical Basis
The recording mechanism is grounded in the concept of state serialization for deterministic replay. In a discrete-time simulation, the world state at each tick can be fully described by a finite set of variables: actor poses, traffic signal phases, weather parameters, and control inputs. By capturing this minimal sufficient state at every simulation tick, the recorder creates a log from which the entire simulation can be reconstructed.
This approach leverages the deterministic nature of the CARLA physics engine: given the same initial conditions and the same sequence of inputs, the simulation will produce the same outputs. The recorder captures the inputs and resulting states, enabling both forward replay and post-hoc querying.
The binary log format prioritizes write throughput over random access, using a sequential append model that minimizes the performance impact on the running simulation. Frame data is organized as typed records (spawn, destroy, transform update, state change) with length-prefixed encoding to support efficient parsing during replay.
The recording granularity is one frame per simulation tick, which means the temporal resolution matches the simulation step size (typically 0.05 seconds in synchronous mode). This guarantees that no simulation events are lost between recorded frames.