erwincoumans / tiny-differentiable-simulator

Tiny Differentiable Simulator is a header-only C++ and CUDA physics library for reinforcement learning and robotics with zero dependencies.
Apache License 2.0
1.2k stars 129 forks source link

The effect of accelerations on the velocities is added twice #200

Closed jotix16 closed 2 years ago

jotix16 commented 2 years ago

Considering the example in ant_environment.h or laikago_environment.h, the Semi-Implicit-Euler integration takes place in the following snippet

https://github.com/erwincoumans/tiny-differentiable-simulator/blob/c1a9e06de33756bceacfaddeecc6bc4b6c98560c/examples/environments/ant_environment.h#L196-L200

First integrate_euler_qdd(*mb_, dt); is called to add the effect of accelerations into change of velocities, then tds::integrate_euler(*mb_, dt); is called to integrate once again.

But if we look into integrator.hpp, we find the integration of acceleration on both functions, i.e in integrate_euler(..):

https://github.com/erwincoumans/tiny-differentiable-simulator/blob/c1a9e06de33756bceacfaddeecc6bc4b6c98560c/src/dynamics/integrator.hpp#L95-L98

and in integrate_euler_qdd(..) https://github.com/erwincoumans/tiny-differentiable-simulator/blob/c1a9e06de33756bceacfaddeecc6bc4b6c98560c/src/dynamics/integrator.hpp#L173-L175

Is this meant to be like this or is this an error and it should be taken care of?

erwincoumans commented 2 years ago

The accelerations should be cleared to zero after 'integrate_euler_qdd', isn't it?

  Algebra::set_zero(mb.qdd());
jotix16 commented 2 years ago

Missed that one. Thank you, I am closing the issue.