Skip to content

Append guidance course (navDesiredHeading) to MSP_NAV_STATUS#11665

Open
MartinovEm wants to merge 1 commit into
iNavFlight:maintenance-10.xfrom
MartinovEm:feature/msp-nav-desired-heading
Open

Append guidance course (navDesiredHeading) to MSP_NAV_STATUS#11665
MartinovEm wants to merge 1 commit into
iNavFlight:maintenance-10.xfrom
MartinovEm:feature/msp-nav-desired-heading

Conversation

@MartinovEm

Copy link
Copy Markdown

What

Append one field to the end of MSP_NAV_STATUS:

  • navDesiredHeading (u16, centidegrees [0..36000)) — the nav controller's desired course/track.

New layout: u8 mode | u8 state | u8 activeWpAction | u8 activeWpNumber | u8 error | u16 headingHoldTarget | u16 navDesiredHeading.

Appended at the tail, so existing consumers that parse the 7-byte reply keep working; new consumers read the extra 2 bytes only when the payload is long enough. No new getter — navDesiredHeading is already an exported global, set every nav cycle (wrap_36000(posControl.desiredState.yaw)). Also removes a long-dead commented-out target_bearing line in the same handler.

Why this value specifically

navDesiredHeading is the flight controller's own guidance output — the course it is actively steering toward — and a client cannot compute it itself:

  • In cruise / course-hold there is no waypoint leg at all; the desired track is internal FC state (the course captured at engage, then stick-adjustable). A client has no other source for it.
  • In RTH / direct-to / waypoint nav it's the controller's actual steering command, which can differ from naive geometry (e.g. tail-first handling).

This is the one piece missing from MSP for a faithful desired-track / CDI / HSI course pointer.

Why the related values are deliberately omitted

Cross-track error, bearing-to-destination and distance-to-destination were left out on purpose — a client can already compute them: for a waypoint mission it downloads the mission (MSP_WP) and derives bearing/distance/XTE from its own GPS position and the waypoint lat/lon (planar geometry; sub-metre precision is pointless at these ranges). In the no-waypoint modes there's no leg, so XTE/distance aren't even meaningful — only the course is. MSP_NAV_STATUS is polled often, so it's kept lean: expose only what the consumer cannot calculate.

Note vs the existing field

The existing u16 getHeadingHoldTarget() (bytes 5-6) is the commanded heading (heading-hold target). The new navDesiredHeading is the desired course/track toward the active leg — complementary, not a duplicate.

Compatibility

Purely additive — appended at the tail, no existing field moved. Consumers should gate display on mode/state (the value is stale when no nav mode is active).

Testing

Built clean on INAV SITL with -DWARNINGS_AS_ERRORS=ON.

@qodo-code-review

Copy link
Copy Markdown
Contributor

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@b14ckyy

b14ckyy commented Jun 20, 2026

Copy link
Copy Markdown
Collaborator

Hey @MartinovEm
It would be better if you target the PR towards maintenance-10.x since 9.1 is locked in and only receives bugfixes. We would also need time to test it against different applications to make sure nothing breaks.

Append the nav guidance course/track (navDesiredHeading, centidegrees) as a
u16 at the end of MSP_NAV_STATUS. It is the flight controller's own desired
course output and is not derivable by a client (see PR description). It is an
already-maintained exported global, so no new getter is added, and it is
appended at the tail, so existing consumers that read the old 7-byte reply are
unaffected.

Also remove the long-dead commented-out target_bearing write.
@MartinovEm MartinovEm force-pushed the feature/msp-nav-desired-heading branch from e2a0a8c to 0d97d05 Compare June 20, 2026 21:34
@MartinovEm MartinovEm changed the base branch from release/9.1 to maintenance-10.x June 20, 2026 21:34
@MartinovEm

MartinovEm commented Jun 20, 2026

Copy link
Copy Markdown
Author

Thanks @b14ckyy — done. Rebased onto maintenance-10.x and switched the PR base to it. Clean rebase (only fc_msp.c touched) and it builds clean on SITL with warnings-as-errors.

@b14ckyy b14ckyy added this to the 10.0 milestone Jun 21, 2026
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.

2 participants