From cd64ce45ac552e73e37574eee55082f460b6ca5b Mon Sep 17 00:00:00 2001 From: Randy Mackay Date: Mon, 10 Sep 2018 16:25:27 +0900 Subject: [PATCH] Rover: fix calc_steering_to_heading rate_max handling units mix up led to deg/s parameter value being applies as rad/s --- APMrover2/mode.cpp | 5 +++-- APMrover2/mode.h | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/APMrover2/mode.cpp b/APMrover2/mode.cpp index 00b93af73f..2b81898904 100644 --- a/APMrover2/mode.cpp +++ b/APMrover2/mode.cpp @@ -446,14 +446,15 @@ void Mode::calc_steering_from_lateral_acceleration(float lat_accel, bool reverse } // calculate steering output to drive towards desired heading -void Mode::calc_steering_to_heading(float desired_heading_cd, float rate_max, bool reversed) +// rate_max is a maximum turn rate in deg/s. set to zero to use default turn rate limits +void Mode::calc_steering_to_heading(float desired_heading_cd, float rate_max_degs) { // calculate yaw error so it can be used for reporting and slowing the vehicle _yaw_error_cd = wrap_180_cd(desired_heading_cd - ahrs.yaw_sensor); // call heading controller const float steering_out = attitude_control.get_steering_out_heading(radians(desired_heading_cd*0.01f), - rate_max, + radians(rate_max_degs), g2.motors.limit.steer_left, g2.motors.limit.steer_right, rover.G_Dt); diff --git a/APMrover2/mode.h b/APMrover2/mode.h index c5eece3139..51c5698af7 100644 --- a/APMrover2/mode.h +++ b/APMrover2/mode.h @@ -141,7 +141,8 @@ protected: void calc_steering_from_lateral_acceleration(float lat_accel, bool reversed = false); // calculate steering output to drive towards desired heading - void calc_steering_to_heading(float desired_heading_cd, float rate_max, bool reversed = false); + // rate_max is a maximum turn rate in deg/s. set to zero to use default turn rate limits + void calc_steering_to_heading(float desired_heading_cd, float rate_max_degs = 0.0f); // calculates the amount of throttle that should be output based // on things like proximity to corners and current speed