diff --git a/Rover/mode.cpp b/Rover/mode.cpp index f4bd7dfc30929..9dcbf757bd745 100644 --- a/Rover/mode.cpp +++ b/Rover/mode.cpp @@ -121,11 +121,17 @@ void Mode::get_pilot_desired_steering_and_throttle(float &steering_out, float &t // check for special case of input and output throttle being in opposite directions float throttle_out_limited = g2.motors.get_slew_limited_throttle(throttle_out, rover.G_Dt); - if ((is_negative(throttle_out) != is_negative(throttle_out_limited)) && - ((g.pilot_steer_type == PILOT_STEER_TYPE_DEFAULT) || - (g.pilot_steer_type == PILOT_STEER_TYPE_DIR_REVERSED_WHEN_REVERSING))) { - steering_out *= -1; + if (is_negative(throttle_out) != is_negative(throttle_out_limited)) { + switch (g.pilot_steer_type) { + case PILOT_STEER_TYPE_DEFAULT: + case PILOT_STEER_TYPE_DIR_REVERSED_WHEN_REVERSING: + steering_out *= -1; + break; + default: + break; + } } + throttle_out = throttle_out_limited; } @@ -137,11 +143,17 @@ void Mode::get_pilot_desired_steering_and_speed(float &steering_out, float &spee speed_out = desired_throttle * 0.01f * calc_speed_max(g.speed_cruise, g.throttle_cruise * 0.01f); // check for special case of input and output throttle being in opposite directions float speed_out_limited = g2.attitude_control.get_desired_speed_accel_limited(speed_out, rover.G_Dt); - if ((is_negative(speed_out) != is_negative(speed_out_limited)) && - ((g.pilot_steer_type == PILOT_STEER_TYPE_DEFAULT) || - (g.pilot_steer_type == PILOT_STEER_TYPE_DIR_REVERSED_WHEN_REVERSING))) { - steering_out *= -1; + if (is_negative(speed_out) != is_negative(speed_out_limited)) { + switch (g.pilot_steer_type) { + case PILOT_STEER_TYPE_DEFAULT: + case PILOT_STEER_TYPE_DIR_REVERSED_WHEN_REVERSING: + steering_out *= -1; + break; + default: + break; + } } + speed_out = speed_out_limited; } diff --git a/libraries/AP_Param/AP_Param.cpp b/libraries/AP_Param/AP_Param.cpp index d25e801778ef6..4424e66a9ce4e 100644 --- a/libraries/AP_Param/AP_Param.cpp +++ b/libraries/AP_Param/AP_Param.cpp @@ -2205,23 +2205,33 @@ void AP_Param::set_float(float value, enum ap_var_type var_type) float rounding_addition = 0.01f; // handle variables with standard type IDs - if (var_type == AP_PARAM_FLOAT) { + switch (var_type) { + case AP_PARAM_FLOAT: ((AP_Float *)this)->set(value); - } else if (var_type == AP_PARAM_INT32) { + break; + case AP_PARAM_INT32: { if (value < 0) rounding_addition = -rounding_addition; float v = value+rounding_addition; v = constrain_float(v, INT32_MIN, INT32_MAX); ((AP_Int32 *)this)->set(v); - } else if (var_type == AP_PARAM_INT16) { + break; + } + case AP_PARAM_INT16: { if (value < 0) rounding_addition = -rounding_addition; float v = value+rounding_addition; v = constrain_float(v, INT16_MIN, INT16_MAX); ((AP_Int16 *)this)->set(v); - } else if (var_type == AP_PARAM_INT8) { + break; + } + case AP_PARAM_INT8: { if (value < 0) rounding_addition = -rounding_addition; float v = value+rounding_addition; v = constrain_float(v, INT8_MIN, INT8_MAX); ((AP_Int8 *)this)->set(v); + break; + } + default: + break; } }