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 authored and rmackay9 committed Jul 25, 2024
1 parent 7f97e89 commit 1e001fa
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions Rover/GCS_Mavlink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -856,10 +856,14 @@ void GCS_MAVLINK_Rover::handle_set_position_target_local_ned(const mavlink_messa
}

// check for supported coordinate frames
if (packet.coordinate_frame != MAV_FRAME_LOCAL_NED &&
packet.coordinate_frame != MAV_FRAME_LOCAL_OFFSET_NED &&
packet.coordinate_frame != MAV_FRAME_BODY_NED &&
packet.coordinate_frame != MAV_FRAME_BODY_OFFSET_NED) {
switch (packet.coordinate_frame) {
case MAV_FRAME_LOCAL_NED:
case MAV_FRAME_LOCAL_OFFSET_NED:
case MAV_FRAME_BODY_NED:
case MAV_FRAME_BODY_OFFSET_NED:
break;

default:
return;
}

Expand Down Expand Up @@ -975,14 +979,19 @@ void GCS_MAVLINK_Rover::handle_set_position_target_global_int(const mavlink_mess
return;
}
// check for supported coordinate frames
if (packet.coordinate_frame != MAV_FRAME_GLOBAL &&
packet.coordinate_frame != MAV_FRAME_GLOBAL_INT &&
packet.coordinate_frame != MAV_FRAME_GLOBAL_RELATIVE_ALT &&
packet.coordinate_frame != MAV_FRAME_GLOBAL_RELATIVE_ALT_INT &&
packet.coordinate_frame != MAV_FRAME_GLOBAL_TERRAIN_ALT &&
packet.coordinate_frame != MAV_FRAME_GLOBAL_TERRAIN_ALT_INT) {
switch (packet.coordinate_frame) {
case MAV_FRAME_GLOBAL:
case MAV_FRAME_GLOBAL_INT:
case MAV_FRAME_GLOBAL_RELATIVE_ALT:
case MAV_FRAME_GLOBAL_RELATIVE_ALT_INT:
case MAV_FRAME_GLOBAL_TERRAIN_ALT:
case MAV_FRAME_GLOBAL_TERRAIN_ALT_INT:
break;

default:
return;
}

bool pos_ignore = packet.type_mask & MAVLINK_SET_POS_TYPE_MASK_POS_IGNORE;
bool vel_ignore = packet.type_mask & MAVLINK_SET_POS_TYPE_MASK_VEL_IGNORE;
bool acc_ignore = packet.type_mask & MAVLINK_SET_POS_TYPE_MASK_ACC_IGNORE;
Expand Down

0 comments on commit 1e001fa

Please sign in to comment.