Skip to content

Commit

Permalink
AP_TECS: added reset_throttle_I_cruise()
Browse files Browse the repository at this point in the history
for resetting integrator during a fwd transition with min throttle
override
  • Loading branch information
tridge committed Aug 16, 2024
1 parent 70c7a79 commit 23b50ce
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
16 changes: 16 additions & 0 deletions libraries/AP_TECS/AP_TECS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,8 @@ void AP_TECS::_update_throttle_with_airspeed(void)
_last_throttle_dem = _throttle_dem;
}

_throttle_dem_pre_integ = _throttle_dem;

// Sum the components.
_throttle_dem = _throttle_dem + _integTHR_state;

Expand Down Expand Up @@ -914,6 +916,10 @@ void AP_TECS::_update_throttle_without_airspeed(int16_t throttle_nudge, float pi
float cosPhi = sqrtf((rotMat.a.y*rotMat.a.y) + (rotMat.b.y*rotMat.b.y));
float STEdot_dem = _rollComp * (1.0f/constrain_float(cosPhi * cosPhi, 0.1f, 1.0f) - 1.0f);
_throttle_dem = _throttle_dem + STEdot_dem / (_STEdot_max - _STEdot_min) * (_THRmaxf - _THRminf);

// integrator not used without airspeed, but store pre-integrator
// value anyway in case we enable airspeed
_throttle_dem_pre_integ = _throttle_dem;
}

void AP_TECS::_detect_bad_descent(void)
Expand Down Expand Up @@ -1197,6 +1203,16 @@ void AP_TECS::_update_STE_rate_lim(void)
_STEdot_neg_max = - _maxSinkRate * GRAVITY_MSS;
}

// reset throttle integrator to give trim throttle
// used when overriding throttle
void AP_TECS::reset_throttle_I_cruise(void)
{
// get the last throttle output without the integrator
const float nomThr = aparm.throttle_cruise * 0.01f;
// set integrator so that we would have gotten cruise throttle
_integTHR_state = nomThr - _throttle_dem_pre_integ;
}


void AP_TECS::update_pitch_throttle(int32_t hgt_dem_cm,
int32_t EAS_dem_cm,
Expand Down
6 changes: 6 additions & 0 deletions libraries/AP_TECS/AP_TECS.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ class AP_TECS {
_integTHR_state = 0.0;
}

// reset throttle integrator to give trim throttle
void reset_throttle_I_cruise(void);

// return landing sink rate
float get_land_sinkrate(void) const {
return _land_sink;
Expand Down Expand Up @@ -215,6 +218,9 @@ class AP_TECS {
// throttle demand in the range from -1.0 to 1.0, usually positive unless reverse thrust is enabled via _THRminf < 0
float _throttle_dem;

// pre-integrator throttle demand
float _throttle_dem_pre_integ;

// pitch angle demand in radians
float _pitch_dem;

Expand Down

0 comments on commit 23b50ce

Please sign in to comment.