diff --git a/ArduCopter/GCS_Mavlink.cpp b/ArduCopter/GCS_Mavlink.cpp index 57918dd3ab..843e1deb7d 100644 --- a/ArduCopter/GCS_Mavlink.cpp +++ b/ArduCopter/GCS_Mavlink.cpp @@ -666,20 +666,11 @@ MAV_RESULT GCS_MAVLINK_Copter::handle_command_int_do_reposition(const mavlink_co return MAV_RESULT_DENIED; } - Location request_location {}; - request_location.lat = packet.x; - request_location.lng = packet.y; - - if (fabsf(packet.z) > LOCATION_ALT_MAX_M) { + Location request_location; + if (!location_from_command_t(packet, request_location)) { return MAV_RESULT_DENIED; } - Location::AltFrame frame; - if (!mavlink_coordinate_frame_to_location_alt_frame((MAV_FRAME)packet.frame, frame)) { - return MAV_RESULT_DENIED; // failed as the location is not valid - } - request_location.set_alt_cm((int32_t)(packet.z * 100.0f), frame); - if (request_location.sanitize(copter.current_loc)) { // if the location wasn't already sane don't load it return MAV_RESULT_DENIED; // failed as the location is not valid