Skip to content

Commit

Permalink
Rover: Change the IF statement to a SWITCH statement
Browse files Browse the repository at this point in the history
  • Loading branch information
muramura committed May 8, 2024
1 parent 8c91077 commit 2f73f8c
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions Rover/mode_auto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -626,16 +626,27 @@ void ModeAuto::exit_mission()
// send message
gcs().send_text(MAV_SEVERITY_NOTICE, "Mission Complete");

if (g2.mis_done_behave == MIS_DONE_BEHAVE_LOITER && start_loiter()) {
return;
}
switch (g2.mis_done_behave) {
case MIS_DONE_BEHAVE_LOITER:
if (start_loiter()) {
return;
}
break;

if (g2.mis_done_behave == MIS_DONE_BEHAVE_ACRO && rover.set_mode(rover.mode_acro, ModeReason::MISSION_END)) {
return;
}
case MIS_DONE_BEHAVE_ACRO:
if (rover.set_mode(rover.mode_acro, ModeReason::MISSION_END)) {
return;
}
break;

if (g2.mis_done_behave == MIS_DONE_BEHAVE_MANUAL && rover.set_mode(rover.mode_manual, ModeReason::MISSION_END)) {
return;
case MIS_DONE_BEHAVE_MANUAL:
if (rover.set_mode(rover.mode_manual, ModeReason::MISSION_END)) {
return;
}
break;

default:
break;
}

start_stop();
Expand Down

0 comments on commit 2f73f8c

Please sign in to comment.