mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-02-25 17:23:56 -04:00
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:
parent
6082b230e8
commit
0b9d10c0f9
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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…
Reference in New Issue
Block a user