Implementation:CARLA simulator Carla Client Set Replayer Time Factor
| Knowledge Sources | |
|---|---|
| Domains | Simulation, Recording |
| Last Updated | 2026-02-15 00:00 GMT |
Overview
Concrete tool for adjusting the playback speed of a recording replay session provided by the CARLA simulator.
Description
The Client.set_replayer_time_factor method sets the temporal scaling factor for an active recording replay. The time factor controls how fast or slow the replay proceeds relative to the original recording's timing. A factor of 1.0 is real-time, 0.5 is half-speed (slow motion), 2.0 is double speed, and 0.0 pauses the replay.
This method can be called at any time during an active replay to dynamically adjust the playback speed. It takes effect immediately on the next simulation tick. The method can also be called before starting a replay to pre-set the desired playback speed.
Important: When the time factor exceeds 2.0, actor position interpolation between recorded frames is disabled. This means actors may appear to jump between positions at high playback speeds. For smooth visual playback, keep the time factor at or below 2.0.
Usage
Call this method during an active replay to control playback speed. Common use cases include slowing down before a collision event for detailed inspection, fast-forwarding through uneventful portions of a long recording, and pausing to examine actor positions at a specific moment. It is typically used in conjunction with replay_file as part of an interactive analysis workflow.
Code Reference
Source Location
- Repository: CARLA
- File:
PythonAPI/carla/src/Client.cpp:L211,LibCarla/source/carla/client/Client.h:L150-152
Signature
Client.set_replayer_time_factor(time_factor: float) -> None
Import
import carla
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| time_factor | float | Yes | The temporal scaling factor for replay playback. 1.0 = real-time, < 1.0 = slow motion, > 1.0 = fast forward, 0.0 = pause. Note: interpolation is disabled above 2.0. |
Outputs
| Name | Type | Description |
|---|---|---|
| return | None | No return value. The time factor takes effect on the next simulation tick. |
Usage Examples
Basic Example
import carla
import time
client = carla.Client('localhost', 2000)
client.set_timeout(10.0)
# Start replay at normal speed
client.replay_file("traffic_scenario_01.log", 0.0, 0.0, 0)
# Watch at normal speed for 10 seconds
time.sleep(10)
# Slow down to half speed for detailed observation
client.set_replayer_time_factor(0.5)
print("Playback slowed to 0.5x")
time.sleep(20) # 10 sim-seconds at 0.5x takes 20 real-seconds
# Speed up to fast-forward through the rest
client.set_replayer_time_factor(5.0)
print("Playback accelerated to 5.0x (interpolation disabled)")
time.sleep(10)
Interactive Analysis Workflow
import carla
import time
client = carla.Client('localhost', 2000)
client.set_timeout(10.0)
filename = "intersection_scenario.log"
# Step 1: Fast-forward through the beginning to reach the area of interest
client.replay_file(filename, 0.0, 0.0, 42)
client.set_replayer_time_factor(4.0)
print("Fast-forwarding at 4x...")
time.sleep(5) # Covers ~20 sim-seconds
# Step 2: Slow down for the critical section
client.set_replayer_time_factor(0.25)
print("Slow motion at 0.25x for detailed analysis...")
time.sleep(40) # Covers ~10 sim-seconds at quarter speed
# Step 3: Pause to inspect a specific moment
client.set_replayer_time_factor(0.0)
print("Replay paused. Inspect the scene in the viewport.")
time.sleep(10) # Time for inspection
# Step 4: Resume at normal speed
client.set_replayer_time_factor(1.0)
print("Resumed at normal speed")
time.sleep(30)
Automated Slow-Motion Capture Around Collisions
import carla
import time
client = carla.Client('localhost', 2000)
client.set_timeout(10.0)
filename = "urban_driving.log"
# Find collision times from the recording
collisions_info = client.show_recorder_collisions(filename, "v", "v")
print(collisions_info)
# For each collision event, replay in slow motion around that time
# Suppose we parse collision at t=32.5s involving actor 55
collision_time = 32.5
actor_id = 55
window = 5.0 # seconds before and after collision
# Start replay 5 seconds before the collision
client.replay_file(
filename,
start_time=collision_time - window,
duration=window * 2,
follow_id=actor_id
)
# Play at one-tenth speed for detailed crash analysis
client.set_replayer_time_factor(0.1)
print(f"Replaying collision at 0.1x speed, following actor {actor_id}")
# Wait for the slow-motion replay to complete
# 10 sim-seconds at 0.1x = 100 real-seconds
time.sleep(100)
print("Slow-motion replay complete")