Non-deterministic Bullet simulation with ZMQ stepping mode

Typically: "How do I... ", "How can I... " questions
Post Reply
fdurante
Posts: 1
Joined: 19 Jan 2025, 13:24

Non-deterministic Bullet simulation with ZMQ stepping mode

Post by fdurante »

Hello,

I am running a biped robot simulation in CoppeliaSim controlled from an external Python script through the ZMQ Remote API.

The simulation is executed in stepping mode:

* `sim.setStepping(True)`
* fixed simulation time step: `0.0041667 s`
* Bullet physics engine
* position-controlled joints
* the external Python script sends joint target positions at each simulation step

The scene file and the Python controller are exactly the same between runs.

However, I observe that repeated runs are not perfectly reproducible. Sometimes the biped reaches the end of the floor, while in another run, with the same files and same nominal settings, it falls earlier. The difference appears after several walking steps and seems related to contact dynamics between the feet and the floor.

My question is:

Is Bullet inside CoppeliaSim expected to be fully deterministic between repeated runs when using the ZMQ Remote API in stepping mode?

Could small differences in OS scheduling, ZMQ communication timing, contact solver warm-starting, or contact manifold generation cause different results even if the simulation time step and input commands are the same?

Would moving the whole controller inside a CoppeliaSim script improve repeatability, compared to using an external Python controller through ZMQ?

Thank you.

CoppeliaSim version tested: 4.9 and 4.10
Physics engine: Bullet 2.78
Operating system: Windows
coppelia
Site Admin
Posts: 10807
Joined: 14 Dec 2012, 00:25

Re: Non-deterministic Bullet simulation with ZMQ stepping mode

Post by coppelia »

Hello,

CoppeliaSim generally does not introduce randomized behavior, except in specific contexts where it is meaningful—such as in path-searching tasks or similar stochastic applications. The remote API also preserves deterministic behavior when running in stepping mode. However, on the physics engine side, certain operations—such as shuffling or perturbing large matrices—may be applied to enhance numerical stability, which can introduce slight variations.

To further investigate any non-deterministic effects, I would recommend running your simulation with two or three different physics engines and comparing the outcomes. This will help you determine whether any observed variability is engine-specific or due to other factors—especially if you notice non-deterministic behavior across repeated runs using the same engine.

Cheers
Post Reply