Skip to content
This repository has been archived by the owner on Nov 17, 2021. It is now read-only.

Support hamilton quaternion #29

Closed
jgoppert opened this issue Aug 18, 2016 · 6 comments
Closed

Support hamilton quaternion #29

jgoppert opened this issue Aug 18, 2016 · 6 comments

Comments

@jgoppert
Copy link
Member

Benefits:

  • Same product convention as DCM.
    • v_c = C_cb * C_ba * v_a v_q = q_cb * q_ba * v_a
    • currently: v_q = q_ba * q_cb * v_a (not very intuitive)
  • More widely used (ROS) etc.

Drawback:

  • ecl library already written assuming products are ordered the other way

@LorenzMeier @Tumbili @bkueng @priseborough @mkschreder

@mkschreder
Copy link

I think switching to hamilton will ensure correctness of future algorithms. You don't want people to come into the project and start doubting their knowledge because the results they get from implementing their equations is not what they would expect just because something as basic as a product operator has been defined differently.

Some other widely used libraries that use hamilton:

  • GLM
  • Eigen

I checked eigen source code and this is their multiplication:

  a.w() * b.w() - a.x() * b.x() - a.y() * b.y() - a.z() * b.z(),
  a.w() * b.x() + a.x() * b.w() + a.y() * b.z() - a.z() * b.y(),
  a.w() * b.y() + a.y() * b.w() + a.z() * b.x() - a.x() * b.z(),
  a.w() * b.z() + a.z() * b.w() + a.x() * b.y() - a.y() * b.x()

Aligning the terms gives:

  a.w() * b.w() - a.x() * b.x() - a.y() * b.y() - a.z() * b.z(),
  a.w() * b.x() + a.x() * b.w() + a.y() * b.z() - a.z() * b.y(),
  a.w() * b.y() - a.x() * b.z() + a.y() * b.w() + a.z() * b.x(),
  a.w() * b.z() + a.x() * b.y() - a.y() * b.x() + a.z() * b.w()

Which is the same as on wikipedia page (https://en.wikipedia.org/wiki/Quaternion#Hamilton_product)

@LorenzMeier
Copy link
Member

Those are some good arguments and I particularly care about compatibility to Eigen. So it sounds like what we need to do is to do a sweep through ECL and replace all incorrect occurrences. That should actually not be too hard, since most of the estimator code is generated and hand-crafted quaternion operations will be just a few.

@jgoppert
Copy link
Member Author

I agree. I just wasn't familiar enough with ecl to do it myself. I am glad there is interest in doing that. I really like the product order matching the dcm product order.

@bkueng
Copy link
Member

bkueng commented Aug 23, 2016

+1 for hamilton

@MaEtUgR
Copy link
Member

MaEtUgR commented Sep 21, 2016

+1 for some standard that is consistent with other applications, JPL would also be a possibility but matching Eigens convention is probably the right choice here.

@MaEtUgR
Copy link
Member

MaEtUgR commented Dec 13, 2016

I'm on my way of checking the criteria for the Hamilton convention to be fully compliant.
I did this using the following paper: http://www.iri.upc.edu/people/jsola/JoanSola/objectes/notes/kinematics.pdf
It uses Hamilton convention and even has some comparisons to JPL.
In the table on page 18 the main decisions for Hamilton are listed.

  • The order of the quaternion elements is clearly right
  • Changes for hamilton quaternion convention. #34 addresses the quaternion multiplication and I checked it is compliant
  • I double checked the rotation matrix conversion and it's compliant at least with this paper
    What I didn't recheck yet are any other conversions like from euler angles... but that can still be done.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants