fix(mavlink): select GPS_RAW_INT/GPS2_RAW instance via SENS_GPS_PRIME#27868
Draft
dakejahl wants to merge 1 commit into
Draft
fix(mavlink): select GPS_RAW_INT/GPS2_RAW instance via SENS_GPS_PRIME#27868dakejahl wants to merge 1 commit into
dakejahl wants to merge 1 commit into
Conversation
sensor_gps uORB instance numbering is boot-order dependent for CAN receivers, so GPS_RAW_INT/GPS2_RAW showed a random receiver in dual-GPS setups (e.g. moving base + rover RTK). Resolve the primary from SENS_GPS_PRIME instead, matching the vehicle_gps_position selection including DroneCAN node IDs (2-127). The node ID matching lives in lib/gnss/SensorGpsSelector.hpp and is shared with vehicle_gps_position. Each stream only reports its selected receiver and falls back to NO_GPS keepalives if it has no data. Signed-off-by: Jacob Dahl <dahl.jakejacob@gmail.com>
Contributor
🔎 FLASH Analysispx4_fmu-v5x [Total VM Diff: 360 byte (0.02 %)]px4_fmu-v6x [Total VM Diff: 368 byte (0.02 %)]Updated: 2026-07-10T22:38:26 |
Contributor
Author
|
@wrsolichin want to give this a try? |
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.
GPS_RAW_INTandGPS2_RAWare hardcoded tosensor_gpsinstances 0 and 1. For CAN-connected receivers the instance numbering is a boot-order race, so in a moving-base + rover dual-RTK setup the receiver reported as the "main" GPS is random per boot. This resolves the reported receiver fromSENS_GPS_PRIMEinstead, mirroring thevehicle_gps_positionselection semantics: 0/1 select the uORB instance directly, 2–127 select a DroneCAN receiver by node ID (matched againstdevice_id).GPS_RAW_INTreports the primary,GPS2_RAWthe other receiver, and both re-point live on parameter updates.lib/gnss/SensorGpsSelector.hppshared by both streams, andvehicle_gps_positionnow uses the samenode_id_matches()instead of its own copy of thedevice_iddecode; an unmatched node ID keeps retrying until the receiver enumerates on the bus, using the legacy 0/1 mapping in the meantimeGPS_RAW_INTemits the existing NO_GPS keepalive instead of silently substituting the other receiverSENS_GPS_PRIMEdescription now documents the MAVLink reportingEKF GPS selection is unaffected. Tested in SIH SITL with pymavlink: flipping
SENS_GPS_PRIMElive moves the receiver between the two messages (fix data follows the selection, NO_GPS keepalives on a dataless target), and unmatched node IDs / the default value keep today's behavior.