Browse Source

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

This allows removing duplicated code
master
Dr.-Ing. Amilcar do Carmo Lucas 6 years ago committed by Peter Barker
parent
commit
0b9d10c0f9
  1. 4
      libraries/SITL/SIM_ADSB.cpp
  2. 4
      libraries/SITL/SIM_Aircraft.cpp
  3. 4
      libraries/SITL/SIM_XPlane.cpp

4
libraries/SITL/SIM_ADSB.cpp

@ -190,10 +190,10 @@ void ADSB::send_report(void) @@ -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;
}

4
libraries/SITL/SIM_Aircraft.cpp

@ -180,7 +180,7 @@ bool Aircraft::on_ground() const @@ -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) @@ -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;

4
libraries/SITL/SIM_XPlane.cpp

@ -306,9 +306,9 @@ bool XPlane::receive_data(void) @@ -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;

Loading…
Cancel
Save