-
Notifications
You must be signed in to change notification settings - Fork 767
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added Jacobians for Rot3::xyz and related conversions to euler angles #520
Conversation
Awesome! |
Perhaps it would be convenient to add unit tests covering ypr near the extreme +-pi and +-pi/2 values? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great! I'm OK to approve as is, but I think the computation is quite heavy and could probably be improved quite a bit. Still, we did not have this before, and it might not make a huge difference in an application.
Vector3 q = xyz(); | ||
Vector3 Rot3::ypr(OptionalJacobian<3, 3> H) const { | ||
Vector3 q = xyz(H); | ||
if (H) H->row(0).swap(H->row(2)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice !
|
||
Matrix39 qHm; | ||
boost::tie(I, q) = RQ(m, qHm); | ||
*H = qHm * mH; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, this is of course perfectly fine. However, if you care about performance, this is (a) 81 mults, and (b) we could use of the fact that mH is super-sparse. In particular, SO3.cpp says
mH << R * P3.block<3, 3>(0, 0), R * P3.block<3, 3>(3, 0),
R * P3.block<3, 3>(6, 0);
Maybe add as a TODO. In fact I suspect the 3*3 matrix of derivatives might yield not too complicated symbolic expressions, and we do a lot of compute here (including multiplying a lot of things with zero). Might be worth some mathematica exploration.
Ok, I'll add more tests. However, the derivative breaks down for pitch values +- pi / 2. How do you prefer to handle that? Do you use nans? |
That was my point, bringing out that discussion :-) |
I think an exception is a good idea. There is a singularity, for sure. |
Hmm, I'm a bit unsure about which epsilon value we should use... If I set roll and yaw to zero, and if then I get :
What do you think? I hope the numbers are understandable. Edit : I should add that I'm talking about the derivative of Rot3::RQ |
Thanks for the great summary and the time collecting the results! |
Also added more tests and a TODO to investigate a more efficient method of getting the jacobian of Rot3::xyz
@Eskilade let me know when ready to merge.... |
Yupp, ok for my part ! Btw, does this merit a mention in contributors or something similar ? :) |
Of course, feel free to add your name, and then I'll merge :-) |
Where do I add it ? Like in which file :) |
You can add your name here: https://github.com/borglab/gtsam.org/blob/master/about.md |
Alright, but since that's a different repo, then you can go ahead and merge this PR :) |
@Eskilade Thanks for your awesome work. Can you tell me how to derive the jacobians for conversions between Rot3 and euler angles? I have not deduced it, thanks! |
@Eskilade Thanks very much ! |
Hi,
This PR adds the remaining Jacobians for conversions between Rot3 and euler angles (first PR here ). Some of the expressions below are a bit hairy, so please feel free to suggest a different way of doing it :)