Skip to content
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

Questions about Quaternion's difference equation #125

Open
nyxrobotics opened this issue Jan 11, 2024 · 3 comments
Open

Questions about Quaternion's difference equation #125

nyxrobotics opened this issue Jan 11, 2024 · 3 comments

Comments

@nyxrobotics
Copy link

I am studying localization with your program.
Let me ask you a question about the implementation details.

I am not sure how to derive this equation for the following quaternion calculation, although the result seems to be correct.

Quaterniont dq(1, gyro[0] * dt / 2, gyro[1] * dt / 2, gyro[2] * dt / 2);
dq.normalize();
Quaterniont qt_ = (qt * dq).normalized();

I believe the following equation can be implemented using Euler angles

dq = Eigen::AngleAxisf(gyro[0] * dt_, Vector3t::UnitX()) * Eigen::AngleAxisf(gyro[1] * dt_, Vector3t::UnitY()) *
     Eigen::AngleAxisf(gyro[2] * dt_, Vector3t::UnitZ());

Therefore, my questions are two

  • Can I learn how to derive your calculation method in some article?
  • Should the formula I am thinking of work the same as yours?
@nyxrobotics
Copy link
Author

I refer to the following article for the quaternion definition formula (the order of the w components has been replaced)
https://qiita.com/drken/items/0639cf34cce14e8d58a5

@koide3
Copy link
Owner

koide3 commented Jan 12, 2024

  • You can find the derivation here.
  • The Euler angle-based method applies X,Y,Z rotations one-by-one while the quaternion-based one applies rotations in all the axes simultaneously. This difference would result in errors when a large angular motion occur. If you are interested in theoretical details, I recommend taking a look at documents about SO3 expmap.

@nyxrobotics
Copy link
Author

Thank you for your reply. It is very helpful.
Please allow me to ask an additional question.
In the article you gave me, I think the calculation would be as follows since it is the derivative of each element of the quaternion.
Can I derive the same equation from here as you?

  Quaterniont dq = Quaterniont(0, gyro[0] * dt_ / 2.0, gyro[1] * dt_ / 2.0, gyro[2] * dt_ / 2.0) * qt;
  Quaterniont qt_next = Quaterniont(qt.w() + dq.w(), qt.x() + dq.x(), qt.y() + dq.y(), qt.z() + dq.z()).normalized();

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

No branches or pull requests

2 participants