Gimbal: Use delta_yaw in heading calc when provided rather than vehicle - #14865
Gimbal: Use delta_yaw in heading calc when provided rather than vehicle#14865jnomikos wants to merge 6 commits into
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #14865 +/- ##
==========================================
+ Coverage 25.47% 33.77% +8.30%
==========================================
Files 769 933 +164
Lines 65912 84623 +18711
Branches 30495 39123 +8628
==========================================
+ Hits 16788 28580 +11792
+ Misses 37285 36841 -444
- Partials 11839 19202 +7363
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 635 files with indirect coverage changes Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
Build ResultsPlatform Status
All builds passed. Pre-commit
Pre-commit hooks: 2 passed, 75 failed, 7 skipped. Test Resultslinux-coverage-integration: 43 passed, 0 skipped Code CoverageCoverage: 69.5% No baseline available for comparison Artifact Sizes
Updated: 2026-08-14 21:37:46 UTC • Commit: 9cebea8 • Triggered by: Windows |
There was a problem hiding this comment.
Pull request overview
Uses gimbal-provided delta_yaw when available to improve body/earth yaw-frame conversions.
Changes:
- Adds delta-yaw telemetry as a Fact.
- Detects and stores supported
delta_yawvalues. - Uses delta yaw instead of vehicle heading for yaw calculations.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
src/Gimbal/GimbalFact.json |
Defines delta-yaw metadata. |
src/Gimbal/GimbalController.cc |
Consumes delta yaw and converts yaw frames. |
src/Gimbal/Gimbal.h |
Exposes and stores the delta-yaw Fact. |
src/Gimbal/Gimbal.cc |
Initializes and copies delta-yaw state. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
| gimbal->setAbsoluteRoll(qRadiansToDegrees(roll)); | ||
| gimbal->setAbsolutePitch(qRadiansToDegrees(pitch)); | ||
|
|
||
| const float deltaYawDeg = qRadiansToDegrees(attitude_status.delta_yaw); |
- Some gimbals have a seperate mag/compass to the vehicle and may provide delta_yaw. - For these specific gimbals, utilizing delta_yaw is better than basing gimbal setpoint on vehicle heading, because it removes the risk of drift if the gimbal's sensor readings differ from vehicle. - A gimbal device maintains its own yaw estimate, which can differ from the vehicle's heading.
90fb758 to
fab16bf
Compare
- Fixes edge case where if deltaYaw WAS valid, went NAN and then became valid again (by sending exactly 0.0), we would not consider it valid.
…n assumption that delta_pitch
4866453 to
0e73d72
Compare
0e73d72 to
9cebea8
Compare
Description
Some gimbals have a seperate mag/compass to the vehicle and may provide delta_yaw. For these specific gimbals, utilizing delta_yaw is better than basing gimbal yaw on vehicle heading, because it removes the risk of inaccuracy if the gimbal's sensor readings differ from vehicle. A gimbal device maintains its own yaw estimate, which can differ from the vehicle's heading.
Motivation: The Pixy LR gimbal when sending the
GIMBAL_DEVICE_ATTITUDE_STATUSmessage always givesYAW_IN_VEHICLE_FRAME, regardless of if follow/lock. When tested indoors and utilizing vehicle heading in the yaw calculation, switching between follow to lock causes the gimbal to move. Utilizing delta_yaw fixes this.Related PR: ArduPilot/ardupilot#33870
Type of Change
Testing
Platforms Tested
Flight Stacks Tested
Tested with Gremsy Pixy LR gimbal on v7.8.7 with my ArduPilot PR. Without my change, switching from follow to lock causes the gimbal to shift and not maintain yaw. With my change, this issue disappears.
PX4 still needs testing, but should work already because it forwards delta_yaw from the gimbal in
GIMBAL_DEVICE_ATTITUDE_STATUSalready.Screenshots
Checklist
Related Issues
By submitting this pull request, I confirm that my contribution is made under the terms of the project's dual license (Apache 2.0 and GPL v3).