ODE Nondeterminism

Typically: "How do I... ", "How can I... " questions
JKY
Posts: 5
Joined: 07 Oct 2016, 20:37

ODE Nondeterminism

Post by JKY » 08 Oct 2016, 00:15

Hi, I am pretty new to V-REP. I have a question regarding nondeterministic simulation in ODE.

According to the following previous posts, the dynamics engines should not be trusted to run deterministically due to factors like constraint ordering: I simulated a passive double-pendulum in V-REP PRO EDU V3.3.0 on Mac OS X 10.11.6. Using the Bullet and Newton engines, the simulation was deterministic, but in ODE the simulation was nondeterministic. I left all simulation parameters and engine-specific parameters at their default values.
This is confusing to me, because the ODE simulation environment is deterministic outside of V-REP. I wrote an equivalent simulation of a passive double pendulum in C++ for ODE and verified that its behavior is deterministic.

What is V-REP doing that makes ODE nondeterministic while preserving determinism in the other engines? Is there a way for me to make ODE run deterministically in V-REP?

Thanks!

coppelia
Site Admin
Posts: 7330
Joined: 14 Dec 2012, 00:25

Re: ODE Nondeterminism

Post by coppelia » 11 Oct 2016, 07:59

Hello,

interesting you mention this point. As far as I know we haven't introduces ourselves a non-deterministic component in the ODE plugin code. It would help to be able to identify what element introduces the non-deterministic component. It seems that friction is not involved in your test case.

Cheers

JKY
Posts: 5
Joined: 07 Oct 2016, 20:37

Re: ODE Nondeterminism

Post by JKY » 12 Oct 2016, 00:32

Hi! Thanks for your reply!

In case it might be useful, here is a Dropbox link to a folder containing the double pendulum V-REP simulation and similar C++ ODE simulation that I have been investigating. I am using ODE version 0.13 compiled for double-precision floating point. In the folder there is also a .CSV output from the ODE simulation:

Dropbox Link

The double-pendulum is supported by a square base resting on the ground. With the current coefficient of friction, the base remains in static friction and does not move during the entire run in both V-REP and raw ODE. Besides this simulation, I have tested raw ODE simulations in the following conditions and have been unable to find nondeterminism in any case:
  • Bouncing and collisions
  • Static or dynamic friction
  • Large or small time steps
  • Gravity and applied forces and torques
  • dWorldStep and dWorldQuickStep solvers
In all V-REP simulations I have built with sufficient motion over a sufficiently long period of time I have noticed nondeterminism in ODE (but not in the other engines). This includes simulations with and without friction, applied forces and torques, or impacts. My simulations do not run when I turn off the "Use 'quickStep'" ODE engine-specific property in V-REP.

Thanks again!

coppelia
Site Admin
Posts: 7330
Joined: 14 Dec 2012, 00:25

Re: ODE Nondeterminism

Post by coppelia » 12 Oct 2016, 13:17

Interesting. With your scene I obtain also non-deterministic results, unless I turn the item Use 'quickstep' off: in that case, the pendulum simulation becomes deterministic.

What happens in details in the ODE engine.. don't ask me. But the quickStep item in an approximation. Turning it off makes things more precise, but slower also. And it has a bad tendency to crash with content that includes several linked bodies.

You say that when you disable the quickStep item, your simulation doesn't run anymore? The double-pendulum doesn't move anymore? That is strange and shouldn't be. What system are you running on? What V-REP version?

Cheers

JKY
Posts: 5
Joined: 07 Oct 2016, 20:37

Re: ODE Nondeterminism

Post by JKY » 13 Oct 2016, 18:11

Great! Turning off "Use 'quickStep" worked for us and made the scene deterministic in Windows 7 and 8. Unfortunately, I have trouble on the machine I usually use running V-REP version 3.3.0 on Mac OS X 10.11.6, El Capitan (2015 Macbook Pro). When I try to run the scene, all objects immediately disappear. Is this a bug specific to V-REP on Mac?

When I turn off "Use 'quickStep'" I receive the warning:
You selected not to use the ‘quickstep’ method. This is only recommended for scenes with very little dynamic content, otherwise you might experience sudden crashes.

coppelia
Site Admin
Posts: 7330
Joined: 14 Dec 2012, 00:25

Re: ODE Nondeterminism

Post by coppelia » 17 Oct 2016, 08:04

Do the objects disappear when the option Use quickStep is turned off? We have actually never worked with ODE without that option on, since we noticed too many problems in that case. As far as I know, this problem is not only specific to Mac.

Cheers

JKY
Posts: 5
Joined: 07 Oct 2016, 20:37

Re: ODE Nondeterminism

Post by JKY » 18 Oct 2016, 01:04

Yes. On the Mac, objects disappear when the option "Use 'quickStep'" is turned off. This disappearing behavior was not observed in Windows with "Use 'quickStep'" turned off. The simulation runs well (though nondeterministically) in both operating systems when "Use 'quickStep'" is turned on. Is the easiest solution to abandon Mac OS when turning off "Use 'quickStep'" since that setting is untested? Thanks!

coppelia
Site Admin
Posts: 7330
Joined: 14 Dec 2012, 00:25

Re: ODE Nondeterminism

Post by coppelia » 18 Oct 2016, 07:32

I guess that's your best option. Or - the harder way - look at the ODE code and try to figure out what is different on Mac with the quickStep function.

Cheers

JKY
Posts: 5
Joined: 07 Oct 2016, 20:37

Re: ODE Nondeterminism

Post by JKY » 20 Oct 2016, 19:54

Hello! My lab mate looked through the ODE source code and found the source of the nondeterminism using quickStep!

On line 64 of quickstep.cpp:

Code: Select all

#define RANDOMLY_REORDER_CONSTRAINTS 1
sets the quickStep solver to randomly reorder constraints for increased accuracy.

ODE defines a function to set the random seed in misc.cpp, but this isn't exposed in V-REP. Setting the random seed at the beginning of the run should make the simulation repeatable. Is this a feature that could be added to V-REP in the future?

coppelia
Site Admin
Posts: 7330
Joined: 14 Dec 2012, 00:25

Re: ODE Nondeterminism

Post by coppelia » 23 Oct 2016, 10:06

Thanks, we now added following for the ODE plugin, during initialization:

Code: Select all

    int s=simGetEngineInt32Parameter(sim_ode_global_randomseed,-1,NULL,NULL);
    if (s>=0)
        dRandSetSeed(s);
So you can change the seed (-1 by default) from within a script with for instance:

Code: Select all

    simSetEngineInt32Parameter(sim_ode_global_randomseed,-1,seed)
This will be available in next release.

Cheers

Post Reply