Pybullet Deterministic Simulation

Post Reply
suhail
Posts: 3
Joined: Sat Jul 20, 2019 9:03 pm

Pybullet Deterministic Simulation

Post by suhail »

Hi,

I am trying to simulate a path on the PR2 manipulator in a specific environment. My program calls the simulate function ten times, I reset the scene every time before calling the simulate function. The results seem to be different every call of the simulation!
However, when I rerun the entire program the first simulation call of the rerun and the first run seem to produce the same results, and the second simulation call of the rerun and the first run, and so on...
Is there a specific flag or seed that I need to set to ensure that every call to the simulate function yields the same result.

I am using setJointMotorControl2 command (POSITION_CONTROL) to move the arm along the path. I set the timestep and step it a fixed number of times. Not sure where the variable is introduced!
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Re: Pybullet Deterministic Simulation

Post by Erwin Coumans »

PyBullet is fully 100% deterministic after calling resetSimulation and adding the objects in the same order.
Many of our reinforcement learning environments rely on this.
In fact, there are unit tests that show that PyBullet is also fully deterministic after a save/restoreState call, not just resetSimulation.

If not, file an issue in the issue tracker with a small pybullet reproduction case (including pybullet_data assets if possible).
https://github.com/bulletphysics/bullet3/issues
suhail
Posts: 3
Joined: Sat Jul 20, 2019 9:03 pm

Re: Pybullet Deterministic Simulation

Post by suhail »

Hey Thank you so much for your response!

I found the problem! I wasn't calling the resetSimulation() function after every iteration.
Is there a workaround to not calling the resetSimulation() function? I don't actually want to remove all the objects from the world, just resetting their position to their initial position is much faster? I am assuming resetsimulation() resets a seed maybe?

Also, when I perform the same action from the same configuration at different times (since the last call to resetSimulation()) I get different results! Is there something I can do about that? I assume if I set the seed manually every time before I step, I would get the same result!
Post Reply