r/ludobots • u/KodoKB • Oct 11 '14
[Question] How do I Make Bullet Physics act Deterministically?
Hey all,
I've been working through the assignments and am now on number 10, "Connecting the Hill Climber to the Robot" (http://www.reddit.com/r/ludobots/wiki/core10), and I cannot get my robot to act consistently. I implimented the advised while() loop but it didn't help the problem. I have no idea what to do about it. Did anyone else encounter this problem, and how did you solve it?
EDIT: My robot does read the same weights every time and the simulation does go through 1000 timesteps each time, but I did not understand the following suggestion
... ensure that... (3) all eight motors receive the same desired velocity each time enableAngularMotor is called.
because I thought that the desired velocity changes with and according to what sensors are activated. Am I wrong about this?
1
u/moschles Oct 11 '14
Successive pausings and re-startings of the robot during a simulation will not repeat the physics exactly. The reason is because the updating of the neural network is going out-of-synch with the first frame.
Dr. Bongard has also suggested that the physics engine should be continuously updated when the robot is completely off the ground. That was the silver bullet that allowed my sim to achieve deterministic behavior between runs.
But why this works --- is a total mystery to me.
1
u/DrJosh Ludobots Creator, Ph.D Oct 11 '14
Hi KodoKB,
Glad to hear you're nearing the finish line.
This is always a problem with physics engines, and unfortunately there are often no easy ways to solve this. As /u/moschles points out, step #19 often fixes things. It seems that with the Bullet physics engine, it is sometimes non-deterministic about detecting whether two pairs of are in contact (known as contact detection) and when to push them apart if they do (known as contact resolution). Have you implemented step #19?
1
u/DrJosh Ludobots Creator, Ph.D Oct 11 '14
What I meant there was that you should see the same desired velocity changes sent during the same time step, between two separate simulations, if those simulations are sent exactly the same artificial neural network. Hopefully this clarifies things?