Time Stepping and Determinism#
This page gives the clocks of the simulators, the time at which a command applies, and the conditions for repeatable runs.
Sources: Game/Config/DefaultEngine.ini, Game/Source/Acres/AcresCommandTiming.h, AcresSimControl.h, Game/Core/Source/AcresCoreBatch.h.
Clocks#
| Item | Value |
|---|---|
| Physics step of the game | 1/120 s (AsyncFixedTimeStepSize=0.008333333333333333, bTickPhysicsAsync=True) |
| Physics time of one frame, at most | 0.1 s, 12 steps (MaxPhysicsDeltaTime=0.1) |
| Control step of the bridges, the run-time library and ACRES Core | 0.1 s (12 physics steps) |
| Clock frame of the sensor stream | Each physics step |
The game renders frames at its own rate. The physics thread runs the steps that the frame time asks for, at most 12. A frame that is longer than 0.1 s thus makes the simulation slower than real time.
When a Command Applies#
The game reads the sockets one time in each rendered frame. A long frame has more than one physics step. When all messages of the frame apply at its first step, the other steps get no message. A controller at 50 Hz then looks silent, and the drive-by-wire timeout of 0.1 s trips.
Thus a receiver thread stamps each message with its arrival time on the wall clock. At each read, the game maps the wall-clock interval since the last read onto the simulation interval that the frame advances. The first physics step at or after the mapped time takes the message. The steps of a long frame thus see the commands in the sequence and at the spacing of their arrival.
In lockstep, each command applies at the next step, as the step request expects.
Lockstep#
-Lockstep (or -SimControl=PORT and the state 2) holds the world. A step request of N steps does these steps:
- It sets a fixed frame time of one physics step. Chaos then runs exactly one step in each frame.
- It releases the world for N frames and holds it again.
- While the world is held, the vehicle pawns keep ticking. The sensors finish their scans and images. The bridges send their reports.
- A barrier goes into each sensor stream and each vehicle bridge.
- The reply goes to the client after the N steps, when the sensors of each agent are idle.
-LockstepFrameSteps lets one frame run the steps up to the next sensor sample, at most 12. The frames between sensor samples then are not rendered.
For many episodes (training, evaluation), these options also cut the frames that nobody reads. The physics does not change.
-LockstepFrameSteps.-SensorCameraRearHz=2: the rear camera at the rate that the perception of the vehicle reads it.-ResX=320 -ResY=180 -ForceResand main-view show flags off (-ExecCmds=ShowFlag.DynamicShadows 0,...).
Warning
Keep Lumen and the reflections of the main view on. Without a ray-tracing feature, the view builds no ray-tracing scene, and the GPU LiDAR stops the game (assertion LayerView.RayTracingSceneBufferSRV).
Tools/Performance/lockstep_benchmark.py --rollout measures the rate with these options.
ACRES Core#
A call of Batch.step runs 12 physics steps of 1/120 s for each environment. One thread steps one environment. The build of ACRES Core and of the run-time library uses -O2 -ffp-contract=off -fno-fast-math. Thus two machines with the same compiler give the same numbers, and the results do not depend on the number of threads (Tests/Runtime/determinism_tests.cpp).
Repeatable Runs#
- In the game, use lockstep and an episode log.
Tools/SimControl/lockstep_determinism.pystarts the game more than one time with the same seed and the same commands, and compares the trajectories. - Outside lockstep, the frame timing changes the step at which a command applies. Thus two free runs are not equal.
- Set the seeds:
-EnvSeed=for the weather and-SensorSeed=for the sensor noise. - Send the commands only between two step requests. A command that arrives during a request applies at a step that changes with the timing.
- Start each run in a new session. A reset does not set the physics clock or the soil water back to the start.
- Outside lockstep, the soil water runs on its own thread. Its snapshots can reach the tires at slightly different steps (
Results/Tractor/soil_weather_results.md). In lockstep, the physics thread steps the water grid itself.