-
Notifications
You must be signed in to change notification settings - Fork 202
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
Fix doTransform with Eigen Quaternion #369
Conversation
@gleichdick I thin, the unit test you mentioned is just plain wrong. I've used the rotated Unity-Y-Vector for visualization in my mind. Turns out, that this is a case, where the current implementation works. So: you are right and the test is wrong. |
@cwecht It's clear that you think the unit test is wrong. But given that you wrote the code originally, do you also agree that the code in |
@clalancette I'm afraid it is so. I have no idea what I was thinking back in the day. I'd still suggest to use Eigen's quaterinon multiplication instead of converting the quaternions to matrices in order to do the multiplication. |
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.
I agree that it would be better to leverage the quaternion multiplication w/o converting to matrices. I'd like to undertand what we did wrong with the quaternion math. Did the previous entry just have the order wrong. t * t_in * t.inverse()
? Where else does this fail? If we're in doubt about the correctness we should potentially write out a few more test cases to verify. And possibly test them against the matrix math for easier validation.
That's no problem, just making sure we were all on the same page. Thanks for the feedback. |
bad8968
to
b8b291f
Compare
In my understanding, a (homogenous) transform is just applied to the left. If the tanslational part is zero, it's just a rotation. So Now I added two more rotation tests (based on three-finger rule). I had to convert the quaternions to rotation matrices to compare them (because [0, 0, -1, 0] is the same rotation as [0, 0, 1, 0] and I defined the expected result in terms of angle-axis). EDIT: Ah, Now I got it: According to Wiki, Rotations of quaternions are chained by multiplication only. The formula mentioned by Tully ( |
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.
Thanks for looking up the difference between the quaternion and vector operations. That makes more sense now. The notation can be quite ambiguous on that.
@cwecht could you take one more look?
Thanks for running the CI, |
LFTM. Finally doTransform for Quaterniond should now be consistent with doTransform for e.g. Affined3d. |
700f781
to
930705b
Compare
The conversion tests turned out to be disabled for a reason, so I don't enable them anymore. Should now finally work...
By the way, I expect #368 to fix that problem. Is there any chance for me to run the CI (the big one) on my own? |
CI looks good now. Thanks @gleichdick for the fix and thanks @cwecht for the review. Merging. |
I noticed that
doTransform()
forEigen::Quaterniond
seems to be broken while making unit tests.The same testcase adapted for tf2_geometry_msgs works.
The math:
![image](https://user-images.githubusercontent.com/43565432/106165996-9dbdbe00-6183-11eb-9f51-b67cf3746d84.png)
Let T be the transform rotation matrix (rotates around the x Axis by 180 degrees) and Q a given rotation matrix (-90 degrees around y). So when transforming Q (T times Q) the resulting quaternion should be [x, y, z, w]^T = [0.7071, 0, -0.7071, 0].
I re-enabled the other conversion tests and formatted the file with uncrustify