@@ -1103,6 +1103,9 @@ ap_message GCS_MAVLINK::mavlink_id_to_ap_message_id(const uint32_t mavlink_id) c
11031103#endif // AP_AHRS_ENABLED
11041104 { MAVLINK_MSG_ID_VFR_HUD, MSG_VFR_HUD},
11051105#endif
1106+ #if AP_MAVLINK_MSG_GLOBAL_POSITION_ENABLED
1107+ { MAVLINK_MSG_ID_GLOBAL_POSITION_INT, MSG_GLOBAL_POSITION},
1108+ #endif // AP_MAVLINK_MSG_GLOBAL_POSITION_ENABLED
11061109#if AP_MAVLINK_MSG_HWSTATUS_ENABLED
11071110 { MAVLINK_MSG_ID_HWSTATUS, MSG_HWSTATUS},
11081111#endif // AP_MAVLINK_MSG_HWSTATUS_ENABLED
@@ -6131,6 +6134,70 @@ void GCS_MAVLINK::send_global_position_int()
61316134#endif // AP_AHRS_ENABLED
61326135}
61336136
6137+ #if AP_MAVLINK_MSG_GLOBAL_POSITION_ENABLED
6138+ void GCS_MAVLINK::send_global_position ()
6139+ {
6140+ if (send_global_position_next_to_send > 1 ) {
6141+ send_global_position_next_to_send = 0 ;
6142+ }
6143+ if (send_global_position_next_to_send == 0 ) {
6144+ GCS_MAVLINK::send_global_position_primary ();
6145+ } else {
6146+ GCS_MAVLINK::send_global_position_secondary ();
6147+ }
6148+ send_global_position_next_to_send++;
6149+ }
6150+
6151+ void GCS_MAVLINK::send_global_position_primary ()
6152+ {
6153+ const AP_AHRS &ahrs = AP::ahrs ();
6154+
6155+ uint8_t flags = 0 ;
6156+ flags |= GLOBAL_POSITION_PRIMARY;
6157+
6158+ Location loc;
6159+ if (!ahrs.get_location (loc)) {
6160+ flags |= GLOBAL_POSITION_UNHEALTHY;
6161+ }
6162+
6163+ return send_global_position_msg (0 , flags, loc);
6164+ }
6165+
6166+ void GCS_MAVLINK::send_global_position_secondary ()
6167+ {
6168+ const AP_AHRS &ahrs = AP::ahrs ();
6169+
6170+ uint8_t flags = 0 ;
6171+
6172+ Location loc;
6173+ if (!ahrs.get_secondary_position (loc)) {
6174+ flags |= GLOBAL_POSITION_UNHEALTHY;
6175+ }
6176+
6177+ return send_global_position_msg (0 , flags, loc);
6178+ }
6179+
6180+ void GCS_MAVLINK::send_global_position_msg (uint8_t instance, uint8_t flags, const Location &loc)
6181+ {
6182+ mavlink_msg_global_position_send (
6183+ chan,
6184+ 0 , // instance
6185+ AP_HAL::micros (), // time_usec
6186+ GLOBAL_POSITION_ESTIMATOR, // source
6187+ flags,
6188+ loc.lat , // in deg*1e7
6189+ loc.lng , // in deg*1e7
6190+ loc.alt * 0.01 , // AMSL alt in metres
6191+ NaNf, // alt_ellipsoid in m
6192+ NaNf, // standard deviation of horizontal position error
6193+ NaNf // standard deviation of vertical position error
6194+ );
6195+ }
6196+
6197+
6198+
6199+ #endif // AP_MAVLINK_MSG_GLOBAL_POSITION_ENABLED
6200+
61346201#if HAL_MOUNT_ENABLED
61356202void GCS_MAVLINK::send_gimbal_device_attitude_status () const
61366203{
@@ -6439,6 +6506,13 @@ bool GCS_MAVLINK::try_send_message(const enum ap_message id)
64396506 break ;
64406507#endif // AP_AHRS_ENABLED
64416508
6509+ #if AP_MAVLINK_MSG_GLOBAL_POSITION_ENABLED
6510+ case MSG_GLOBAL_POSITION:
6511+ CHECK_PAYLOAD_SIZE (GLOBAL_POSITION);
6512+ send_global_position ();
6513+ break ;
6514+ #endif // AP_MAVLINK_MSG_GLOBAL_POSITION_ENABLED
6515+
64426516#if AP_RPM_ENABLED
64436517 case MSG_RPM:
64446518 CHECK_PAYLOAD_SIZE (RPM);
0 commit comments