Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AP_Mission: Change the IF statement to a SWITCH statement #26947

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 26 additions & 8 deletions libraries/AP_Mission/AP_Mission.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -413,10 +413,17 @@ bool AP_Mission::start_command(const Mission_Command& cmd)

}

if (cmd.id == MAV_CMD_DO_JUMP || cmd.id == MAV_CMD_JUMP_TAG || cmd.id == MAV_CMD_DO_JUMP_TAG) {
switch (cmd.id) {
case MAV_CMD_DO_JUMP:
case MAV_CMD_JUMP_TAG:
case MAV_CMD_DO_JUMP_TAG:
GCS_SEND_TEXT(MAV_SEVERITY_INFO, "Mission: %u %s %u", cmd.index, cmd.type(), (unsigned)cmd.p1);
} else {
break;

default:
GCS_SEND_TEXT(MAV_SEVERITY_INFO, "Mission: %u %s", cmd.index, cmd.type());
break;

}

switch (cmd.id) {
Expand Down Expand Up @@ -545,13 +552,18 @@ int32_t AP_Mission::get_next_ground_course_cd(int32_t default_angle)
return default_angle;
}
// special handling for nav commands with no target location
if (cmd.id == MAV_CMD_NAV_GUIDED_ENABLE ||
cmd.id == MAV_CMD_NAV_DELAY) {
switch (cmd.id) {
case MAV_CMD_NAV_GUIDED_ENABLE:
case MAV_CMD_NAV_DELAY:
return default_angle;
}
if (cmd.id == MAV_CMD_NAV_SET_YAW_SPEED) {

case MAV_CMD_NAV_SET_YAW_SPEED:
return (_nav_cmd.content.set_yaw_speed.angle_deg * 100);

default:
break;
}

return _nav_cmd.content.location.get_bearing_to(cmd.content.location);
}

Expand All @@ -565,11 +577,17 @@ bool AP_Mission::set_current_cmd(uint16_t index)
// read command to check for DO_LAND_START and DO_RETURN_PATH_START
Mission_Command cmd;
if (read_cmd_from_storage(index, cmd)) {
if (cmd.id == MAV_CMD_DO_LAND_START) {
switch (cmd.id) {
case MAV_CMD_DO_LAND_START:
_flags.in_landing_sequence = true;
break;

} else if (cmd.id == MAV_CMD_DO_RETURN_PATH_START) {
case MAV_CMD_DO_RETURN_PATH_START:
_flags.in_return_path = true;
break;

default:
break;

}
}
Expand Down
Loading