Implementation:CARLA simulator Carla Recorder Comparer Tool
| Knowledge Sources | |
|---|---|
| Domains | Simulation, Testing, Utility |
| Last Updated | 2026-02-15 05:00 GMT |
Overview
Command-line utility script that compares two CARLA recorder output files line by line to detect determinism differences between simulation runs.
Description
This script (recorder_comparer.py) performs line-by-line comparison of two recorder text files (output from show_recorder_file_info) to verify simulation determinism. The comparison intelligently handles non-deterministic elements: it ignores actor IDs (which vary between runs), parenting information, collision events, destroy operations, real-time timestamps, and spectator-related entries. For each line, it extracts frame numbers and timestamps for context in difference reports. When differences are found, the script outputs the line number, frame info, and the differing content from both files with ANSI bold formatting. The comparison skips the first 3 header lines and validates that files contain at least 10 lines. It reports whether the files are identical or prints each difference interactively (via input() for user-paced review).
Usage
Use this tool to verify that two CARLA simulation recordings produce identical results, which is essential for testing determinism in replay scenarios and validating that code changes do not introduce non-deterministic behavior.
Code Reference
Source Location
- Repository: CARLA
- File: PythonAPI/util/recorder_comparer.py
Signature
def main():
"""Compare two recorder text files line by line.
Skips non-deterministic elements (IDs, collisions, spectator).
Reports differences with frame/time context.
"""
Import
# Run as a command-line tool:
python recorder_comparer.py -f1 recording1.txt -f2 recording2.txt
I/O Contract
| Argument | Type | Default | Description |
|---|---|---|---|
| --host | str | 127.0.0.1 | CARLA server IP address |
| -p, --port | int | 2000 | CARLA server TCP port |
| -f1, --file1 | str | None | First recorder output text file |
| -f2, --file2 | str | None | Second recorder output text file |
| Output | Description |
|---|---|
| "Both recordings are identical" | Files match (ignoring non-deterministic fields) |
| Difference report | Line number, frame, time, and differing content |
Usage Examples
# First, generate recorder info files
python show_recorder_file_info.py -f recording_run1.rec -s run1_info.txt
python show_recorder_file_info.py -f recording_run2.rec -s run2_info.txt
# Compare the two recordings
python recorder_comparer.py -f1 run1_info.txt -f2 run2_info.txt