NVIDIA / warp

A Python framework for high performance GPU simulation and graphics
https://nvidia.github.io/warp/
Other
4.16k stars 232 forks source link

Unstable simulation of joint limits for a hinge joint #182

Open slecleach opened 8 months ago

slecleach commented 8 months ago

I've been using warp for a few weeks and it's definitely a very impressive, well executed project!

Currently, I am having trouble simulating a hinge joint using warp.sim. I set the joint range to "-200 45" (in degrees), the rotating link is correctly stopped by the 45deg limit. But when I rotate the link towards the -200deg limit the simulation breaks as soon as it gets close to -180deg.

image

Also I have created a minimal working example here: https://github.com/slecleach/warp/pull/1 You can easily replicate the plot above by running this file: https://github.com/slecleach/warp/blob/minimal_example/examples/env/env_rotor.py

I am not sure what is causing this, I would appreciate if you could share some insights about this phenomenon. Thank you!

eric-heiden commented 5 months ago

Hi Simon,

Thanks for reporting the issue! There seems to be a problem in handling joint coordinates outside [-pi, pi] in general for integrators relying on maximal coordinates (XPBDIntegrator (used by default), SemiImplicitIntegrator). The FeatherstoneIntegrator handles these joint limits correctly, could you work with this for now by setting

integrator_type = IntegratorType.FEATHERSTONE

in the Environment static variables? We will investigate this issue further in the meantime.

slecleach commented 5 months ago

Hi Eric,

Thanks a lot for getting back to me! Yes we'll try the new Featherstone integrator, with minimal coordinates, this type of constraint is somewhat easier to handle. I'll also take a look at the XPBD code to see if I can spot the issue. I'll let you know if I find anything ;)