SITL: replace location_offset() and get_distance() function calls with Location object member function calls

This allows removing duplicated code
This commit is contained in:
Dr.-Ing. Amilcar do Carmo Lucas 2019-02-25 01:16:28 +01:00 committed by Peter Barker
parent 6082b230e8
commit 0b9d10c0f9
3 changed files with 6 additions and 6 deletions

View File

@ -190,10 +190,10 @@ void ADSB::send_report(void)
ADSB_Vehicle &vehicle = vehicles[i];
Location loc = home;
location_offset(loc, vehicle.position.x, vehicle.position.y);
loc.offset(vehicle.position.x, vehicle.position.y);
// re-init when exceeding radius range
if (get_distance(home, loc) > _sitl->adsb_radius_m) {
if (home.get_distance(loc) > _sitl->adsb_radius_m) {
vehicle.initialised = false;
}

View File

@ -180,7 +180,7 @@ bool Aircraft::on_ground() const
void Aircraft::update_position(void)
{
location = home;
location_offset(location, position.x, position.y);
location.offset(position.x, position.y);
location.alt = static_cast<int32_t>(home.alt - position.z * 100.0f);
@ -683,7 +683,7 @@ void Aircraft::smooth_sensors(void)
smoothing.position += smoothing.velocity_ef * delta_time;
smoothing.location = home;
location_offset(smoothing.location, smoothing.position.x, smoothing.position.y);
smoothing.location.offset(smoothing.position.x, smoothing.position.y);
smoothing.location.alt = static_cast<int32_t>(home.alt - smoothing.position.z * 100.0f);
smoothing.last_update_us = now;

View File

@ -306,9 +306,9 @@ bool XPlane::receive_data(void)
accel_earth.z += GRAVITY_MSS;
// the position may slowly deviate due to float accuracy and longitude scaling
if (get_distance(loc, location) > 4 || abs(loc.alt - location.alt)*0.01f > 2.0f) {
if (loc.get_distance(location) > 4 || abs(loc.alt - location.alt)*0.01f > 2.0f) {
printf("X-Plane home reset dist=%f alt=%.1f/%.1f\n",
get_distance(loc, location), loc.alt*0.01f, location.alt*0.01f);
loc.get_distance(location), loc.alt*0.01f, location.alt*0.01f);
// reset home location
position_zero(-pos.x, -pos.y, -pos.z);
home.lat = loc.lat;