Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

APM_Control: Plane controllers: only autotune if not in assisted flight #21732

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion libraries/APM_Control/AP_PitchController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#include "AP_PitchController.h"
#include <AP_AHRS/AP_AHRS.h>

#include <../ArduPlane/quadplane.h>

extern const AP_HAL::HAL& hal;

const AP_Param::GroupInfo AP_PitchController::var_info[] = {
Expand Down Expand Up @@ -207,7 +209,14 @@ float AP_PitchController::_get_rate_out(float desired_rate, float scaler, bool d
// remember the last output to trigger the I limit
_last_out = out;

if (autotune != nullptr && autotune->running && aspeed > aparm.airspeed_min) {
// Only run autotune if in un-assisted forward flight
#if HAL_QUADPLANE_ENABLED
const bool assisted_flight = QuadPlane::get_singleton()->in_assisted_flight();
#else
const bool assisted_flight = false;
#endif

if (autotune != nullptr && autotune->running && aspeed > aparm.airspeed_min && !assisted_flight) {
// let autotune have a go at the values
autotune->update(pinfo, scaler, angle_err_deg);
}
Expand Down
11 changes: 10 additions & 1 deletion libraries/APM_Control/AP_RollController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#include "AP_RollController.h"
#include <AP_AHRS/AP_AHRS.h>

#include <../ArduPlane/quadplane.h>

extern const AP_HAL::HAL& hal;

const AP_Param::GroupInfo AP_RollController::var_info[] = {
Expand Down Expand Up @@ -195,7 +197,14 @@ float AP_RollController::_get_rate_out(float desired_rate, float scaler, bool di
// remember the last output to trigger the I limit
_last_out = out;

if (autotune != nullptr && autotune->running && aspeed > aparm.airspeed_min) {
// Only run autotune if in un-assisted forward flight
#if HAL_QUADPLANE_ENABLED
const bool assisted_flight = QuadPlane::get_singleton()->in_assisted_flight();
#else
const bool assisted_flight = false;
#endif

if (autotune != nullptr && autotune->running && aspeed > aparm.airspeed_min && !assisted_flight) {
// let autotune have a go at the values
autotune->update(pinfo, scaler, angle_err_deg);
}
Expand Down
11 changes: 10 additions & 1 deletion libraries/APM_Control/AP_YawController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#include "AP_YawController.h"
#include <AP_AHRS/AP_AHRS.h>

#include <../ArduPlane/quadplane.h>

extern const AP_HAL::HAL& hal;

const AP_Param::GroupInfo AP_YawController::var_info[] = {
Expand Down Expand Up @@ -330,7 +332,14 @@ float AP_YawController::get_rate_out(float desired_rate, float scaler, bool disa
// remember the last output to trigger the I limit
_last_out = out;

if (autotune != nullptr && autotune->running && aspeed > aparm.airspeed_min) {
// Only run autotune if in un-assisted forward flight
#if HAL_QUADPLANE_ENABLED
const bool assisted_flight = QuadPlane::get_singleton()->in_assisted_flight();
#else
const bool assisted_flight = false;
#endif

if (autotune != nullptr && autotune->running && aspeed > aparm.airspeed_min && !assisted_flight) {
// fake up an angular error based on a notional time constant of 0.5s
const float angle_err_deg = desired_rate * gains.tau;
// let autotune have a go at the values
Expand Down