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

AP_TECS: scale velRateMin correctly with airspeed #25411

Merged
merged 1 commit into from
Jan 8, 2024
Merged
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
16 changes: 13 additions & 3 deletions libraries/AP_TECS/AP_TECS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,11 +470,19 @@ void AP_TECS::_update_speed_demand(void)
// Constrain speed demand, taking into account the load factor
_TAS_dem = constrain_float(_TAS_dem, _TASmin, _TASmax);

// Determine the true cruising airspeed (m/s)
const float TAScruise = 0.01f * (float)aparm.airspeed_cruise_cm * _ahrs.get_EAS2TAS();

// calculate velocity rate limits based on physical performance limits
// provision to use a different rate limit if bad descent or underspeed condition exists
// Use 50% of maximum energy rate to allow margin for total energy contgroller
// Use 50% of maximum energy rate on gain, 90% on dissipation to allow margin for total energy controller
const float velRateMax = 0.5f * _STEdot_max / _TAS_state;
const float velRateMin = 0.5f * _STEdot_min / _TAS_state;
// Maximum permissible rate of deceleration value at max airspeed
const float velRateNegMax = 0.9f * _STEdot_neg_max / _TASmax;
// Maximum permissible rate of deceleration value at cruise speed
const float velRateNegCruise = 0.9f * _STEdot_min / TAScruise;
// Linear interpolation between velocity rate at cruise and max speeds, capped at those speeds
const float velRateMin = linear_interpolate(velRateNegMax, velRateNegCruise, _TAS_state, _TASmax, TAScruise);
const float TAS_dem_previous = _TAS_dem_adj;

// Apply rate limit
Expand Down Expand Up @@ -1163,10 +1171,12 @@ void AP_TECS::_initialise_states(int32_t ptchMinCO_cd, float hgt_afe)

void AP_TECS::_update_STE_rate_lim(void)
{
// Calculate Specific Total Energy Rate Limits
// Calculate Specific Total Energy Rate Limits & deceleration rate bounds
// Keep the 50% energy margin from the original velRate calculation for now
// This is a trivial calculation at the moment but will get bigger once we start adding altitude effects
_STEdot_max = _climb_rate_limit * GRAVITY_MSS;
_STEdot_min = - _minSinkRate * GRAVITY_MSS;
_STEdot_neg_max = - _maxSinkRate * GRAVITY_MSS;
}


Expand Down
7 changes: 4 additions & 3 deletions libraries/AP_TECS/AP_TECS.h
Original file line number Diff line number Diff line change
Expand Up @@ -349,9 +349,10 @@ class AP_TECS {
// pitch demand before limiting
float _pitch_dem_unc;

// Maximum and minimum specific total energy rate limits
float _STEdot_max;
float _STEdot_min;
// Specific total energy rate limits
float _STEdot_max; // Specific total energy rate gain at cruise airspeed & THR_MAX (m/s/s)
float _STEdot_min; // Specific total energy rate loss at cruise airspeed & THR_MIN (m/s/s)
float _STEdot_neg_max; // Specific total energy rate loss at max airspeed & THR_MIN (m/s/s)

// Maximum and minimum floating point throttle limits
float _THRmaxf;
Expand Down