mirror of https://github.com/ArduPilot/ardupilot
Sub: handle MAV_CMD_DO_REPOSITION
This commit is contained in:
parent
1012be95d8
commit
297fcfd777
|
@ -483,6 +483,46 @@ MAV_RESULT GCS_MAVLINK_Sub::handle_command_do_set_roi(const Location &roi_loc)
|
|||
return MAV_RESULT_ACCEPTED;
|
||||
}
|
||||
|
||||
MAV_RESULT GCS_MAVLINK_Sub::handle_command_int_do_reposition(const mavlink_command_int_t &packet)
|
||||
{
|
||||
const bool change_modes = ((int32_t)packet.param2 & MAV_DO_REPOSITION_FLAGS_CHANGE_MODE) == MAV_DO_REPOSITION_FLAGS_CHANGE_MODE;
|
||||
if (!sub.flightmode->in_guided_mode() && !change_modes) {
|
||||
return MAV_RESULT_DENIED;
|
||||
}
|
||||
|
||||
// sanity check location
|
||||
if (!check_latlng(packet.x, packet.y)) {
|
||||
return MAV_RESULT_DENIED;
|
||||
}
|
||||
|
||||
Location request_location;
|
||||
if (!location_from_command_t(packet, request_location)) {
|
||||
return MAV_RESULT_DENIED;
|
||||
}
|
||||
|
||||
if (request_location.sanitize(sub.current_loc)) {
|
||||
// if the location wasn't already sane don't load it
|
||||
return MAV_RESULT_DENIED; // failed as the location is not valid
|
||||
}
|
||||
|
||||
// we need to do this first, as we don't want to change the flight mode unless we can also set the target
|
||||
if (!sub.mode_guided.guided_set_destination(request_location)) {
|
||||
return MAV_RESULT_FAILED;
|
||||
}
|
||||
|
||||
if (!sub.flightmode->in_guided_mode()) {
|
||||
if (!sub.set_mode(Mode::Number::GUIDED, ModeReason::GCS_COMMAND)) {
|
||||
return MAV_RESULT_FAILED;
|
||||
}
|
||||
// the position won't have been loaded if we had to change the flight mode, so load it again
|
||||
if (!sub.mode_guided.guided_set_destination(request_location)) {
|
||||
return MAV_RESULT_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
return MAV_RESULT_ACCEPTED;
|
||||
}
|
||||
|
||||
MAV_RESULT GCS_MAVLINK_Sub::handle_command_int_packet(const mavlink_command_int_t &packet, const mavlink_message_t &msg)
|
||||
{
|
||||
switch(packet.command) {
|
||||
|
@ -496,6 +536,9 @@ MAV_RESULT GCS_MAVLINK_Sub::handle_command_int_packet(const mavlink_command_int_
|
|||
case MAV_CMD_DO_MOTOR_TEST:
|
||||
return handle_MAV_CMD_DO_MOTOR_TEST(packet);
|
||||
|
||||
case MAV_CMD_DO_REPOSITION:
|
||||
return handle_command_int_do_reposition(packet);
|
||||
|
||||
case MAV_CMD_MISSION_START:
|
||||
return handle_MAV_CMD_MISSION_START(packet);
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ protected:
|
|||
MAV_RESULT _handle_command_preflight_calibration(const mavlink_command_int_t &packet, const mavlink_message_t &msg) override;
|
||||
|
||||
MAV_RESULT handle_command_int_packet(const mavlink_command_int_t &packet, const mavlink_message_t &msg) override;
|
||||
MAV_RESULT handle_command_int_do_reposition(const mavlink_command_int_t &packet);
|
||||
|
||||
// override sending of scaled_pressure3 to send on-board temperature:
|
||||
void send_scaled_pressure3() override;
|
||||
|
|
|
@ -320,6 +320,7 @@ public:
|
|||
bool has_manual_throttle() const override { return false; }
|
||||
bool allows_arming(bool from_gcs) const override { return true; }
|
||||
bool is_autopilot() const override { return true; }
|
||||
bool in_guided_mode() const override { return true; }
|
||||
bool guided_limit_check();
|
||||
void guided_limit_init_time_and_pos();
|
||||
void guided_set_angle(const Quaternion &q, float climb_rate_cms, bool use_yaw_rate, float yaw_rate_rads);
|
||||
|
|
Loading…
Reference in New Issue