Plane: move fence disable code to a function to enable reusability
This commit is contained in:
parent
fef8b37b11
commit
4f7ffc5eb1
@ -929,6 +929,7 @@ private:
|
||||
// fence.cpp
|
||||
void fence_check();
|
||||
bool fence_stickmixing() const;
|
||||
void disable_fence_for_landing(void);
|
||||
#endif
|
||||
|
||||
// ArduPlane.cpp
|
||||
|
@ -383,21 +383,8 @@ void Plane::do_land(const AP_Mission::Mission_Command& cmd)
|
||||
}
|
||||
|
||||
#if AC_FENCE == ENABLED
|
||||
switch(fence.auto_enabled()) {
|
||||
case AC_Fence::AutoEnable::ALWAYS_ENABLED:
|
||||
fence.enable(false);
|
||||
gcs().send_text(MAV_SEVERITY_NOTICE, "Fence disabled (auto disable)");
|
||||
break;
|
||||
case AC_Fence::AutoEnable::ENABLE_DISABLE_FLOOR_ONLY:
|
||||
fence.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;
|
||||
}
|
||||
disable_fence_for_landing();
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void Plane::do_landing_vtol_approach(const AP_Mission::Mission_Command& cmd)
|
||||
|
@ -126,4 +126,22 @@ bool Plane::fence_stickmixing(void) const
|
||||
// normal mixing rules
|
||||
return true;
|
||||
}
|
||||
|
||||
void Plane::disable_fence_for_landing(void)
|
||||
{
|
||||
switch (fence.auto_enabled()) {
|
||||
case AC_Fence::AutoEnable::ALWAYS_ENABLED:
|
||||
fence.enable(false);
|
||||
gcs().send_text(MAV_SEVERITY_NOTICE, "Fence disabled (auto disable)");
|
||||
break;
|
||||
case AC_Fence::AutoEnable::ENABLE_DISABLE_FLOOR_ONLY:
|
||||
fence.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;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -1306,7 +1306,9 @@ void QuadPlane::init_qland(void)
|
||||
#if LANDING_GEAR_ENABLED == ENABLED
|
||||
plane.g2.landing_gear.deploy_for_landing();
|
||||
#endif
|
||||
#if AC_FENCE == ENABLED
|
||||
plane.disable_fence_for_landing();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user