Copter: simplify home distance and bearing calculation

This commit is contained in:
Pierre Kancir 2018-07-25 17:54:12 +02:00 committed by Randy Mackay
parent f78ffefd66
commit 1aeb9446c0

View File

@ -14,9 +14,7 @@ void Copter::run_nav_updates(void)
uint32_t Copter::home_distance()
{
if (position_ok()) {
const Vector3f home = pv_location_to_vector(ahrs.get_home());
const Vector3f curr = inertial_nav.get_position();
_home_distance = get_horizontal_distance_cm(curr, home);
_home_distance = get_distance_cm(current_loc, ahrs.get_home());
}
return _home_distance;
}
@ -25,9 +23,7 @@ uint32_t Copter::home_distance()
int32_t Copter::home_bearing()
{
if (position_ok()) {
const Vector3f home = pv_location_to_vector(ahrs.get_home());
const Vector3f curr = inertial_nav.get_position();
_home_bearing = get_bearing_cd(curr,home);
_home_bearing = get_bearing_cd(current_loc, ahrs.get_home());
}
return _home_bearing;
}