ArduCopter: use an enumeration for the AP_Avoidance recovery action

This commit is contained in:
Peter Barker 2020-08-16 12:12:52 +10:00 committed by Peter Barker
parent 36e6ce6e5e
commit 38122eb35e
2 changed files with 6 additions and 6 deletions

View File

@ -97,7 +97,7 @@ MAV_COLLISION_ACTION AP_Avoidance_Copter::handle_avoidance(const AP_Avoidance::O
return actual_action; return actual_action;
} }
void AP_Avoidance_Copter::handle_recovery(uint8_t recovery_action) void AP_Avoidance_Copter::handle_recovery(RecoveryAction recovery_action)
{ {
// check we are coming out of failsafe // check we are coming out of failsafe
if (copter.failsafe.adsb) { if (copter.failsafe.adsb) {
@ -109,19 +109,19 @@ void AP_Avoidance_Copter::handle_recovery(uint8_t recovery_action)
if (copter.control_mode_reason == ModeReason::AVOIDANCE) { if (copter.control_mode_reason == ModeReason::AVOIDANCE) {
switch (recovery_action) { switch (recovery_action) {
case AP_AVOIDANCE_RECOVERY_REMAIN_IN_AVOID_ADSB: case RecoveryAction::REMAIN_IN_AVOID_ADSB:
// do nothing, we'll stay in the AVOID_ADSB mode which is guided which will loiter forever // do nothing, we'll stay in the AVOID_ADSB mode which is guided which will loiter forever
break; break;
case AP_AVOIDANCE_RECOVERY_RESUME_PREVIOUS_FLIGHTMODE: case RecoveryAction::RESUME_PREVIOUS_FLIGHTMODE:
set_mode_else_try_RTL_else_LAND(prev_control_mode); set_mode_else_try_RTL_else_LAND(prev_control_mode);
break; break;
case AP_AVOIDANCE_RECOVERY_RTL: case RecoveryAction::RTL:
set_mode_else_try_RTL_else_LAND(Mode::Number::RTL); set_mode_else_try_RTL_else_LAND(Mode::Number::RTL);
break; break;
case AP_AVOIDANCE_RECOVERY_RESUME_IF_AUTO_ELSE_LOITER: case RecoveryAction::RESUME_IF_AUTO_ELSE_LOITER:
if (prev_control_mode == Mode::Number::AUTO) { if (prev_control_mode == Mode::Number::AUTO) {
set_mode_else_try_RTL_else_LAND(Mode::Number::AUTO); set_mode_else_try_RTL_else_LAND(Mode::Number::AUTO);
} }

View File

@ -24,7 +24,7 @@ protected:
MAV_COLLISION_ACTION handle_avoidance(const AP_Avoidance::Obstacle *obstacle, MAV_COLLISION_ACTION requested_action) override; MAV_COLLISION_ACTION handle_avoidance(const AP_Avoidance::Obstacle *obstacle, MAV_COLLISION_ACTION requested_action) override;
// override recovery handler // override recovery handler
void handle_recovery(uint8_t recovery_action) override; void handle_recovery(RecoveryAction recovery_action) override;
// check flight mode is avoid_adsb // check flight mode is avoid_adsb
bool check_flightmode(bool allow_mode_change); bool check_flightmode(bool allow_mode_change);