-
Notifications
You must be signed in to change notification settings - Fork 13.6k
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
Yaw Emergency estimator: store attitude as quaternion instead of DCM #24119
Conversation
This saves flash and makes code simpler
🔎 FLASH Analysispx4_fmu-v5x [Total VM Diff: -136 byte (-0.01 %)]
px4_fmu-v6x [Total VM Diff: -120 byte (-0.01 %)]
Updated: 2024-12-17T12:02:33 |
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.
Refactoring looks consistent with original code to me
// Apply the change in yaw angle to the AHRS using left multiplication to rotate | ||
// the attitude around the earth Down axis | ||
const Quatf dq(cosf(yawDelta / 2.f), 0.f, 0.f, sinf(yawDelta / 2.f)); | ||
_ahrs_ekf_gsf[model_index].q = (dq * _ahrs_ekf_gsf[model_index].q).normalized(); |
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.
Just double checking about the order - to me it makes more sense to first apply the yaw and then the remaining tilt as the rotation is applied from right to left. Could you confirm?
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.
Rotating a vector is from right to left, yes, but here we're simply chaining rotations here (from left to right). So yes, first rotate around yaw and then tilt.
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.
ah okay, because in the Quaternion header file it says the order is from right to left. But if it's from left to right then makes sense!
This is a pure refactoring, no functional changes expected.
Solved Problem
The yaw estimator has its attitude stored as a rotation matrix. This requires to save 5 more floats than using a quaternion per EKF; since there are 5 EKFs per yaw estimator this gives 25 floats per EKF2 instance. Furthermore initializing, integrating and re-normalizing a quaternion is simpler than using a rotation matrix.
Solution
Store the attitude as a quaternion.
Test coverage
unit tests