Add two new MSP2 commands for GCS-initiated flight control#11462
Add two new MSP2 commands for GCS-initiated flight control#11462danarrib wants to merge 3 commits intoiNavFlight:maintenance-9.xfrom
Conversation
Maintenance 9.x to master
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.
Branch Targeting SuggestionYou've targeted the
If This is an automated suggestion to help route contributions to the appropriate branch. |
|
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.
|
|
Test firmware build ready — commit Download firmware for PR #11462 228 targets built. Find your board's
|
|
@stronnag and @xznhj8129 have some deeper knowledge of MSP and any potential traps. Do either of you have any comment? |
|
Oh this is awesome work you're doing, but we just did add SET_ALT_TARGET and SET_HEAD in 10.x #11230 |
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)? |
|
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 |
|
Biggest issue recycling the You guys are the experts of course, but my 2 cents on this topic is: We should have a separated command for setting the course direction. What I think we should so is:
What do you guys think? |
I would prefer we keep the |
…lementation The set-altitude functionality is already covered by a more mature existing implementation in INAV. Remove the MSP2_INAV_SET_ALT_TARGET command added in the previous commit, keeping only MSP2_INAV_SET_WP_INDEX (0x2221) and MSP2_INAV_SET_CRUISE_HEADING (0x2223). Removes: define in msp_protocol_v2_inav.h, navSetDesiredAltitude() in navigation.c/.h, the MSP handler in fc_msp.c, and the docs section.
|
I agree now that i know the intent of SET_HEAD, i think we should revert the changes i made to SET_HEAD, so that an old message behaves as it always did. AFAIK cruise mode is the only nav mode where setting a heading would be relevant? All the others are GPS based. And to be clear, this is meant to set the aircraft's ground course, even if the compass heading is different due to ie wind? |
Yes, it's ground course, regardless of heading. |

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_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: