AC_Fence: tidy get_breach_distance
The polygon fence will soon be able to supply a breach distance - prepare for that.
This commit is contained in:
parent
6a241cc3e9
commit
a5ec64fc99
@ -421,22 +421,18 @@ void AC_Fence::clear_breach(uint8_t fence_type)
|
||||
_breached_fences &= ~fence_type;
|
||||
}
|
||||
|
||||
/// get_breach_distance - returns distance in meters outside of the given fence
|
||||
/// get_breach_distance - returns maximum distance in meters outside
|
||||
/// of the given fences. fence_type is a bitmask here.
|
||||
float AC_Fence::get_breach_distance(uint8_t fence_type) const
|
||||
{
|
||||
switch (fence_type) {
|
||||
case AC_FENCE_TYPE_ALT_MAX:
|
||||
return _alt_max_breach_distance;
|
||||
break;
|
||||
case AC_FENCE_TYPE_CIRCLE:
|
||||
return _circle_breach_distance;
|
||||
break;
|
||||
case AC_FENCE_TYPE_ALT_MAX | AC_FENCE_TYPE_CIRCLE:
|
||||
return MAX(_alt_max_breach_distance,_circle_breach_distance);
|
||||
float max = 0.0f;
|
||||
if (fence_type & AC_FENCE_TYPE_ALT_MAX) {
|
||||
max = MAX(_alt_max_breach_distance, max);
|
||||
}
|
||||
|
||||
// we don't recognise the fence type so just return 0
|
||||
return 0;
|
||||
if (fence_type & AC_FENCE_TYPE_CIRCLE) {
|
||||
max = MAX(_circle_breach_distance, max);
|
||||
}
|
||||
return max;
|
||||
}
|
||||
|
||||
/// manual_recovery_start - caller indicates that pilot is re-taking manual control so fence should be disabled for 10 seconds
|
||||
|
@ -72,7 +72,8 @@ public:
|
||||
/// get_breach_count - returns number of times we have breached the fence
|
||||
uint16_t get_breach_count() const { return _breach_count; }
|
||||
|
||||
/// get_breach_distance - returns distance in meters outside of the given fence
|
||||
/// get_breach_distance - returns maximum distance in meters outside
|
||||
/// of the given fences. fence_type is a bitmask here.
|
||||
float get_breach_distance(uint8_t fence_type) const;
|
||||
|
||||
/// get_action - getter for user requested action on limit breach
|
||||
|
Loading…
Reference in New Issue
Block a user