mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-22 02:03: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
@@ -152,10 +152,10 @@ void HomePosition::fillLocalHomePos(home_position_s &home, float x, float y, flo
|
||||
|
||||
void HomePosition::fillGlobalHomePos(home_position_s &home, const vehicle_global_position_s &gpos)
|
||||
{
|
||||
fillGlobalHomePos(home, gpos.lat, gpos.lon, gpos.alt);
|
||||
fillGlobalHomePos(home, gpos.lat, gpos.lon, (double)gpos.alt);
|
||||
}
|
||||
|
||||
void HomePosition::fillGlobalHomePos(home_position_s &home, double lat, double lon, float alt)
|
||||
void HomePosition::fillGlobalHomePos(home_position_s &home, double lat, double lon, double alt)
|
||||
{
|
||||
home.lat = lat;
|
||||
home.lon = lon;
|
||||
@@ -189,7 +189,7 @@ void HomePosition::setInAirHomePosition()
|
||||
ref_pos.reproject(home.x - lpos.x, home.y - lpos.y, home_lat, home_lon);
|
||||
|
||||
const float home_alt = gpos.alt + home.z;
|
||||
fillGlobalHomePos(home, home_lat, home_lon, home_alt);
|
||||
fillGlobalHomePos(home, home_lat, home_lon, (double)home_alt);
|
||||
|
||||
setHomePosValid();
|
||||
home.timestamp = hrt_absolute_time();
|
||||
@@ -206,8 +206,8 @@ void HomePosition::setInAirHomePosition()
|
||||
double home_lon;
|
||||
ref_pos.reproject(home.x - lpos.x, home.y - lpos.y, home_lat, home_lon);
|
||||
|
||||
const float home_alt = _gps_alt + home.z;
|
||||
fillGlobalHomePos(home, home_lat, home_lon, home_alt);
|
||||
const double home_alt = _gps_alt + (double)home.z;
|
||||
fillGlobalHomePos(home, home_lat, home_lon, (double)home_alt);
|
||||
|
||||
setHomePosValid();
|
||||
home.timestamp = hrt_absolute_time();
|
||||
@@ -304,9 +304,9 @@ void HomePosition::update(bool set_automatically, bool check_if_changed)
|
||||
sensor_gps_s vehicle_gps_position;
|
||||
_vehicle_gps_position_sub.copy(&vehicle_gps_position);
|
||||
|
||||
_gps_lat = static_cast<double>(vehicle_gps_position.lat) * 1e-7;
|
||||
_gps_lon = static_cast<double>(vehicle_gps_position.lon) * 1e-7;
|
||||
_gps_alt = static_cast<float>(vehicle_gps_position.alt) * 1e-3f;
|
||||
_gps_lat = vehicle_gps_position.latitude_deg;
|
||||
_gps_lon = vehicle_gps_position.longitude_deg;
|
||||
_gps_alt = vehicle_gps_position.altitude_msl_m;
|
||||
_gps_eph = vehicle_gps_position.eph;
|
||||
_gps_epv = vehicle_gps_position.epv;
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ private:
|
||||
static void fillLocalHomePos(home_position_s &home, const vehicle_local_position_s &lpos);
|
||||
static void fillLocalHomePos(home_position_s &home, float x, float y, float z, float heading);
|
||||
static void fillGlobalHomePos(home_position_s &home, const vehicle_global_position_s &gpos);
|
||||
static void fillGlobalHomePos(home_position_s &home, double lat, double lon, float alt);
|
||||
static void fillGlobalHomePos(home_position_s &home, double lat, double lon, double alt);
|
||||
|
||||
uORB::Subscription _vehicle_gps_position_sub{ORB_ID(vehicle_gps_position)};
|
||||
|
||||
@@ -83,7 +83,7 @@ private:
|
||||
bool _gps_position_for_home_valid{false};
|
||||
double _gps_lat{0};
|
||||
double _gps_lon{0};
|
||||
float _gps_alt{0.f};
|
||||
double _gps_alt{0};
|
||||
float _gps_eph{0.f};
|
||||
float _gps_epv{0.f};
|
||||
};
|
||||
|
||||
@@ -136,7 +136,7 @@ int do_baro_calibration(orb_advert_t *mavlink_log_pub)
|
||||
if ((hrt_elapsed_time(&sensor_gps.timestamp) < 1_s)
|
||||
&& (sensor_gps.fix_type >= 2) && (sensor_gps.epv < 100)) {
|
||||
|
||||
float alt = sensor_gps.alt * 0.001f;
|
||||
float alt = (float)sensor_gps.altitude_msl_m;
|
||||
|
||||
if (PX4_ISFINITE(gps_altitude_sum)) {
|
||||
gps_altitude_sum += alt;
|
||||
|
||||
@@ -237,8 +237,8 @@ static float get_sphere_radius()
|
||||
|
||||
if (gps_sub.copy(&gps)) {
|
||||
if (hrt_elapsed_time(&gps.timestamp) < 100_s && (gps.fix_type >= 2) && (gps.eph < 1000)) {
|
||||
const double lat = gps.lat / 1.e7;
|
||||
const double lon = gps.lon / 1.e7;
|
||||
const double lat = gps.latitude_deg;
|
||||
const double lon = gps.longitude_deg;
|
||||
|
||||
// magnetic field data returned by the geo library using the current GPS position
|
||||
return get_mag_strength_gauss(lat, lon);
|
||||
@@ -960,8 +960,8 @@ int do_mag_calibration_quick(orb_advert_t *mavlink_log_pub, float heading_radian
|
||||
|
||||
if (vehicle_gps_position_sub.copy(&gps)) {
|
||||
if ((gps.timestamp != 0) && (gps.eph < 1000)) {
|
||||
latitude = gps.lat / 1.e7f;
|
||||
longitude = gps.lon / 1.e7f;
|
||||
latitude = (float)gps.latitude_deg;
|
||||
longitude = (float)gps.longitude_deg;
|
||||
mag_earth_available = true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user