-
Notifications
You must be signed in to change notification settings - Fork 17.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Support for GPS_STATUS mavlink msg #28517
base: master
Are you sure you want to change the base?
Conversation
This takes a lot of space and should therefore be behind a feature flag |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As @amilcarlucas says, please put this behind a feature flag.
Enable it by default on boards with >2048 kB of flash
@peterbarker |
void AP_GPS::send_mavlink_gps_status(mavlink_channel_t chan) | ||
{ | ||
#if GPS_SATELITES_INFO_ENABLED | ||
mavlink_gps_status_t msg{}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
void AP_GPS::send_mavlink_gps_status(mavlink_channel_t chan) | |
{ | |
#if GPS_SATELITES_INFO_ENABLED | |
mavlink_gps_status_t msg{}; | |
#if AP_GPS_SEND_MAVLINK_GPS_STATUS_ENABLED | |
void AP_GPS::send_mavlink_gps_status(mavlink_channel_t chan) | |
{ | |
mavlink_gps_status_t msg{}; |
- correct spelling of satellite
- move compilation guards to outside of function
- make the define name more descriptive
uint8_t satellites_visible; | ||
uint8_t satellites_used[20]; | ||
uint8_t satellites_elevation[20]; | ||
uint8_t satellites_azimuth[20]; | ||
uint8_t satellites_snr[20]; | ||
uint8_t satellites_prn[20]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uint8_t satellites_visible; | |
uint8_t satellites_used[20]; | |
uint8_t satellites_elevation[20]; | |
uint8_t satellites_azimuth[20]; | |
uint8_t satellites_snr[20]; | |
uint8_t satellites_prn[20]; | |
struct { | |
uint8_t visible; | |
uint8_t used[20]; | |
uint8_t elevation[20]; | |
uint8_t azimuth[20]; | |
uint8_t snr[20]; | |
uint8_t prn[20]; | |
} satellites; |
The constant 20 here is dubious; Needs to be a lot bigger than that. Also needs to be a define.
We probably want to actually dynamically allocate the structure used to hold the sv if the user asks for the information to be streamed from the autopilot.
state.satellites_visible = _gsv.num_gps + _gsv.num_glonass + _gsv.num_galileo + _gsv.num_baidou + _gsv.num_others; | ||
} | ||
for (int y = 0; y < end; y++) { | ||
state.satellites_prn[y + (_gsv.this_page_num - 1) * 4] = _gsv.svid[y]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a buffer-overflow in the making here.
Create a variable to contain the offset, constrain when it is used to actually index the array.
} | ||
} | ||
} | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#endif | |
#endif // AP_GPS_NMEA_SATELITES_INFO_ENABLED |
@@ -734,6 +779,49 @@ void AP_GPS_NMEA::parse_agrica_field(uint16_t term_number, const char *term) | |||
} | |||
} | |||
|
|||
#if AP_GPS_NMEA_SATELITES_INFO_ENABLED |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#if AP_GPS_NMEA_SATELITES_INFO_ENABLED | |
#if AP_GPS_NMEA_SATELLITES_INFO_ENABLED |
similarly elsewhere
@@ -1021,6 +1021,7 @@ ap_message GCS_MAVLINK::mavlink_id_to_ap_message_id(const uint32_t mavlink_id) c | |||
{ MAVLINK_MSG_ID_RC_CHANNELS_RAW, MSG_RC_CHANNELS_RAW}, | |||
#endif | |||
{ MAVLINK_MSG_ID_RAW_IMU, MSG_RAW_IMU}, | |||
{ MAVLINK_MSG_ID_GPS_STATUS, MSG_GPS_STATUS}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{ MAVLINK_MSG_ID_GPS_STATUS, MSG_GPS_STATUS}, | |
#if ... | |
{ MAVLINK_MSG_ID_GPS_STATUS, MSG_GPS_STATUS}, |
@@ -6339,6 +6340,11 @@ bool GCS_MAVLINK::try_send_message(const enum ap_message id) | |||
send_raw_imu(); | |||
break; | |||
|
|||
case MSG_GPS_STATUS: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
case MSG_GPS_STATUS: | |
#if ... | |
case MSG_GPS_STATUS: |
@@ -278,6 +278,7 @@ static const ap_message STREAM_EXTENDED_STATUS_msgs[] = { | |||
MSG_NAV_CONTROLLER_OUTPUT, | |||
MSG_GPS_RAW, | |||
MSG_GPS_RTK, | |||
MSG_GPS_STATUS, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't stream this by default - way too much data for a normal telemetry link.
MSG_GPS_STATUS, |
There are many ways a user could request this information from the autopilot as required - for example, a hypothetical satellites view in MissionPlanner could poke the autopilot to start sending it the data (and the autopilot would then make dynamic allocations to start collecting the data from the GPS device.
} | ||
break; | ||
} | ||
state.satellites_used[i] = static_cast<uint8_t>(_buffer.sat.sat_block[i].flags & 0x01); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, no relevant constraint placed upon the value used to index into the array; need one.
When using the ubx and NMEA protocols, satellite information is parsed and broadcasted via the GPS_STATUS MAVLink message.
I have also developed support for the SBF protocol but did not include it due to its high bandwidth requirements. However, it can be added upon request.