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

More stable version of quaternion_axis_angle #196

Closed ErikGartner closed 2 years ago

ErikGartner commented 2 years ago

I've noticed stability issues that I think are traced to the current version of quaternion_axis_angle.

I've empirically noticed better results with this version from Ceres: https://github.com/ceres-solver/ceres-solver/blob/0141ca090c315db2f3c38e1731f0fe9754a4e4cc/include/ceres/rotation.h#L278

erwincoumans commented 2 years ago

Thank you. The epsilon 1e-6 is quite large, when using double precision. Could you try using a smaller value (1e-15) and see if that still helps? We can add this epsilon constant to the Algebra (dependent on scalar type, 32bit float 1e-6 and 64bit double using 1e-15.

ErikGartner commented 2 years ago

Sure, I'll try with a smaller epsilon and see if that works. There is the epsilon()function we might be able to use already.

https://github.com/google-research/tiny-differentiable-simulator/blob/master/src/math/eigen_algebra.hpp#L665

erwincoumans commented 2 years ago

Let's merge it for now, thanks!