Skip to content

Commit

Permalink
APM_Control: added D_FF support for fixed wing
Browse files Browse the repository at this point in the history
  • Loading branch information
tridge committed Nov 21, 2023
1 parent 60d5e65 commit 69bfe9b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion libraries/APM_Control/AP_AutoTune.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ void AP_AutoTune::update(AP_PIDInfo &pinfo, float scaler, float angle_err_deg)
// filter actuator without I term so we can take ratios without
// accounting for trim offsets. We first need to include the I and
// clip to 45 degrees to get the right value of the real surface
const float clipped_actuator = constrain_float(pinfo.FF + pinfo.P + pinfo.D + pinfo.I, -45, 45) - pinfo.I;
const float clipped_actuator = constrain_float(pinfo.FF + pinfo.P + pinfo.D + pinfo.DFF + pinfo.I, -45, 45) - pinfo.I;
const float actuator = actuator_filter.apply(clipped_actuator);
const float actual_rate = rate_filter.apply(pinfo.actual);

Expand Down
3 changes: 2 additions & 1 deletion libraries/APM_Control/AP_PitchController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,13 +218,14 @@ float AP_PitchController::_get_rate_out(float desired_rate, float scaler, bool d
pinfo.P *= deg_scale;
pinfo.I *= deg_scale;
pinfo.D *= deg_scale;
pinfo.DFF *= deg_scale;

// fix the logged target and actual values to not have the scalers applied
pinfo.target = desired_rate;
pinfo.actual = degrees(rate_y);

// sum components
float out = pinfo.FF + pinfo.P + pinfo.I + pinfo.D;
float out = pinfo.FF + pinfo.P + pinfo.I + pinfo.D + pinfo.DFF;
if (ground_mode) {
// when on ground suppress D and half P term to prevent oscillations
out -= pinfo.D + 0.5*pinfo.P;
Expand Down
3 changes: 2 additions & 1 deletion libraries/APM_Control/AP_RollController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,13 +206,14 @@ float AP_RollController::_get_rate_out(float desired_rate, float scaler, bool di
pinfo.P *= deg_scale;
pinfo.I *= deg_scale;
pinfo.D *= deg_scale;
pinfo.DFF *= deg_scale;

// fix the logged target and actual values to not have the scalers applied
pinfo.target = desired_rate;
pinfo.actual = degrees(rate_x);

// sum components
float out = pinfo.FF + pinfo.P + pinfo.I + pinfo.D;
float out = pinfo.FF + pinfo.P + pinfo.I + pinfo.D + pinfo.DFF;
if (ground_mode) {
// when on ground suppress D term to prevent oscillations
out -= pinfo.D + 0.5*pinfo.P;
Expand Down
3 changes: 2 additions & 1 deletion libraries/APM_Control/AP_YawController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,14 +344,15 @@ float AP_YawController::get_rate_out(float desired_rate, float scaler, bool disa
pinfo.P *= deg_scale;
pinfo.I *= deg_scale;
pinfo.D *= deg_scale;
pinfo.DFF *= deg_scale;
pinfo.limit = limit_I;

// fix the logged target and actual values to not have the scalers applied
pinfo.target = desired_rate;
pinfo.actual = degrees(rate_z);

// sum components
float out = pinfo.FF + pinfo.P + pinfo.I + pinfo.D;
float out = pinfo.FF + pinfo.P + pinfo.I + pinfo.D + pinfo.DFF;

// remember the last output to trigger the I limit
_last_out = out;
Expand Down

0 comments on commit 69bfe9b

Please sign in to comment.