Pr claude/test eulers from quat test - #45
Open
peterbarker wants to merge 11 commits into
Open
Conversation
…trix quat.rotate(-trim) treats the trim parameters as a rotation vector; everywhere else trim is applied as the euler rotation matrix get_rotation_vehicle_body_to_autopilot_body() - in DCM's body matrix and the EKFs' getRotationBodyToNED. The two conventions differ at second order in the trim angles (measured 0.05 degrees of attitude with 3/-2 degrees of trim), so each backend's quaternion disagreed with the rotation matrix supplied by the same backend. Apply the same rotation to the quaternion that is applied to the matrices, via a quaternion built from the trim euler angles, cached alongside the trim rotation matrices. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Backends now supply only a quaternion as their attitude estimate; the euler angles and rotation matrix in the results are derived from it by common code. This guarantees all attitude representations supplied by a backend agree; previously the euler angles disagreed with the quaternion by up to 3.8 degrees (EKF2/EKF3, with 3/-2 degrees of trim, at high attitude angles) and the rotation matrix by 0.05 degrees. For DCM the derived matrix is also now exactly orthonormal rather than being the renormalized integration matrix. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Mirrors the existing rotation-matrix accessor. In Replay the quaternion is reconstructed from the trim logged in RFRN, so existing logs replay without change. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
AP_AHRS no longer consumes euler angles from the EKFs. The remaining internal consumers - NKF1/XKF1 logging and the lane-switch yaw reset accounting - now derive euler angles the same way AP_AHRS does: compose the attitude quaternion with the trim quaternion and convert, so logged eulers are in the same (vehicle-body) frame as ATT and can never disagree with the quaternion-derived attitude. This also replaces the previous euler-component subtraction of trim, which was only a first-order approximation; with 3/-2 degrees of trim it was wrong by up to 3.8 degrees at high attitude angles. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This was the last consumer of getRotationBodyToNED, which took a detour through a rotation matrix purely to apply trim; apply the trim quaternion instead, as AP_AHRS does, and remove getRotationBodyToNED from the cores and frontends. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The EKFs now apply trim via the quaternion form only. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The rotation matrix is now derived from the backend quaternion, so converting it back to a quaternion was a round trip; return the stored quaternion directly. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Log, per backend, the difference between the euler angles and rotation matrix the backend supplies in its Estimates and the same representations derived from the quaternion it supplies. This quantifies what would change if the backends supplied solely a quaternion. Not for merging. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Flies attitude excursions with zero and non-zero AHRS_TRIM to gather QVAL log data quantifying backend attitude divergence from the quaternion. EKF2 is enabled so it is measured too. Not for merging. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Uses the SITL calibration model to pose the vehicle at ~290 fibonacci-sphere-distributed attitudes, with zero and non-zero AHRS_TRIM, and reports per-backend the divergence between backend-supplied attitude representations and those derived from the backend's quaternion. Results are written as a JSON artifact to the buildlogs directory for visualisation. Not for merging. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Interactive sphere (plotly) showing, across the whole attitude envelope, how far each backend's master-era euler/matrix outputs diverge from its own quaternion with 3/-2 degrees of AHRS_TRIM, with the dense EulersFromQuatPosed SITL measurements overlaid and tabulated. eulers_from_quat_sphere.py regenerates the html from the preserved measurement JSON; the analytic model in it validates itself against the measurements on each run. Not for merging. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
peterbarker
force-pushed
the
pr-claude/test-eulers-from-quat-test
branch
from
June 12, 2026 03:22
f605c29 to
ce75326
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Classification & Testing (check all that apply and add your own)
Description