From 55e8c781d8161583f5d3fd81ea2e13b975eca37c Mon Sep 17 00:00:00 2001 From: Randy Mackay Date: Sat, 23 Mar 2024 11:41:51 +0900 Subject: [PATCH] AC_PosControl: always update yaw targets --- libraries/AC_AttitudeControl/AC_PosControl.cpp | 9 ++++++--- libraries/AC_AttitudeControl/AC_PosControl.h | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/libraries/AC_AttitudeControl/AC_PosControl.cpp b/libraries/AC_AttitudeControl/AC_PosControl.cpp index e82241ab3c..61265b77c3 100644 --- a/libraries/AC_AttitudeControl/AC_PosControl.cpp +++ b/libraries/AC_AttitudeControl/AC_PosControl.cpp @@ -1231,7 +1231,7 @@ void AC_PosControl::lean_angles_to_accel_xy(float& accel_x_cmss, float& accel_y_ } // calculate_yaw_and_rate_yaw - update the calculated the vehicle yaw and rate of yaw. -bool AC_PosControl::calculate_yaw_and_rate_yaw() +void AC_PosControl::calculate_yaw_and_rate_yaw() { // Calculate the turn rate float turn_rate = 0.0f; @@ -1250,9 +1250,12 @@ bool AC_PosControl::calculate_yaw_and_rate_yaw() if (vel_desired_xy_len > _vel_max_xy_cms * 0.05f) { _yaw_target = degrees(_vel_desired.xy().angle()) * 100.0f; _yaw_rate_target = turn_rate * degrees(100.0f); - return true; + return; } - return false; + + // use the current attitude controller yaw target + _yaw_target = _attitude_control.get_att_target_euler_cd().z; + _yaw_rate_target = 0; } // calculate_overspeed_gain - calculated increased maximum acceleration and jerk if over speed condition is detected diff --git a/libraries/AC_AttitudeControl/AC_PosControl.h b/libraries/AC_AttitudeControl/AC_PosControl.h index 8863125ac4..c47eaa8731 100644 --- a/libraries/AC_AttitudeControl/AC_PosControl.h +++ b/libraries/AC_AttitudeControl/AC_PosControl.h @@ -411,7 +411,7 @@ protected: void lean_angles_to_accel_xy(float& accel_x_cmss, float& accel_y_cmss) const; // calculate_yaw_and_rate_yaw - calculate the vehicle yaw and rate of yaw. - bool calculate_yaw_and_rate_yaw(); + void calculate_yaw_and_rate_yaw(); // calculate_overspeed_gain - calculated increased maximum acceleration and jerk if over speed condition is detected float calculate_overspeed_gain();