Plane: support autotune for yaw rate control

This commit is contained in:
Andrew Tridgell 2021-11-25 19:42:08 +11:00 committed by Peter Barker
parent 81d20ae49d
commit 55d8afa1dd
3 changed files with 8 additions and 1 deletions

View File

@ -595,6 +595,11 @@ void Plane::calc_nav_yaw_coordinated(float speed_scaler)
plane.guided_state.last_forced_rpy_ms.z > 0 && plane.guided_state.last_forced_rpy_ms.z > 0 &&
millis() - plane.guided_state.last_forced_rpy_ms.z < 3000) { millis() - plane.guided_state.last_forced_rpy_ms.z < 3000) {
commanded_rudder = plane.guided_state.forced_rpy_cd.z; commanded_rudder = plane.guided_state.forced_rpy_cd.z;
} else if (control_mode == &mode_autotune && g.acro_yaw_rate > 0 && yawController.rate_control_enabled()) {
// user is doing an AUTOTUNE with yaw rate control
const float rudd_expo = rudder_in_expo(true);
const float yaw_rate = (rudd_expo/SERVO_MAX) * g.acro_yaw_rate;
commanded_rudder = yawController.get_rate_out(yaw_rate, speed_scaler, false);
} else { } else {
if (control_mode == &mode_stabilize && rudder_in != 0) { if (control_mode == &mode_stabilize && rudder_in != 0) {
disable_integrator = true; disable_integrator = true;

View File

@ -546,7 +546,7 @@ const AP_Param::Info Plane::var_info[] = {
// @Param: ACRO_YAW_RATE // @Param: ACRO_YAW_RATE
// @DisplayName: ACRO mode yaw rate // @DisplayName: ACRO mode yaw rate
// @Description: The maximum yaw rate at full stick deflection in ACRO mode. If this is zero then rudder is directly controlled by rudder stick input // @Description: The maximum yaw rate at full stick deflection in ACRO mode. If this is zero then rudder is directly controlled by rudder stick input. This option is only available if you also set YAW_RATE_ENABLE to 1.
// @Units: deg/s // @Units: deg/s
// @Range: 0 500 // @Range: 0 500
// @Increment: 1 // @Increment: 1

View File

@ -164,6 +164,7 @@ void Plane::autotune_start(void)
gcs().send_text(MAV_SEVERITY_INFO, "Started autotune"); gcs().send_text(MAV_SEVERITY_INFO, "Started autotune");
rollController.autotune_start(); rollController.autotune_start();
pitchController.autotune_start(); pitchController.autotune_start();
yawController.autotune_start();
} }
/* /*
@ -173,6 +174,7 @@ void Plane::autotune_restore(void)
{ {
rollController.autotune_restore(); rollController.autotune_restore();
pitchController.autotune_restore(); pitchController.autotune_restore();
yawController.autotune_restore();
gcs().send_text(MAV_SEVERITY_INFO, "Stopped autotune"); gcs().send_text(MAV_SEVERITY_INFO, "Stopped autotune");
} }