mirror of https://github.com/ArduPilot/ardupilot
GCS_MAVLink: use bitmask based enablement for fences
This commit is contained in:
parent
738586342c
commit
f73154349b
|
@ -16,20 +16,24 @@ MAV_RESULT GCS_MAVLINK::handle_command_do_fence_enable(const mavlink_command_int
|
||||||
return MAV_RESULT_UNSUPPORTED;
|
return MAV_RESULT_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ((uint16_t)packet.param1) {
|
uint8_t fences = AC_FENCE_ALL_FENCES;
|
||||||
case 0: // disable fence
|
if (uint8_t(packet.param2)) {
|
||||||
fence->enable(false);
|
fences = uint8_t(packet.param2);
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (AC_Fence::MavlinkFenceActions(packet.param1)) {
|
||||||
|
case AC_Fence::MavlinkFenceActions::DISABLE_FENCE:
|
||||||
|
fence->enable(false, fences);
|
||||||
return MAV_RESULT_ACCEPTED;
|
return MAV_RESULT_ACCEPTED;
|
||||||
case 1: // enable fence
|
case AC_Fence::MavlinkFenceActions::ENABLE_FENCE:
|
||||||
if (!fence->present())
|
if (!(fence->present() & fences)) {
|
||||||
{
|
|
||||||
return MAV_RESULT_FAILED;
|
return MAV_RESULT_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
fence->enable(true);
|
fence->enable(true, fences);
|
||||||
return MAV_RESULT_ACCEPTED;
|
return MAV_RESULT_ACCEPTED;
|
||||||
case 2: // disable fence floor only
|
case AC_Fence::MavlinkFenceActions::DISABLE_ALT_MIN_FENCE:
|
||||||
fence->disable_floor();
|
fence->enable(false, AC_FENCE_TYPE_ALT_MIN);
|
||||||
return MAV_RESULT_ACCEPTED;
|
return MAV_RESULT_ACCEPTED;
|
||||||
default:
|
default:
|
||||||
return MAV_RESULT_FAILED;
|
return MAV_RESULT_FAILED;
|
||||||
|
@ -82,7 +86,7 @@ void GCS_MAVLINK::send_fence_status() const
|
||||||
mavlink_breach_type = FENCE_BREACH_BOUNDARY;
|
mavlink_breach_type = FENCE_BREACH_BOUNDARY;
|
||||||
}
|
}
|
||||||
|
|
||||||
// report on Avoidance liminting
|
// report on Avoidance limiting
|
||||||
uint8_t breach_mitigation = FENCE_MITIGATE_UNKNOWN;
|
uint8_t breach_mitigation = FENCE_MITIGATE_UNKNOWN;
|
||||||
#if AP_AVOIDANCE_ENABLED && !APM_BUILD_TYPE(APM_BUILD_ArduPlane)
|
#if AP_AVOIDANCE_ENABLED && !APM_BUILD_TYPE(APM_BUILD_ArduPlane)
|
||||||
const AC_Avoid* avoid = AC_Avoid::get_singleton();
|
const AC_Avoid* avoid = AC_Avoid::get_singleton();
|
||||||
|
|
Loading…
Reference in New Issue