fix(navigator): keep course setpoint NaN outside Course mode#27807
Open
mrpollo wants to merge 2 commits into
Open
fix(navigator): keep course setpoint NaN outside Course mode#27807mrpollo wants to merge 2 commits into
mrpollo wants to merge 2 commits into
Conversation
The reposition triplet was zero-initialized at boot and memset after consumption, and mission_item_to_position_setpoint() never wrote the course field, so a finite course (0.0, or stale after leaving Course mode) could leak into published position setpoints. Reset the reposition triplet with reset_position_setpoint() and clear course when converting mission items, so the field is only finite while Course mode commands it. Replaces the consumer-side clear from #27537 with a fix at the source. Signed-off-by: Ramon Roche <mrpollo@gmail.com>
Reverts the hotfix from #27487. The navigator now guarantees the course field is NaN unless Course mode explicitly commands it, so PX4_ISFINITE(course) is again a sufficient trigger for course guidance. Signed-off-by: Ramon Roche <mrpollo@gmail.com>
Contributor
🔎 FLASH Analysispx4_fmu-v5x [Total VM Diff: 16 byte (0 %)]px4_fmu-v6x [Total VM Diff: 16 byte (0 %)]Updated: 2026-07-03T20:51:59 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #27537 and #27487, fixing the course initialization issue at the source so the hotfix guard can be removed.
The
PositionSetpoint.coursefield could end up finite (and get consumed as a course guidance command) in two ways: the reposition triplet was zero-initialized at boot andmemsetafter consumption while none of the reposition command handlers writecourse, andmission_item_to_position_setpoint()updates the current setpoint in place without ever touchingcourse, so a stale value set by Course mode survived a switch to Hold, RTL, or Mission.mission_item_to_position_setpoint()now clearscourseto NaN; mission items never command a course.Loiter::reposition()resets the consumed reposition triplet withreset_position_setpoint()instead ofmemset, and the navigator resets it once at startup, so unset fields (yaw,course) are NaN rather than zero. This replaces the consumer-side clear from fix(navigator): clear course on loiter reposition #27537.GUIDED_COURSEnav state guard from fix(fw_mode_manager): guard course guidance on GUIDED_COURSE nav state #27487: with the navigator guaranteeing NaN semantics,PX4_ISFINITE(course)is again a sufficient trigger in the FW mode manager.Verified in SIH SITL (airplane) at the uORB level: entering Course mode publishes a finite
course, switching back to Hold publishes a LOITER setpoint withcourse = NaN(previously stale finite), and repeatedDO_REPOSITIONcommands produce loiter setpoints withcourse/yaw= NaN on both the first-use and post-consumption paths. Built for px4_sitl_sih and px4_fmu-v6x.Log of the SITL session (the
position_setpoint_triplet.current.coursetransitions are visible in Flight Review; ground roll only, the SIH airplane cannot reach rotation speed): https://logs.px4.io/plot_app?log=d89b1ec6-4cc4-4e92-b115-55a90623052cChangelog Entry
@mahima-yoga this should be the "remaining corner cases" hunt from #27537: the stale-course-after-Course-mode path via
mission_item_to_position_setpoint()was the one left, covered here along with the revert of your guard.