Skip to content

Add three new MSP2 commands for GCS-initiated flight control#11462

Open
danarrib wants to merge 2 commits intoiNavFlight:maintenance-9.xfrom
danarrib:bulletgcss/msp-set-wp-index-and-altitude
Open

Add three new MSP2 commands for GCS-initiated flight control#11462
danarrib wants to merge 2 commits intoiNavFlight:maintenance-9.xfrom
danarrib:bulletgcss/msp-set-wp-index-and-altitude

Conversation

@danarrib
Copy link
Copy Markdown
Contributor

Adds three new write-only MSP2 commands that allow a ground control station to interact with an active INAV navigation session without requiring direct RC transmitter input:

MSP2_INAV_SET_WP_INDEX (0x2221)
Jump to a specific waypoint during an active WP mission.
Payload: U8 wp_index (0-based, relative to mission start waypoint).
Preconditions: aircraft must be armed and NAV_WP_MODE must be active.
Transitions any active waypoint FSM state back to PRE_ACTION so
INAV re-initialises navigation for the new target waypoint.

MSP2_INAV_SET_ALT_TARGET (0x2222)
Set a new target altitude while altitude-controlled navigation is active.
Payload: I32 altitude_cm (centimetres, relative to home).
Preconditions: aircraft must be armed and NAV_CTL_ALT must be active.
Calls updateClimbRateToAltitudeController() which works for both
multicopter and fixed-wing platforms.

MSP2_INAV_SET_CRUISE_HEADING (0x2223)
Set the heading target while Cruise or Course Hold mode is active.
Payload: I32 heading_centidegrees (0–35999).
Preconditions: aircraft must be armed and NAV_COURSE_HOLD_MODE must
be active. Sets both posControl.cruise.course and previousCourse to
prevent spurious heading adjustments on the next control cycle.

Implementation details:

  • New FSM event NAV_FSM_EVENT_SWITCH_TO_WAYPOINT_JUMP aliases NAV_FSM_EVENT_STATE_SPECIFIC_4 (safe: WP and RTH states never overlap so the same underlying integer can be reused in both groups).
  • FSM transitions added for PRE_ACTION, IN_PROGRESS, REACHED, HOLD_TIME and FINISHED states, all routing to PRE_ACTION.
  • Three new public functions declared in navigation.h and implemented in navigation.c: navSetActiveWaypointIndex(), navSetDesiredAltitude(), navSetCruiseHeading().
  • MSP handlers added in fc_msp.c; all return MSP_RESULT_ERROR if the aircraft is not in a compatible state.

sensei-hacker and others added 2 commits March 22, 2026 14:25
Adds three new write-only MSP2 commands that allow a ground control
station to interact with an active INAV navigation session without
requiring direct RC transmitter input:

  MSP2_INAV_SET_WP_INDEX (0x2221)
    Jump to a specific waypoint during an active WP mission.
    Payload: U8 wp_index (0-based, relative to mission start waypoint).
    Preconditions: aircraft must be armed and NAV_WP_MODE must be active.
    Transitions any active waypoint FSM state back to PRE_ACTION so
    INAV re-initialises navigation for the new target waypoint.

  MSP2_INAV_SET_ALT_TARGET (0x2222)
    Set a new target altitude while altitude-controlled navigation is active.
    Payload: I32 altitude_cm (centimetres, relative to home).
    Preconditions: aircraft must be armed and NAV_CTL_ALT must be active.
    Calls updateClimbRateToAltitudeController() which works for both
    multicopter and fixed-wing platforms.

  MSP2_INAV_SET_CRUISE_HEADING (0x2223)
    Set the heading target while Cruise or Course Hold mode is active.
    Payload: I32 heading_centidegrees (0–35999).
    Preconditions: aircraft must be armed and NAV_COURSE_HOLD_MODE must
    be active. Sets both posControl.cruise.course and previousCourse to
    prevent spurious heading adjustments on the next control cycle.

Implementation details:
  - New FSM event NAV_FSM_EVENT_SWITCH_TO_WAYPOINT_JUMP aliases
    NAV_FSM_EVENT_STATE_SPECIFIC_4 (safe: WP and RTH states never
    overlap so the same underlying integer can be reused in both groups).
  - FSM transitions added for PRE_ACTION, IN_PROGRESS, REACHED,
    HOLD_TIME and FINISHED states, all routing to PRE_ACTION.
  - Three new public functions declared in navigation.h and implemented
    in navigation.c: navSetActiveWaypointIndex(), navSetDesiredAltitude(),
    navSetCruiseHeading().
  - MSP handlers added in fc_msp.c; all return MSP_RESULT_ERROR if the
    aircraft is not in a compatible state.
@github-actions
Copy link
Copy Markdown

Branch Targeting Suggestion

You've targeted the master branch with this PR. Please consider if a version branch might be more appropriate:

  • maintenance-9.x - If your change is backward-compatible and won't create compatibility issues between INAV firmware and Configurator 9.x versions. This will allow your PR to be included in the next 9.x release.

  • maintenance-10.x - If your change introduces compatibility requirements between firmware and configurator that would break 9.x compatibility. This is for PRs which will be included in INAV 10.x

If master is the correct target for this change, no action is needed.


This is an automated suggestion to help route contributions to the appropriate branch.

@danarrib danarrib changed the base branch from master to maintenance-9.x March 29, 2026 16:33
@danarrib
Copy link
Copy Markdown
Contributor Author

danarrib commented Mar 29, 2026

Just a little bit of context:

Bullet GCSS (my internet-based Ground Station System) will have this feature of setting a new altitude, a new course and jump for waypoints during a mission.

image

@github-actions
Copy link
Copy Markdown

Test firmware build ready — commit 216b76c

Download firmware for PR #11462

228 targets built. Find your board's .hex file by name on that page (e.g. MATEKF405SE.hex). Files are individually downloadable — no GitHub login required.

Development build for testing only. Use Full Chip Erase when flashing.

@sensei-hacker
Copy link
Copy Markdown
Member

@stronnag and @xznhj8129 have some deeper knowledge of MSP and any potential traps. Do either of you have any comment?

@xznhj8129
Copy link
Copy Markdown
Contributor

Oh this is awesome work you're doing, but we just did add SET_ALT_TARGET and SET_HEAD in 10.x #11230
https://github.com/iNavFlight/inav/tree/maintenance-10.x/docs/development/msp#msp2_inav_set_alt_target
https://github.com/iNavFlight/inav/tree/maintenance-10.x/docs/development/msp#msp_set_head I know this used to do nothing in cruise mode, but i updated it
https://github.com/iNavFlight/inav/pull/11230/changes#diff-e67741f944e959c3f68a81189a5fcd8be50f5e4e567c1fc68f50ac5e86d0a233L1962
Only MSP2_INAV_SET_WP_INDEX be new, that would be handy. I think you missed them because you are targeting 9.x-maintenance.

@danarrib
Copy link
Copy Markdown
Contributor Author

Oh this is awesome work you're doing, but we just did add SET_ALT_TARGET and SET_HEAD in 10.x #11230 https://github.com/iNavFlight/inav/tree/maintenance-10.x/docs/development/msp#msp2_inav_set_alt_target https://github.com/iNavFlight/inav/tree/maintenance-10.x/docs/development/msp#msp_set_head I know this used to do nothing in cruise mode, but i updated it https://github.com/iNavFlight/inav/pull/11230/changes#diff-e67741f944e959c3f68a81189a5fcd8be50f5e4e567c1fc68f50ac5e86d0a233L1962 Only MSP2_INAV_SET_WP_INDEX be new, that would be handy. I think you missed them because you are targeting 9.x-maintenance.

Ok, that's nice.

Yeah, I'm targeting 9.x-maintenance because none of the changes are breaking changes, so they could slip into a minor or patch release just fine.

What do you suggest me to do?

Should I change this PR to just add the MSP2_INAV_SET_WP_INDEX, and remove the other 2 commands (and then we wait for version 10 to use the feature)?

@xznhj8129
Copy link
Copy Markdown
Contributor

Ah i'm not sure myself, i struggle sometimes to figure out what's breaking or not, i targeted 10 to stay safe; maybe @sensei-hacker could enlighten us? I wonder if we could patch in the 10x part for next update

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants