AC_Fence: Add common auto enable and auto disable
This commit is contained in:
parent
2a9affe517
commit
b6d29d746b
@ -160,6 +160,42 @@ void AC_Fence::disable_floor()
|
||||
clear_breach(AC_FENCE_TYPE_ALT_MIN);
|
||||
}
|
||||
|
||||
/*
|
||||
called when an auto-takeoff is complete
|
||||
*/
|
||||
void AC_Fence::auto_enable_fence_after_takeoff(void)
|
||||
{
|
||||
switch(auto_enabled()) {
|
||||
case AC_Fence::AutoEnable::ALWAYS_ENABLED:
|
||||
case AC_Fence::AutoEnable::ENABLE_DISABLE_FLOOR_ONLY:
|
||||
enable(true);
|
||||
break;
|
||||
default:
|
||||
// fence does not auto-enable in other takeoff conditions
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
called when performing an auto landing
|
||||
*/
|
||||
void AC_Fence::auto_disable_fence_for_landing(void)
|
||||
{
|
||||
switch (auto_enabled()) {
|
||||
case AC_Fence::AutoEnable::ALWAYS_ENABLED:
|
||||
enable(false);
|
||||
gcs().send_text(MAV_SEVERITY_NOTICE, "Fence disabled (auto disable)");
|
||||
break;
|
||||
case AC_Fence::AutoEnable::ENABLE_DISABLE_FLOOR_ONLY:
|
||||
disable_floor();
|
||||
gcs().send_text(MAV_SEVERITY_NOTICE, "Fence floor disabled (auto disable)");
|
||||
break;
|
||||
default:
|
||||
// fence does not auto-disable in other landing conditions
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool AC_Fence::present() const
|
||||
{
|
||||
const auto enabled_fences = _enabled_fences.get();
|
||||
|
@ -74,6 +74,12 @@ public:
|
||||
/// disable_floor - allows fence floor to be enabled/disabled. Note this does not update the eeprom saved value
|
||||
void disable_floor();
|
||||
|
||||
/// auto_enable_fence_on_takeoff - auto enables the fence. Called after takeoff conditions met
|
||||
void auto_enable_fence_after_takeoff();
|
||||
|
||||
/// auto_disable_fence_for_landing - auto disables respective fence. Called prior to landing.
|
||||
void auto_disable_fence_for_landing();
|
||||
|
||||
/// enabled - returns true if fence is enabled
|
||||
bool enabled() const { return _enabled; }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user