mirror of https://github.com/ArduPilot/ardupilot
AC_Fence: Add Pre-Arm check for margin < radius
This commit is contained in:
parent
251ebf9286
commit
85692312ac
|
@ -129,6 +129,11 @@ bool AC_Fence::pre_arm_check_polygon(const char* &fail_msg) const
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!_poly_loader.check_inclusion_circle_margin(_margin)) {
|
||||||
|
fail_msg = "Margin is less than inclusion circle radius";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,6 +144,11 @@ bool AC_Fence::pre_arm_check_circle(const char* &fail_msg) const
|
||||||
fail_msg = "Invalid FENCE_RADIUS value";
|
fail_msg = "Invalid FENCE_RADIUS value";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (_circle_radius < _margin) {
|
||||||
|
fail_msg = "FENCE_MARGIN is less than FENCE_RADIUS";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -865,6 +865,19 @@ bool AC_PolyFence_loader::get_inclusion_circle(uint8_t index, Vector2f ¢er_p
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool AC_PolyFence_loader::check_inclusion_circle_margin(float margin) const
|
||||||
|
{
|
||||||
|
// check circular includes
|
||||||
|
for (uint8_t i=0; i<_num_loaded_circle_inclusion_boundaries; i++) {
|
||||||
|
const InclusionCircle &circle = _loaded_circle_inclusion_boundary[i];
|
||||||
|
if (circle.radius < margin) {
|
||||||
|
// circle radius should never be less than margin
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool AC_PolyFence_loader::validate_fence(const AC_PolyFenceItem *new_items, uint16_t count) const
|
bool AC_PolyFence_loader::validate_fence(const AC_PolyFenceItem *new_items, uint16_t count) const
|
||||||
{
|
{
|
||||||
// validate the fence items...
|
// validate the fence items...
|
||||||
|
|
|
@ -110,6 +110,9 @@ public:
|
||||||
/// center is offsets in cm from EKF origin in NE frame, radius is in meters
|
/// center is offsets in cm from EKF origin in NE frame, radius is in meters
|
||||||
bool get_inclusion_circle(uint8_t index, Vector2f ¢er_pos_cm, float &radius) const;
|
bool get_inclusion_circle(uint8_t index, Vector2f ¢er_pos_cm, float &radius) const;
|
||||||
|
|
||||||
|
// false if margin < fence radius
|
||||||
|
bool check_inclusion_circle_margin(float margin) const;
|
||||||
|
|
||||||
///
|
///
|
||||||
/// mavlink
|
/// mavlink
|
||||||
///
|
///
|
||||||
|
|
Loading…
Reference in New Issue