From d66e98c0b16b0882c707255e225abbb57b3d1102 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Wed, 11 Sep 2024 12:00:51 +1000 Subject: [PATCH] Rover: ignore set_position_target_global_int pos-target if acc is not masked Co-authored-by: muramura we don't use acceleration if you're trying to move the vehicle, so we shouldn't accept the command it isn't in the "ignore" mask --- Rover/GCS_Mavlink.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/Rover/GCS_Mavlink.cpp b/Rover/GCS_Mavlink.cpp index 6712e3fa059ba0..ef523b8f4c2d84 100644 --- a/Rover/GCS_Mavlink.cpp +++ b/Rover/GCS_Mavlink.cpp @@ -1058,6 +1058,11 @@ void GCS_MAVLINK_Rover::handle_set_position_target_global_int(const mavlink_mess } } + if (!acc_ignore) { + // ignore any command where acceleration is not ignored + return; + } + // set guided mode targets if (!pos_ignore) { // consume position target @@ -1065,19 +1070,22 @@ void GCS_MAVLINK_Rover::handle_set_position_target_global_int(const mavlink_mess // GCS will just need to look at desired location // outputs to see if it having an effect. } - } else if (!vel_ignore && acc_ignore && yaw_ignore && yaw_rate_ignore) { + return; + } + + if (!vel_ignore && yaw_ignore && yaw_rate_ignore) { // consume velocity rover.mode_guided.set_desired_heading_and_speed(target_yaw_cd, speed_dir * target_speed); - } else if (!vel_ignore && acc_ignore && yaw_ignore && !yaw_rate_ignore) { + } else if (!vel_ignore && yaw_ignore && !yaw_rate_ignore) { // consume velocity and turn rate rover.mode_guided.set_desired_turn_rate_and_speed(target_turn_rate_cds, speed_dir * target_speed); - } else if (!vel_ignore && acc_ignore && !yaw_ignore && yaw_rate_ignore) { + } else if (!vel_ignore && !yaw_ignore && yaw_rate_ignore) { // consume velocity rover.mode_guided.set_desired_heading_and_speed(target_yaw_cd, speed_dir * target_speed); - } else if (vel_ignore && acc_ignore && !yaw_ignore && yaw_rate_ignore) { + } else if (vel_ignore && !yaw_ignore && yaw_rate_ignore) { // consume just target heading (probably only skid steering vehicles can do this) rover.mode_guided.set_desired_heading_and_speed(target_yaw_cd, 0.0f); - } else if (vel_ignore && acc_ignore && yaw_ignore && !yaw_rate_ignore) { + } else if (vel_ignore && yaw_ignore && !yaw_rate_ignore) { // consume just turn rate(probably only skid steering vehicles can do this) rover.mode_guided.set_desired_turn_rate_and_speed(target_turn_rate_cds, 0.0f); }