mirror of https://github.com/ArduPilot/ardupilot
Rover: use enum-class for mission-done behaviours
This commit is contained in:
parent
136e76e5ea
commit
7003647eda
|
@ -384,8 +384,10 @@ public:
|
||||||
// windvane
|
// windvane
|
||||||
AP_WindVane windvane;
|
AP_WindVane windvane;
|
||||||
|
|
||||||
|
#if AP_MISSION_ENABLED
|
||||||
// mission behave
|
// mission behave
|
||||||
AP_Int8 mis_done_behave;
|
AP_Enum<ModeAuto::DoneBehaviour> mis_done_behave;
|
||||||
|
#endif
|
||||||
|
|
||||||
// balance both pitch trim
|
// balance both pitch trim
|
||||||
AP_Float bal_pitch_trim;
|
AP_Float bal_pitch_trim;
|
||||||
|
|
10
Rover/mode.h
10
Rover/mode.h
|
@ -282,11 +282,11 @@ public:
|
||||||
FUNCTOR_BIND_MEMBER(&ModeAuto::verify_command_callback, bool, const AP_Mission::Mission_Command&),
|
FUNCTOR_BIND_MEMBER(&ModeAuto::verify_command_callback, bool, const AP_Mission::Mission_Command&),
|
||||||
FUNCTOR_BIND_MEMBER(&ModeAuto::exit_mission, void)};
|
FUNCTOR_BIND_MEMBER(&ModeAuto::exit_mission, void)};
|
||||||
|
|
||||||
enum Mis_Done_Behave {
|
enum class DoneBehaviour : uint8_t {
|
||||||
MIS_DONE_BEHAVE_HOLD = 0,
|
HOLD = 0,
|
||||||
MIS_DONE_BEHAVE_LOITER = 1,
|
LOITER = 1,
|
||||||
MIS_DONE_BEHAVE_ACRO = 2,
|
ACRO = 2,
|
||||||
MIS_DONE_BEHAVE_MANUAL = 3
|
MANUAL = 3,
|
||||||
};
|
};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -626,16 +626,25 @@ void ModeAuto::exit_mission()
|
||||||
// send message
|
// send message
|
||||||
gcs().send_text(MAV_SEVERITY_NOTICE, "Mission Complete");
|
gcs().send_text(MAV_SEVERITY_NOTICE, "Mission Complete");
|
||||||
|
|
||||||
if (g2.mis_done_behave == MIS_DONE_BEHAVE_LOITER && start_loiter()) {
|
switch ((DoneBehaviour)g2.mis_done_behave) {
|
||||||
return;
|
case DoneBehaviour::HOLD:
|
||||||
}
|
// the default "start_stop" behaviour is used
|
||||||
|
break;
|
||||||
if (g2.mis_done_behave == MIS_DONE_BEHAVE_ACRO && rover.set_mode(rover.mode_acro, ModeReason::MISSION_END)) {
|
case DoneBehaviour::LOITER:
|
||||||
return;
|
if (start_loiter()) {
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
if (g2.mis_done_behave == MIS_DONE_BEHAVE_MANUAL && rover.set_mode(rover.mode_manual, ModeReason::MISSION_END)) {
|
break;
|
||||||
return;
|
case DoneBehaviour::ACRO:
|
||||||
|
if (rover.set_mode(rover.mode_acro, ModeReason::MISSION_END)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case DoneBehaviour::MANUAL:
|
||||||
|
if (rover.set_mode(rover.mode_manual, ModeReason::MISSION_END)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
start_stop();
|
start_stop();
|
||||||
|
|
|
@ -145,7 +145,7 @@ void Rover::init_ardupilot()
|
||||||
|
|
||||||
// boat should loiter after completing a mission to avoid drifting off
|
// boat should loiter after completing a mission to avoid drifting off
|
||||||
if (is_boat()) {
|
if (is_boat()) {
|
||||||
rover.g2.mis_done_behave.set_default(ModeAuto::Mis_Done_Behave::MIS_DONE_BEHAVE_LOITER);
|
rover.g2.mis_done_behave.set_default(uint8_t(ModeAuto::DoneBehaviour::LOITER));
|
||||||
}
|
}
|
||||||
|
|
||||||
// flag that initialisation has completed
|
// flag that initialisation has completed
|
||||||
|
|
Loading…
Reference in New Issue