dartsim / dart

DART: Dynamic Animation and Robotics Toolkit
http://dartsim.github.io/
BSD 2-Clause "Simplified" License
890 stars 286 forks source link

Create an API for tuning ERP and CFM of the contact constraints in the underlying ODE LCP Solver #1068

Open eastskykang opened 6 years ago

eastskykang commented 6 years ago

When I simulate the stack of the blocks as the image below, I got the warning message "ODE Message 3: LCP internal error, s <= 0" from Dantzig solver. As far as I know, this error is from ODE Dantzig solver (standard solver of Open Dynamics Engine) and it slows down the simulation step.

image

In ODE, I could tune some parameters such as ERP or CFM. For Dart, how can I set parameters to attenuate this problem?

mxgrey commented 6 years ago

We keep a copy of the ODE LCP solver in the DART codebase, so the error will be coming from here.

I don't think we currently provide any interfaces for tuning the ERP or CFM, but that would be a great feature to add.

mxgrey commented 6 years ago

One option to consider in the meantime (if you haven't tried it already) is switching to the PGSLCPSolver. The PGS method tends to provide more stable results.

You should be able to change the solver by calling

world->getConstraintSolver()->setLCPSolver(dart::common::make_unique<dart::constraint::PGSLCPSolver>(world->getTimeStep()))

(Disclaimer: That line of code is untested, so it may need some corrections)