Regression in Logmap? (v4.2a7)

92 views
Skip to first unread message

Guillaume Jacob

unread,
Jun 24, 2022, 9:37:15 AM6/24/22
to gtsam users
Hi everyone,

After an upgrade from version 4.0.3 to 4.2a7, we've noticed a strange behavior in our unit tests which we were able to track down to back and forth conversions between AngleAxis and Rotation representations for rotations.

Here is a piece of code that generates random test data in the form of 3D vectors with a norm close to PI, applies Logmap / Expmap to each vector and compares the vectors before / after this transformation − using the same metric as Eigen::DenseBase::isApprox().

* With GTSAM 4.0.3, the error is lower than 1e-9 for angles < 3.140 rad, then increases as the angle approaches PI (as expected due to the singularity).

gtsam_4.0.3_s.png

* With GTSAM 4.2a7, we can notice a huge jump from about 1e-12 to [1e-5, 1e-3] around ~3.110 rad and a decrease as the angle gets closer to PI.

gtsam_4.2a7_s.png

There have been several changes in SO3::Logmap recently so we suppose a mistake might have slipped unnoticed. What do you think?

Thanks in advance,
Guillaume

plot_gtsam.py
main.cpp

Guillaume Jacob

unread,
Jun 24, 2022, 9:51:25 AM6/24/22
to gtsam users
I forgot to mention that with some modifications I was able to reduce the error jump from ~1e-4 down to ~1e-8 by including two additional higher order terms in the Taylor series for the scale and replacing the approximation `Q1 = 2.0 + 2.0 * Raa` by `Q1 = 1 + 2 * Raa - tr` to account for the fact that the trace of R is not exactly -1. However, we still have the discontinuity around ~ 3.110 rad.

Figure_4_hot+tr_s.png
G

Guillaume Jacob

unread,
Jun 28, 2022, 3:29:29 AM6/28/22
to Jiang, Fan, gtsam users
Hi Fan,

I've tried with several tolerance values: 1e-4 to 1e-9, see attached figures. Pay attention to the vertical axis, as limits can change from one figure to another. Let me know if you think of additional tests I could perform.

Thanks,
Guillaume

On Sat, 25 Jun 2022 at 07:53, Jiang, Fan <fan....@gatech.edu> wrote:
Hi G,

I am pretty sure this is due to my PR https://github.com/borglab/gtsam/pull/887 for fixing the singularity. The tolerances in that PR seems a bit too loose, thanks to your observations. Could you try changing the 
if (tr + 1.0 < 1e-4) { to some higher tolerances and see the impact?

Best,
Fan

Fan Jiang
3rd year Robotics PhD
Georgia Institute of Technology

E-mail: fan....@gatech.edu

Try TeXmacs today!


On Jun 24, 2022, at 06:51:25, Guillaume Jacob <guillau...@easymile.com> wrote:

I forgot to mention that with some modifications I was able to reduce the error jump from ~1e-4 down to ~1e-8 by including two additional higher order terms in the Taylor series for the scale and replacing the approximation `Q1 = 2.0 + 2.0 * Raa` by `Q1 = 1 + 2 * Raa - tr` to account for the fact that the trace of R is not exactly -1. However, we still have the discontinuity around ~ 3.110 rad.

<Figure_4_hot+tr_s.png>
G
On Friday, 24 June 2022 at 15:37:15 UTC+2 Guillaume Jacob wrote:
Hi everyone,

After an upgrade from version 4.0.3 to 4.2a7, we've noticed a strange behavior in our unit tests which we were able to track down to back and forth conversions between AngleAxis and Rotation representations for rotations.

Here is a piece of code that generates random test data in the form of 3D vectors with a norm close to PI, applies Logmap / Expmap to each vector and compares the vectors before / after this transformation − using the same metric as Eigen::DenseBase::isApprox().

* With GTSAM 4.0.3, the error is lower than 1e-9 for angles < 3.140 rad, then increases as the angle approaches PI (as expected due to the singularity).

gtsam_4.0.3_s.png

* With GTSAM 4.2a7, we can notice a huge jump from about 1e-12 to [1e-5, 1e-3] around ~3.110 rad and a decrease as the angle gets closer to PI.

gtsam_4.2a7_s.png

There have been several changes in SO3::Logmap recently so we suppose a mistake might have slipped unnoticed. What do you think?

Thanks in advance,
Guillaume


-- 
You received this message because you are subscribed to the Google Groups "gtsam users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gtsam-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gtsam-users/04a4c6b4-0ed6-4fcb-aa02-48aaa6169dd0n%40googlegroups.com.
<Figure_4_hot+tr_s.png>



--

Guillaume JACOB 
Software Engineer

office +33 (0)5 32 10 81 90
guillaume.jacob@easymile‍.com

21 Boulevard de la Marquette
Bat B, 3éme étage
31000 Toulouse
www.easymile‍.com

gtsam_4.2a7_thr1e-4.png
gtsam_4.2a7_thr1e-5.png
gtsam_4.2a7_thr1e-6.png
gtsam_4.2a7_thr1e-7.png
gtsam_4.2a7_thr1e-7_zoom.png
gtsam_4.2a7_thr1e-8.png
gtsam_4.2a7_thr1e-8_zoom.png
gtsam_4.2a7_thr1e-9.png
gtsam_4.2a7_thr1e-9_zoom.png

Frank Dellaert

unread,
Jul 2, 2022, 12:20:23 PM7/2/22
to gtsam users
Thanks for the thorough investigation! I was traveling but will talk to Fan to check into it in more detail.
Is it possible to create an issue on GTSAM repo and upload these graphs?
Frank

Fan Jiang

unread,
Jul 3, 2022, 1:23:32 PM7/3/22
to Guillaume Jacob, gtsam users
Hi Guillaume,

Thanks for the new investigations! Could you open an issue on GitHub with the data, so we can keep better records?

On your test results: If you read #887 you will see that the reason #887 is introduced is to fix the axis angle for slight unnormalized matrices, hence the test case in #887. For your problem, it seems that the changes introduced have reduced tolerance when off the singularity. I am thinking about 1. reduce tolerance to like 1e-7 and 2. add a higher order term in the near-singularity case. We can tune the two halves to match at the transition.

Best,
Fan


Guillaume Jacob

unread,
Jul 4, 2022, 4:14:24 AM7/4/22
to gtsam users
Frank, Fan,

Thanks for the feedback! Here's the link to the new issue: https://github.com/borglab/gtsam/issues/1233.

Regards,
Guillaume
Reply all
Reply to author
Forward
0 new messages