Skip to content

Gimbal: Use delta_yaw in heading calc when provided rather than vehicle - #14865

Open
jnomikos wants to merge 1 commit into
mavlink:masterfrom
jnomikos:john-delta-yaw
Open

Gimbal: Use delta_yaw in heading calc when provided rather than vehicle#14865
jnomikos wants to merge 1 commit into
mavlink:masterfrom
jnomikos:john-delta-yaw

Conversation

@jnomikos

@jnomikos jnomikos commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

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_STATUS message always gives YAW_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

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Refactoring (no functional changes)
  • CI/Build changes
  • Other

Testing

  • Tested locally
  • Added/updated unit tests
  • Tested with simulator (SITL)
  • Tested with hardware

Platforms Tested

  • Linux
  • Windows
  • macOS
  • Android
  • iOS

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_STATUS already.

Screenshots

Checklist

  • I have read the Contribution Guidelines
  • I have read the Code of Conduct
  • My code follows the project's coding standards
  • I have added tests that prove my fix/feature works
  • New and existing unit tests pass locally

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).

@codecov

codecov Bot commented Aug 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 31.25000% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 34.26%. Comparing base (f29efd3) to head (ab02585).
⚠️ Report is 308 commits behind head on master.

Files with missing lines Patch % Lines
src/Gimbal/GimbalController.cc 20.00% 3 Missing and 5 partials ⚠️
src/Gimbal/Gimbal.cc 33.33% 1 Missing and 1 partial ⚠️
src/Gimbal/Gimbal.h 66.66% 0 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #14865      +/-   ##
==========================================
+ Coverage   25.47%   34.26%   +8.79%     
==========================================
  Files         769      943     +174     
  Lines       65912    85250   +19338     
  Branches    30495    39334    +8839     
==========================================
+ Hits        16788    29211   +12423     
+ Misses      37285    36546     -739     
- Partials    11839    19493    +7654     
Flag Coverage Δ
unittests 34.26% <31.25%> (+8.79%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/Comms/MockLink/MockLinkGimbal.cc 50.52% <ø> (+4.21%) ⬆️
src/Gimbal/Gimbal.h 48.27% <66.66%> (+17.50%) ⬆️
src/Gimbal/Gimbal.cc 30.35% <33.33%> (-1.72%) ⬇️
src/Gimbal/GimbalController.cc 22.34% <20.00%> (-0.13%) ⬇️

... and 651 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e1f0d6a...ab02585. Read the comment docs.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

github-actions Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Build Results

Platform Status

Platform Status Details
Linux Passed View
Windows Passed View
MacOS Passed View
Android Passed View

All builds passed.

Pre-commit

Check Status Details
pre-commit Failed (non-blocking) View

Pre-commit hooks: 2 passed, 75 failed, 7 skipped.

Test Results

linux-coverage-integration: 48 passed, 0 skipped
linux-coverage-unit: 173 passed, 0 skipped
linux-sanitizers-integration: 28 passed, 0 skipped
linux-sanitizers-unit: 173 passed, 0 skipped
Total: 422 passed, 0 skipped

Code Coverage

Coverage: 70.2%

No baseline available for comparison

Artifact Sizes

Artifact Size
QGroundControl 252.95 MB
QGroundControl-aarch64 176.89 MB
QGroundControl-installer-AMD64 138.00 MB
QGroundControl-installer-AMD64-ARM64 80.52 MB
QGroundControl-installer-ARM64 109.26 MB
QGroundControl-linux 84.68 MB
QGroundControl-mac 84.65 MB
QGroundControl-x86_64 189.13 MB
No baseline available for comparison

Updated: 2026-08-20 21:15:36 UTC • Commit: ab02585 • Triggered by: Linux

@jnomikos
jnomikos marked this pull request as ready for review August 14, 2026 17:11
Copilot AI balanced review requested due to automatic review settings August 14, 2026 17:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_yaw values.
  • 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.

Comment thread src/Gimbal/GimbalController.cc
Comment thread src/Gimbal/GimbalController.cc Outdated
Comment thread src/Gimbal/GimbalController.cc Outdated
Comment thread src/Gimbal/GimbalController.cc Outdated
Comment thread src/Gimbal/GimbalController.cc Outdated
@jnomikos
jnomikos marked this pull request as draft August 14, 2026 17:29
@jnomikos
jnomikos marked this pull request as ready for review August 14, 2026 20:54
@jnomikos
jnomikos force-pushed the john-delta-yaw branch 2 times, most recently from 0e73d72 to 9cebea8 Compare August 14, 2026 20:58
@DonLakeFlyer DonLakeFlyer added this to the Release V5.1 milestone Aug 18, 2026
@DonLakeFlyer

Copy link
Copy Markdown
Contributor

@jnomikos Can you squash to a single commit?

@jnomikos

Copy link
Copy Markdown
Contributor Author

@jnomikos Can you squash to a single commit?

Sure

@jnomikos

Copy link
Copy Markdown
Contributor Author

@DonLakeFlyer squashed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants