43 static constexpr
float DT_MIN = 0.001f;
44 static constexpr
float DT_MAX = 1.0f;
59 float altitude,
bool vz_valid,
float vz,
float az)
65 bool reset_altitude =
false;
69 reset_altitude =
true;
72 if (!altitude_lock || !in_air) {
73 reset_altitude =
true;
103 float hgt_ddot_mea = -az;
114 float vert_vel_input =
_vert_accel_state + hgt_ddot_mea + hgt_err * omega2 * 3.0f;
116 float vert_pos_input =
_vert_vel_state + hgt_err * _hgt_estimate_freq * 3.0f;
120 if (reset_altitude) {
121 _vert_pos_state = altitude;
124 _vert_pos_state = _vert_pos_state + vert_pos_input *
dt;
134 float speed_deriv_raw = rotMat(2, 0) *
CONSTANTS_ONE_G + accel_body(0);
167 _EAS = indicated_airspeed;
184 tas_rate_state_input =
max(tas_rate_state_input, 0.0
f);
325 float cosPhi = sqrtf((rotMat(0, 1) * rotMat(0, 1)) + (rotMat(1, 1) * rotMat(1, 1)));
333 float throttle_predicted = 0.0f;
335 if (STE_rate_setpoint >= 0) {
420 }
else if (exit_mode) {
443 SKE_weighting = 2.0f;
446 SKE_weighting = 0.0f;
450 float SPE_weighting = 2.0f - SKE_weighting;
473 pitch_integ_input =
min(pitch_integ_input,
477 pitch_integ_input =
max(pitch_integ_input,
583 float EAS_setpoint,
float indicated_airspeed,
float eas_to_tas,
bool climb_out_setpoint,
float pitch_min_climbout,
584 float throttle_min,
float throttle_max,
float throttle_cruise,
float pitch_limit_min,
float pitch_limit_max)
598 _initialize_states(pitch, throttle_cruise, baro_altitude, pitch_min_climbout, eas_to_tas);
constexpr _Tp constrain(_Tp val, _Tp min_val, _Tp max_val)
float _TAS_min
true airpeed demand lower limit (m/sec)
float _pitch_setpoint_unc
pitch demand before limiting (rad)
float _SPE_rate
specific potential energy rate estimate (m**2/sec**3)
float _integrator_gain
integrator gain used by the throttle and pitch demand calculation
float _hgt_rate_setpoint
demanded climb rate tracked by the TECS algorithm
Adapter / shim layer for system calls needed by ECL.
float _vert_vel_state
complimentary filter state - height rate (m/sec)
float _SPE_setpoint
specific potential energy demand (m**2/sec**2)
static constexpr float DT_MAX
max value of _dt allowed before a filter state reset is performed (sec)
float _hgt_setpoint
demanded height tracked by the TECS algorithm (m)
float _height_error_gain
gain from height error to demanded climb rate (1/sec)
float _pitch_setpoint_max
pitch demand upper limit (rad)
float _hgt_setpoint_prev
previous value of _hgt_setpoint after noise filtering and rate limiting (m)
bool _uncommanded_descent_recovery
true when a continuous descent caused by an unachievable airspeed demand has been detected ...
float _vert_accel_limit
magnitude of the maximum vertical acceleration allowed (m/sec**2)
float _tas_rate_state
complimentary filter state - true airspeed first derivative (m/sec**2)
void _update_speed_states(float airspeed_setpoint, float indicated_airspeed, float eas_to_tas)
Update the airspeed internal state using a second order complementary filter.
float _throttle_slewrate
throttle demand slew rate limit (1/sec)
void _detect_underspeed()
Detect if the system is not capable of maintaining airspeed.
Definition of geo / math functions to perform geodesic calculations.
float _min_sink_rate
sink rate produced by min allowed throttle (m/sec)
float _throttle_integ_state
throttle integrator state
uint64_t _pitch_update_timestamp
last timestamp of the pitch function call
bool _climbout_mode_active
true when in climbout mode
static constexpr float DT_MIN
minimum allowed value of _dt (sec)
float _STE_rate_min
specific total energy rate lower limit acheived when throttle is at _throttle_setpoint_min (m**2/sec*...
void _update_throttle_setpoint(float throttle_cruise, const matrix::Dcmf &rotMat)
Update throttle setpoint.
float _throttle_setpoint_min
normalised throttle lower limit
float _SKE_estimate
specific kinetic energy estimate (m**2/sec**2)
float _speed_derivative
rate of change of speed along X axis (m/sec**2)
float _pitch_integ_state
pitch integrator state (rad)
float _STE_rate_error
specific total energy rate error (m**2/sec**3)
float _pitch_damping_gain
damping gain of the pitch demand calculation (sec)
float _tas_state
complimentary filter state - true airspeed (m/sec)
float _pitch_time_constant
control time constant used by the pitch demand calculation (sec)
float _SKE_setpoint
specific kinetic energy demand (m**2/sec**2)
float _indicated_airspeed_min
equivalent airspeed demand lower limit (m/sec)
float _throttle_damping_gain
damping gain of the throttle demand calculation (sec)
static constexpr float CONSTANTS_ONE_G
void _update_pitch_setpoint()
Update the pitch setpoint.
float _TAS_max
true airpeed demand upper limit (m/sec)
#define ecl_absolute_time()
float _pitch_speed_weight
speed control weighting used by pitch demand calculation
float _TAS_setpoint_last
previous true airpeed demand (m/sec)
float _last_throttle_setpoint
throttle demand rate limiter state (1/sec)
float _SKE_rate
specific kinetic energy rate estimate (m**2/sec**3)
uint64_t _state_update_timestamp
last timestamp of the 50 Hz function call
float _STE_error
specific total energy error (m**2/sec**2)
float _max_sink_rate
maximum safe sink rate (m/sec)
float _SEB_error
specific energy balance error (m**2/sec**2)
float _throttle_setpoint_max
normalised throttle upper limit
float _load_factor_correction
gain from normal load factor increase to total energy rate demand (m**2/sec**3)
float _hgt_setpoint_in_prev
previous value of _hgt_setpoint after noise filtering (m)
bool airspeed_sensor_enabled()
Get the current airspeed status.
float _last_pitch_setpoint
pitch demand rate limiter state (rad/sec)
float _pitch_setpoint_min
pitch demand lower limit (rad)
void _initialize_states(float pitch, float throttle_cruise, float baro_altitude, float pitch_min_climbout, float eas_to_tas)
Initialize the controller.
float _TAS_setpoint
current airpeed demand (m/sec)
float _EAS
equivalent airspeed (m/sec)
bool _detect_underspeed_enabled
true when underspeed detection is enabled
float _dt
Time since last update of main TECS loop (sec)
float _SPE_estimate
specific potential energy estimate (m**2/sec**2)
Vector< float, 6 > f(float t, const Matrix< float, 6, 1 > &, const Matrix< float, 3, 1 > &)
bool _in_air
true when the vehicle is flying
float _hgt_setpoint_adj
demanded height used by the control loops after all filtering has been applied (m) ...
float _SEB_rate_error
specific energy balance rate error (m**2/sec**3)
float _height_setpoint_gain_ff
gain from height demand derivative to demanded climb rate
float _pitch_setpoint
pitch angle demand (radians)
float _TAS_rate_setpoint
true airspeed rate demand tracked by the TECS algorithm (m/sec**2)
float _vert_accel_state
complimentary filter state - height second derivative (m/sec**2)
bool _states_initalized
true when TECS states have been iniitalized
constexpr _Tp min(_Tp a, _Tp b)
bool _underspeed_detected
true when an underspeed condition has been detected
float _SPE_rate_setpoint
specific potential energy rate demand (m**2/sec**3)
float _EAS_setpoint
Equivalent airspeed demand (m/sec)
void update_pitch_throttle(const matrix::Dcmf &rotMat, float pitch, float baro_altitude, float hgt_setpoint, float EAS_setpoint, float indicated_airspeed, float eas_to_tas, bool climb_out_setpoint, float pitch_min_climbout, float throttle_min, float throttle_setpoint_max, float throttle_cruise, float pitch_limit_min, float pitch_limit_max)
Update the control loop calculations.
float _STE_rate_max
specific total energy rate upper limit achieved when throttle is at _throttle_setpoint_max (m**2/sec*...
float _hgt_setpoint_adj_prev
value of _hgt_setpoint_adj from previous frame (m)
void _detect_uncommanded_descent()
Detect an uncommanded descent.
void _update_STE_rate_lim()
Calculate specific total energy rate limits.
float _throttle_setpoint
normalized throttle demand (0..1)
constexpr _Tp max(_Tp a, _Tp b)
float _max_climb_rate
climb rate produced by max allowed throttle (m/sec)
void update_vehicle_state_estimates(float airspeed, const matrix::Dcmf &rotMat, const matrix::Vector3f &accel_body, bool altitude_lock, bool in_air, float altitude, bool vz_valid, float vz, float az)
Updates the following vehicle kineamtic state estimates: Vertical position, velocity and acceleration...
float _SKE_rate_setpoint
specific kinetic energy rate demand (m**2/sec**3)
void _update_height_setpoint(float desired, float state)
Update the desired height.
float _TAS_setpoint_adj
true airspeed demand tracked by the TECS algorithm (m/sec)
void _update_speed_setpoint()
Update the desired airspeed.
float _hgt_estimate_freq
cross-over frequency of the height rate complementary filter (rad/sec)
float _throttle_time_constant
control time constant used by the throttle demand calculation (sec)
void _update_energy_estimates()
Update specific energy.
float _tas_estimate_freq
cross-over frequency of the true airspeed complementary filter (rad/sec)
float _speed_error_gain
gain from speed error to demanded speed rate (1/sec)
uint64_t _speed_update_timestamp
last timestamp of the speed function call
float _vert_pos_state
complimentary filter state - height (m)
static constexpr float DT_DEFAULT
default value for _dt (sec)
float _indicated_airspeed_max
equivalent airspeed demand upper limit (m/sec)