mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-23 18:53:33 +08:00
SensorGps.msg: switch to double precision for lat/lon/alt
To match https://github.com/PX4/PX4-GPSDrivers/pull/132 - adding high precision RTK lat/lon/alt components
This commit is contained in:
committed by
Beat Küng
parent
f82785a322
commit
f000238987
@@ -233,11 +233,11 @@ void sPort_send_GPS_LON(int uart)
|
||||
/* send longitude */
|
||||
/* convert to 30 bit signed magnitude degrees*6E5 with MSb = 1 and bit 30=sign */
|
||||
/* precision is approximately 0.1m */
|
||||
uint32_t iLon = 6E-2 * fabs(s_port_subscription_data->vehicle_gps_position_sub.get().lon);
|
||||
uint32_t iLon = 6E-2 * fabs(s_port_subscription_data->vehicle_gps_position_sub.get().longitude_deg * 1e7);
|
||||
|
||||
iLon |= (1 << 31);
|
||||
|
||||
if (s_port_subscription_data->vehicle_gps_position_sub.get().lon < 0) { iLon |= (1 << 30); }
|
||||
if (s_port_subscription_data->vehicle_gps_position_sub.get().longitude_deg < 0) { iLon |= (1 << 30); }
|
||||
|
||||
sPort_send_data(uart, SMARTPORT_ID_GPS_LON_LAT, iLon);
|
||||
}
|
||||
@@ -246,9 +246,9 @@ void sPort_send_GPS_LAT(int uart)
|
||||
{
|
||||
/* send latitude */
|
||||
/* convert to 30 bit signed magnitude degrees*6E5 with MSb = 0 and bit 30=sign */
|
||||
uint32_t iLat = 6E-2 * fabs(s_port_subscription_data->vehicle_gps_position_sub.get().lat);
|
||||
uint32_t iLat = 6E-2 * fabs(s_port_subscription_data->vehicle_gps_position_sub.get().latitude_deg * 1e7);
|
||||
|
||||
if (s_port_subscription_data->vehicle_gps_position_sub.get().lat < 0) { iLat |= (1 << 30); }
|
||||
if (s_port_subscription_data->vehicle_gps_position_sub.get().latitude_deg < 0) { iLat |= (1 << 30); }
|
||||
|
||||
sPort_send_data(uart, SMARTPORT_ID_GPS_LON_LAT, iLat);
|
||||
}
|
||||
@@ -256,7 +256,7 @@ void sPort_send_GPS_LAT(int uart)
|
||||
void sPort_send_GPS_ALT(int uart)
|
||||
{
|
||||
/* send altitude */
|
||||
uint32_t iAlt = s_port_subscription_data->vehicle_gps_position_sub.get().alt / 10;
|
||||
uint32_t iAlt = static_cast<uint32_t>(s_port_subscription_data->vehicle_gps_position_sub.get().altitude_msl_m * 1e2);
|
||||
sPort_send_data(uart, SMARTPORT_ID_GPS_ALT, iAlt);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user