stanfordnmbl / osim-rl

Reinforcement learning environments with musculoskeletal models
http://osim-rl.stanford.edu/
MIT License
894 stars 249 forks source link

Too low integrator accuracy leads to exception #138

Closed janEbert closed 6 years ago

janEbert commented 6 years ago

Setting a too low integrator accuracy (or - given the parameter - too high) leads to the following exception:

std::exception in 'SimTK::State const & OpenSim::Manager::integrate(double)':
SimTK Exception thrown at AbstractIntegratorRep.cpp:428:
  Integrator step failed at time 0.49668703558495564 apparently because:
SimTK Exception thrown at AbstractIntegratorRep.cpp:547:
  Error detected by Simbody method AbstractIntegrator::takeOneStep(): Unable
to advance time past 0.496687.
  (Required condition 't1 > t0' was not met.)

I received the exception using ProstheticEnvs instantiated with integrator_accuracy >= 0.01. There were no problems with values <= 0.001.

Slightly more detailed information: I trained four walkers using different integrator accuracies: 0.1, 0.01, 0.001 and 0.00005 (default). This was the only parameter I modified and as mentioned above, there was a related occurence of errors.

I am on Windows 10 using the latest OpenSim version (Python 3.6.1) and followed the recommended installation instructions.

kidzik commented 6 years ago

That's right, unfortunately, integration might not be possible with integrator accuracy set to high, I believe there is no workaround. @chrisdembia @carmichaelong is there any way to hack this?

chrisdembia commented 6 years ago

I had temporarily introduced a change to allow setting integrator accuracy from Python/Matlab: https://github.com/opensim-org/opensim-core/commit/d09c42953eed8e1b07e014232eef27a73ca4d403 (this commit shows removing the change).

kidzik commented 6 years ago

Thank you @chrisdembia . We actually do have an interface to change accuracy through this https://github.com/kidzik/opensim-core/commit/550c2a15d56a918f5fe712d4050b8b5eba84eaeb and this https://github.com/stanfordnmbl/osim-rl/blob/master/osim/env/osim.py#L227-L233

However, @janEbert is trying to put very high accuracy and it crashes. Is there any rule on how high it can go? or any hack to make it less accurate?

chrisdembia commented 6 years ago

Sherm uses the terms "loose accuracy" and "tight accuracy" to avoid the ambiguity of "low accuracy" and "high accuracy."

That exception message just means the accuracy level is too loose.

janEbert commented 6 years ago

Maybe emit a warning, clip the value or do not allow too high/loose values?

chrisdembia commented 6 years ago

Thanks @janEbert. I think the solution is a warning or clearer error message. It is not possible to clip the value because the appropriate clipping value depends on the model and motion.

chrisdembia commented 6 years ago

@janEbert I created an issue in the simbody repository (https://github.com/simbody/simbody/issues/639).

carmichaelong commented 6 years ago

It is not possible to clip the value because the appropriate clipping value depends on the model and motion.

This is an important point, and particularly tricky here since motions are being generated on the fly. That being said, it might be good to have a rough guideline somewhere. It sounds like @janEbert has found a cutoff accuracy that seems to work pretty well at 0.001, which agrees with what I've been using with a similar model.

chrisdembia commented 6 years ago

Ah yes, giving guidelines is a good idea.