Skip to content

Commit

Permalink
AC_Fence: return failure message
Browse files Browse the repository at this point in the history
  • Loading branch information
rmackay9 committed Mar 25, 2017
1 parent 8171645 commit c1a25c2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion libraries/AC_Fence/AC_Fence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,20 +108,24 @@ uint8_t AC_Fence::get_enabled_fences() const
}

/// pre_arm_check - returns true if all pre-takeoff checks have completed successfully
bool AC_Fence::pre_arm_check() const
bool AC_Fence::pre_arm_check(const char* &fail_msg) const
{
fail_msg = nullptr;

// if not enabled or not fence set-up always return true
if (!_enabled || _enabled_fences == AC_FENCE_TYPE_NONE) {
return true;
}

// check no limits are currently breached
if (_breached_fences != AC_FENCE_TYPE_NONE) {
fail_msg = "vehicle outside fence";
return false;
}

// if we have horizontal limits enabled, check inertial nav position is ok
if ((_enabled_fences & (AC_FENCE_TYPE_CIRCLE | AC_FENCE_TYPE_POLYGON))>0 && !_inav.get_filter_status().flags.horiz_pos_abs && !_inav.get_filter_status().flags.pred_horiz_pos_abs) {
fail_msg = "fence requires position";
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion libraries/AC_Fence/AC_Fence.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class AC_Fence
uint8_t get_enabled_fences() const;

/// pre_arm_check - returns true if all pre-takeoff checks have completed successfully
bool pre_arm_check() const;
bool pre_arm_check(const char* &fail_msg) const;

///
/// methods to check we are within the boundaries and recover
Expand Down

0 comments on commit c1a25c2

Please sign in to comment.