AC_Fence: rename check_destination_within_fence and accept distances in meters

This commit is contained in:
Randy Mackay 2016-05-19 17:31:36 +09:00
parent bc22419286
commit 4829dbb55d
2 changed files with 6 additions and 7 deletions

View File

@ -197,17 +197,16 @@ uint8_t AC_Fence::check_fence(float curr_alt)
//outside = Polygon_outside(location, &geofence_state->boundary[1], geofence_state->num_points-1);
}
/// check_fence_guided - returns false if the destination waypoint is outside the fence
// returns true if the guided waypoint is within the fence
bool AC_Fence::check_fence_location(float destination_alt, float home_destination_distance)
// returns true if the destination is within fence (used to reject waypoints outside the fence)
bool AC_Fence::check_destination_within_fence(float dest_alt, float dest_distance_to_home)
{
// Altitude fence check
if ((get_enabled_fences() & AC_FENCE_TYPE_ALT_MAX) && (round(destination_alt*0.01f) >= _alt_max)) {
if ((get_enabled_fences() & AC_FENCE_TYPE_ALT_MAX) && (dest_alt >= _alt_max)) {
return false;
}
// Circular fence check
if ((get_enabled_fences() & AC_FENCE_TYPE_CIRCLE) && (home_destination_distance*0.01f >= _circle_radius)) {
if ((get_enabled_fences() & AC_FENCE_TYPE_CIRCLE) && (dest_distance_to_home >= _circle_radius)) {
return false;
}

View File

@ -54,8 +54,8 @@ public:
/// curr_alt is the altitude above home in meters
uint8_t check_fence(float curr_alt);
// check_fence_location - returns true if the destination waypoint is within fence
bool check_fence_location(float destination_alt, float home_destination_distance);
// returns true if the destination is within fence (used to reject waypoints outside the fence)
bool check_destination_within_fence(float dest_alt, float dest_distance_to_home);
/// get_breaches - returns bit mask of the fence types that have been breached
uint8_t get_breaches() const { return _breached_fences; }