PX4 Firmware
PX4 Autopilot Software http://px4.io
tecs.h
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * Copyright (c) 2017 Estimation and Control Library (ECL). All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * 1. Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in
13  * the documentation and/or other materials provided with the
14  * distribution.
15  * 3. Neither the name ECL nor the names of its contributors may be
16  * used to endorse or promote products derived from this software
17  * without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
22  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
24  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
25  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
26  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
27  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
29  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30  * POSSIBILITY OF SUCH DAMAGE.
31  *
32  ****************************************************************************/
33 
34 /**
35  * @file tecs.cpp
36  *
37  * @author Paul Riseborough
38  */
39 
40 #pragma once
41 
42 #include <mathlib/mathlib.h>
43 #include <matrix/math.hpp>
44 
45 class TECS
46 {
47 public:
48  TECS() = default;
49  ~TECS() = default;
50 
51  // no copy, assignment, move, move assignment
52  TECS(const TECS &) = delete;
53  TECS &operator=(const TECS &) = delete;
54  TECS(TECS &&) = delete;
55  TECS &operator=(TECS &&) = delete;
56 
57  /**
58  * Get the current airspeed status
59  *
60  * @return true if airspeed is enabled for control
61  */
63 
64  /**
65  * Set the airspeed enable state
66  */
67  void enable_airspeed(bool enabled) { _airspeed_enabled = enabled; }
68 
69  /**
70  * Updates the following vehicle kineamtic state estimates:
71  * Vertical position, velocity and acceleration.
72  * Speed derivative
73  * Must be called prior to udating tecs control loops
74  * Must be called at 50Hz or greater
75  */
76  void update_vehicle_state_estimates(float airspeed, const matrix::Dcmf &rotMat,
77  const matrix::Vector3f &accel_body, bool altitude_lock, bool in_air,
78  float altitude, bool vz_valid, float vz, float az);
79 
80  /**
81  * Update the control loop calculations
82  */
83  void update_pitch_throttle(const matrix::Dcmf &rotMat, float pitch, float baro_altitude, float hgt_setpoint,
84  float EAS_setpoint, float indicated_airspeed, float eas_to_tas, bool climb_out_setpoint, float pitch_min_climbout,
85  float throttle_min, float throttle_setpoint_max, float throttle_cruise,
86  float pitch_limit_min, float pitch_limit_max);
87 
88  float get_throttle_setpoint(void) { return _throttle_setpoint; }
89  float get_pitch_setpoint() { return _pitch_setpoint; }
91 
92  void reset_state() { _states_initalized = false; }
93 
99  };
100 
102 
103  // setters for controller parameters
104  void set_time_const(float time_const) { _pitch_time_constant = time_const; }
105  void set_integrator_gain(float gain) { _integrator_gain = gain; }
106 
107  void set_min_sink_rate(float rate) { _min_sink_rate = rate; }
108  void set_max_sink_rate(float sink_rate) { _max_sink_rate = sink_rate; }
109  void set_max_climb_rate(float climb_rate) { _max_climb_rate = climb_rate; }
110 
111  void set_height_comp_filter_omega(float omega) { _hgt_estimate_freq = omega; }
112  void set_heightrate_ff(float heightrate_ff) { _height_setpoint_gain_ff = heightrate_ff; }
113  void set_heightrate_p(float heightrate_p) { _height_error_gain = heightrate_p; }
114 
115  void set_indicated_airspeed_max(float airspeed) { _indicated_airspeed_max = airspeed; }
116  void set_indicated_airspeed_min(float airspeed) { _indicated_airspeed_min = airspeed; }
117 
118  void set_pitch_damping(float damping) { _pitch_damping_gain = damping; }
119  void set_vertical_accel_limit(float limit) { _vert_accel_limit = limit; }
120 
121  void set_speed_comp_filter_omega(float omega) { _tas_estimate_freq = omega; }
122  void set_speed_weight(float weight) { _pitch_speed_weight = weight; }
123  void set_speedrate_p(float speedrate_p) { _speed_error_gain = speedrate_p; }
124 
125  void set_time_const_throt(float time_const_throt) { _throttle_time_constant = time_const_throt; }
126  void set_throttle_damp(float throttle_damp) { _throttle_damping_gain = throttle_damp; }
127  void set_throttle_slewrate(float slewrate) { _throttle_slewrate = slewrate; }
128 
129  void set_roll_throttle_compensation(float compensation) { _load_factor_correction = compensation; }
130 
131  // TECS status
132  uint64_t timestamp() { return _pitch_update_timestamp; }
133  ECL_TECS_MODE tecs_mode() { return _tecs_mode; }
134 
136  float vert_pos_state() { return _vert_pos_state; }
137 
139  float tas_state() { return _tas_state; }
140 
142  float vert_vel_state() { return _vert_vel_state; }
143 
146 
147  float STE_error() { return _STE_error; }
148  float STE_rate_error() { return _STE_rate_error; }
149 
150  float SEB_error() { return _SEB_error; }
151  float SEB_rate_error() { return _SEB_rate_error; }
152 
155 
156  /**
157  * Handle the altitude reset
158  *
159  * If the estimation system resets the height in one discrete step this
160  * will gracefully even out the reset over time.
161  */
162  void handle_alt_step(float delta_alt, float altitude)
163  {
164  // add height reset delta to all variables involved
165  // in filtering the demanded height
166  _hgt_setpoint_in_prev += delta_alt;
167  _hgt_setpoint_prev += delta_alt;
168  _hgt_setpoint_adj_prev += delta_alt;
169 
170  // reset height states
171  _vert_pos_state = altitude;
172  _vert_accel_state = 0.0f;
173  _vert_vel_state = 0.0f;
174  }
175 
176 private:
177 
178  enum ECL_TECS_MODE _tecs_mode {ECL_TECS_MODE_NORMAL};
179 
180  // timestamps
181  uint64_t _state_update_timestamp{0}; ///< last timestamp of the 50 Hz function call
182  uint64_t _speed_update_timestamp{0}; ///< last timestamp of the speed function call
183  uint64_t _pitch_update_timestamp{0}; ///< last timestamp of the pitch function call
184 
185  // controller parameters
186  float _hgt_estimate_freq{0.0f}; ///< cross-over frequency of the height rate complementary filter (rad/sec)
187  float _tas_estimate_freq{0.0f}; ///< cross-over frequency of the true airspeed complementary filter (rad/sec)
188  float _max_climb_rate{2.0f}; ///< climb rate produced by max allowed throttle (m/sec)
189  float _min_sink_rate{1.0f}; ///< sink rate produced by min allowed throttle (m/sec)
190  float _max_sink_rate{2.0f}; ///< maximum safe sink rate (m/sec)
191  float _pitch_time_constant{5.0f}; ///< control time constant used by the pitch demand calculation (sec)
192  float _throttle_time_constant{8.0f}; ///< control time constant used by the throttle demand calculation (sec)
193  float _pitch_damping_gain{0.0f}; ///< damping gain of the pitch demand calculation (sec)
194  float _throttle_damping_gain{0.0f}; ///< damping gain of the throttle demand calculation (sec)
195  float _integrator_gain{0.0f}; ///< integrator gain used by the throttle and pitch demand calculation
196  float _vert_accel_limit{0.0f}; ///< magnitude of the maximum vertical acceleration allowed (m/sec**2)
197  float _load_factor_correction{0.0f}; ///< gain from normal load factor increase to total energy rate demand (m**2/sec**3)
198  float _pitch_speed_weight{1.0f}; ///< speed control weighting used by pitch demand calculation
199  float _height_error_gain{0.0f}; ///< gain from height error to demanded climb rate (1/sec)
200  float _height_setpoint_gain_ff{0.0f}; ///< gain from height demand derivative to demanded climb rate
201  float _speed_error_gain{0.0f}; ///< gain from speed error to demanded speed rate (1/sec)
202  float _indicated_airspeed_min{3.0f}; ///< equivalent airspeed demand lower limit (m/sec)
203  float _indicated_airspeed_max{30.0f}; ///< equivalent airspeed demand upper limit (m/sec)
204  float _throttle_slewrate{0.0f}; ///< throttle demand slew rate limit (1/sec)
205 
206  // controller outputs
207  float _throttle_setpoint{0.0f}; ///< normalized throttle demand (0..1)
208  float _pitch_setpoint{0.0f}; ///< pitch angle demand (radians)
209 
210  // complimentary filter states
211  float _vert_accel_state{0.0f}; ///< complimentary filter state - height second derivative (m/sec**2)
212  float _vert_vel_state{0.0f}; ///< complimentary filter state - height rate (m/sec)
213  float _vert_pos_state{0.0f}; ///< complimentary filter state - height (m)
214  float _tas_rate_state{0.0f}; ///< complimentary filter state - true airspeed first derivative (m/sec**2)
215  float _tas_state{0.0f}; ///< complimentary filter state - true airspeed (m/sec)
216 
217  // controller states
218  float _throttle_integ_state{0.0f}; ///< throttle integrator state
219  float _pitch_integ_state{0.0f}; ///< pitch integrator state (rad)
220  float _last_throttle_setpoint{0.0f}; ///< throttle demand rate limiter state (1/sec)
221  float _last_pitch_setpoint{0.0f}; ///< pitch demand rate limiter state (rad/sec)
222  float _speed_derivative{0.0f}; ///< rate of change of speed along X axis (m/sec**2)
223 
224  // speed demand calculations
225  float _EAS{0.0f}; ///< equivalent airspeed (m/sec)
226  float _TAS_max{30.0f}; ///< true airpeed demand upper limit (m/sec)
227  float _TAS_min{3.0f}; ///< true airpeed demand lower limit (m/sec)
228  float _TAS_setpoint{0.0f}; ///< current airpeed demand (m/sec)
229  float _TAS_setpoint_last{0.0f}; ///< previous true airpeed demand (m/sec)
230  float _EAS_setpoint{0.0f}; ///< Equivalent airspeed demand (m/sec)
231  float _TAS_setpoint_adj{0.0f}; ///< true airspeed demand tracked by the TECS algorithm (m/sec)
232  float _TAS_rate_setpoint{0.0f}; ///< true airspeed rate demand tracked by the TECS algorithm (m/sec**2)
233 
234  // height demand calculations
235  float _hgt_setpoint{0.0f}; ///< demanded height tracked by the TECS algorithm (m)
236  float _hgt_setpoint_in_prev{0.0f}; ///< previous value of _hgt_setpoint after noise filtering (m)
237  float _hgt_setpoint_prev{0.0f}; ///< previous value of _hgt_setpoint after noise filtering and rate limiting (m)
238  float _hgt_setpoint_adj{0.0f}; ///< demanded height used by the control loops after all filtering has been applied (m)
239  float _hgt_setpoint_adj_prev{0.0f}; ///< value of _hgt_setpoint_adj from previous frame (m)
240  float _hgt_rate_setpoint{0.0f}; ///< demanded climb rate tracked by the TECS algorithm
241 
242  // vehicle physical limits
243  float _pitch_setpoint_unc{0.0f}; ///< pitch demand before limiting (rad)
244  float _STE_rate_max{0.0f}; ///< specific total energy rate upper limit achieved when throttle is at _throttle_setpoint_max (m**2/sec**3)
245  float _STE_rate_min{0.0f}; ///< specific total energy rate lower limit acheived when throttle is at _throttle_setpoint_min (m**2/sec**3)
246  float _throttle_setpoint_max{0.0f}; ///< normalised throttle upper limit
247  float _throttle_setpoint_min{0.0f}; ///< normalised throttle lower limit
248  float _pitch_setpoint_max{0.5f}; ///< pitch demand upper limit (rad)
249  float _pitch_setpoint_min{-0.5f}; ///< pitch demand lower limit (rad)
250 
251  // specific energy quantities
252  float _SPE_setpoint{0.0f}; ///< specific potential energy demand (m**2/sec**2)
253  float _SKE_setpoint{0.0f}; ///< specific kinetic energy demand (m**2/sec**2)
254  float _SPE_rate_setpoint{0.0f}; ///< specific potential energy rate demand (m**2/sec**3)
255  float _SKE_rate_setpoint{0.0f}; ///< specific kinetic energy rate demand (m**2/sec**3)
256  float _SPE_estimate{0.0f}; ///< specific potential energy estimate (m**2/sec**2)
257  float _SKE_estimate{0.0f}; ///< specific kinetic energy estimate (m**2/sec**2)
258  float _SPE_rate{0.0f}; ///< specific potential energy rate estimate (m**2/sec**3)
259  float _SKE_rate{0.0f}; ///< specific kinetic energy rate estimate (m**2/sec**3)
260 
261  // specific energy error quantities
262  float _STE_error{0.0f}; ///< specific total energy error (m**2/sec**2)
263  float _STE_rate_error{0.0f}; ///< specific total energy rate error (m**2/sec**3)
264  float _SEB_error{0.0f}; ///< specific energy balance error (m**2/sec**2)
265  float _SEB_rate_error{0.0f}; ///< specific energy balance rate error (m**2/sec**3)
266 
267  // time steps (non-fixed)
268  float _dt{DT_DEFAULT}; ///< Time since last update of main TECS loop (sec)
269  static constexpr float DT_DEFAULT = 0.02f; ///< default value for _dt (sec)
270 
271  // controller mode logic
272  bool _underspeed_detected{false}; ///< true when an underspeed condition has been detected
273  bool _detect_underspeed_enabled{true}; ///< true when underspeed detection is enabled
274  bool _uncommanded_descent_recovery{false}; ///< true when a continuous descent caused by an unachievable airspeed demand has been detected
275  bool _climbout_mode_active{false}; ///< true when in climbout mode
276  bool _airspeed_enabled{false}; ///< true when airspeed use has been enabled
277  bool _states_initalized{false}; ///< true when TECS states have been iniitalized
278  bool _in_air{false}; ///< true when the vehicle is flying
279 
280  /**
281  * Update the airspeed internal state using a second order complementary filter
282  */
283  void _update_speed_states(float airspeed_setpoint, float indicated_airspeed, float eas_to_tas);
284 
285  /**
286  * Update the desired airspeed
287  */
288  void _update_speed_setpoint();
289 
290  /**
291  * Update the desired height
292  */
293  void _update_height_setpoint(float desired, float state);
294 
295  /**
296  * Detect if the system is not capable of maintaining airspeed
297  */
298  void _detect_underspeed();
299 
300  /**
301  * Update specific energy
302  */
304 
305  /**
306  * Update throttle setpoint
307  */
308  void _update_throttle_setpoint(float throttle_cruise, const matrix::Dcmf &rotMat);
309 
310  /**
311  * Detect an uncommanded descent
312  */
314 
315  /**
316  * Update the pitch setpoint
317  */
318  void _update_pitch_setpoint();
319 
320  /**
321  * Initialize the controller
322  */
323  void _initialize_states(float pitch, float throttle_cruise, float baro_altitude, float pitch_min_climbout,
324  float eas_to_tas);
325 
326  /**
327  * Calculate specific total energy rate limits
328  */
329  void _update_STE_rate_lim();
330 
331 };
ECL_TECS_MODE tecs_mode()
Definition: tecs.h:133
float STE_rate_error()
Definition: tecs.h:148
float _TAS_min
true airpeed demand lower limit (m/sec)
Definition: tecs.h:227
float _pitch_setpoint_unc
pitch demand before limiting (rad)
Definition: tecs.h:243
float _SPE_rate
specific potential energy rate estimate (m**2/sec**3)
Definition: tecs.h:258
float SEB_error()
Definition: tecs.h:150
float _integrator_gain
integrator gain used by the throttle and pitch demand calculation
Definition: tecs.h:195
void set_min_sink_rate(float rate)
Definition: tecs.h:107
float _hgt_rate_setpoint
demanded climb rate tracked by the TECS algorithm
Definition: tecs.h:240
float _vert_vel_state
complimentary filter state - height rate (m/sec)
Definition: tecs.h:212
float _SPE_setpoint
specific potential energy demand (m**2/sec**2)
Definition: tecs.h:252
void set_heightrate_ff(float heightrate_ff)
Definition: tecs.h:112
float _hgt_setpoint
demanded height tracked by the TECS algorithm (m)
Definition: tecs.h:235
void set_speed_weight(float weight)
Definition: tecs.h:122
float _height_error_gain
gain from height error to demanded climb rate (1/sec)
Definition: tecs.h:199
float _pitch_setpoint_max
pitch demand upper limit (rad)
Definition: tecs.h:248
float _hgt_setpoint_prev
previous value of _hgt_setpoint after noise filtering and rate limiting (m)
Definition: tecs.h:237
bool _uncommanded_descent_recovery
true when a continuous descent caused by an unachievable airspeed demand has been detected ...
Definition: tecs.h:274
float _vert_accel_limit
magnitude of the maximum vertical acceleration allowed (m/sec**2)
Definition: tecs.h:196
float _tas_rate_state
complimentary filter state - true airspeed first derivative (m/sec**2)
Definition: tecs.h:214
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.
Definition: tecs.cpp:149
void set_max_climb_rate(float climb_rate)
Definition: tecs.h:109
static enum @74 state
float _throttle_slewrate
throttle demand slew rate limit (1/sec)
Definition: tecs.h:204
void _detect_underspeed()
Detect if the system is not capable of maintaining airspeed.
Definition: tecs.cpp:268
float _min_sink_rate
sink rate produced by min allowed throttle (m/sec)
Definition: tecs.h:189
void set_height_comp_filter_omega(float omega)
Definition: tecs.h:111
void set_max_sink_rate(float sink_rate)
Definition: tecs.h:108
float _throttle_integ_state
throttle integrator state
Definition: tecs.h:218
uint64_t _pitch_update_timestamp
last timestamp of the pitch function call
Definition: tecs.h:183
bool _climbout_mode_active
true when in climbout mode
Definition: tecs.h:275
float _STE_rate_min
specific total energy rate lower limit acheived when throttle is at _throttle_setpoint_min (m**2/sec*...
Definition: tecs.h:245
void _update_throttle_setpoint(float throttle_cruise, const matrix::Dcmf &rotMat)
Update throttle setpoint.
Definition: tecs.cpp:304
float _SKE_estimate
specific kinetic energy estimate (m**2/sec**2)
Definition: tecs.h:257
float _throttle_setpoint_min
normalised throttle lower limit
Definition: tecs.h:247
float _speed_derivative
rate of change of speed along X axis (m/sec**2)
Definition: tecs.h:222
float _pitch_integ_state
pitch integrator state (rad)
Definition: tecs.h:219
void enable_airspeed(bool enabled)
Set the airspeed enable state.
Definition: tecs.h:67
float _STE_rate_error
specific total energy rate error (m**2/sec**3)
Definition: tecs.h:263
float speed_derivative()
Definition: tecs.h:145
void set_time_const(float time_const)
Definition: tecs.h:104
uint64_t timestamp()
Definition: tecs.h:132
float _pitch_damping_gain
damping gain of the pitch demand calculation (sec)
Definition: tecs.h:193
float get_pitch_setpoint()
Definition: tecs.h:89
float _tas_state
complimentary filter state - true airspeed (m/sec)
Definition: tecs.h:215
void set_indicated_airspeed_min(float airspeed)
Definition: tecs.h:116
float _pitch_time_constant
control time constant used by the pitch demand calculation (sec)
Definition: tecs.h:191
float STE_error()
Definition: tecs.h:147
float pitch_integ_state()
Definition: tecs.h:154
float _SKE_setpoint
specific kinetic energy demand (m**2/sec**2)
Definition: tecs.h:253
float TAS_rate_setpoint()
Definition: tecs.h:144
float _indicated_airspeed_min
equivalent airspeed demand lower limit (m/sec)
Definition: tecs.h:202
float _throttle_damping_gain
damping gain of the throttle demand calculation (sec)
Definition: tecs.h:194
bool _airspeed_enabled
true when airspeed use has been enabled
Definition: tecs.h:276
void _update_pitch_setpoint()
Update the pitch setpoint.
Definition: tecs.cpp:426
float _TAS_max
true airpeed demand upper limit (m/sec)
Definition: tecs.h:226
float _pitch_speed_weight
speed control weighting used by pitch demand calculation
Definition: tecs.h:198
float _TAS_setpoint_last
previous true airpeed demand (m/sec)
Definition: tecs.h:229
float _last_throttle_setpoint
throttle demand rate limiter state (1/sec)
Definition: tecs.h:220
float _SKE_rate
specific kinetic energy rate estimate (m**2/sec**3)
Definition: tecs.h:259
uint64_t _state_update_timestamp
last timestamp of the 50 Hz function call
Definition: tecs.h:181
void set_integrator_gain(float gain)
Definition: tecs.h:105
float _STE_error
specific total energy error (m**2/sec**2)
Definition: tecs.h:262
float _max_sink_rate
maximum safe sink rate (m/sec)
Definition: tecs.h:190
float _SEB_error
specific energy balance error (m**2/sec**2)
Definition: tecs.h:264
float _throttle_setpoint_max
normalised throttle upper limit
Definition: tecs.h:246
float TAS_setpoint_adj()
Definition: tecs.h:138
float _load_factor_correction
gain from normal load factor increase to total energy rate demand (m**2/sec**3)
Definition: tecs.h:197
float _hgt_setpoint_in_prev
previous value of _hgt_setpoint after noise filtering (m)
Definition: tecs.h:236
bool airspeed_sensor_enabled()
Get the current airspeed status.
Definition: tecs.h:62
float _last_pitch_setpoint
pitch demand rate limiter state (rad/sec)
Definition: tecs.h:221
float _pitch_setpoint_min
pitch demand lower limit (rad)
Definition: tecs.h:249
void _initialize_states(float pitch, float throttle_cruise, float baro_altitude, float pitch_min_climbout, float eas_to_tas)
Initialize the controller.
Definition: tecs.cpp:518
float _TAS_setpoint
current airpeed demand (m/sec)
Definition: tecs.h:228
float _EAS
equivalent airspeed (m/sec)
Definition: tecs.h:225
void set_speedrate_p(float speedrate_p)
Definition: tecs.h:123
bool _detect_underspeed_enabled
true when underspeed detection is enabled
Definition: tecs.h:273
ECL_TECS_MODE
Definition: tecs.h:94
float _dt
Time since last update of main TECS loop (sec)
Definition: tecs.h:268
float _SPE_estimate
specific potential energy estimate (m**2/sec**2)
Definition: tecs.h:256
void set_throttle_damp(float throttle_damp)
Definition: tecs.h:126
bool _in_air
true when the vehicle is flying
Definition: tecs.h:278
float _hgt_setpoint_adj
demanded height used by the control loops after all filtering has been applied (m) ...
Definition: tecs.h:238
float tas_state()
Definition: tecs.h:139
float _SEB_rate_error
specific energy balance rate error (m**2/sec**3)
Definition: tecs.h:265
float _height_setpoint_gain_ff
gain from height demand derivative to demanded climb rate
Definition: tecs.h:200
float _pitch_setpoint
pitch angle demand (radians)
Definition: tecs.h:208
void handle_alt_step(float delta_alt, float altitude)
Handle the altitude reset.
Definition: tecs.h:162
float _TAS_rate_setpoint
true airspeed rate demand tracked by the TECS algorithm (m/sec**2)
Definition: tecs.h:232
float hgt_rate_setpoint()
Definition: tecs.h:141
void set_indicated_airspeed_max(float airspeed)
Definition: tecs.h:115
float _vert_accel_state
complimentary filter state - height second derivative (m/sec**2)
Definition: tecs.h:211
void set_roll_throttle_compensation(float compensation)
Definition: tecs.h:129
bool _states_initalized
true when TECS states have been iniitalized
Definition: tecs.h:277
float throttle_integ_state()
Definition: tecs.h:153
bool _underspeed_detected
true when an underspeed condition has been detected
Definition: tecs.h:272
float _SPE_rate_setpoint
specific potential energy rate demand (m**2/sec**3)
Definition: tecs.h:254
Definition: tecs.h:45
void set_pitch_damping(float damping)
Definition: tecs.h:118
float _EAS_setpoint
Equivalent airspeed demand (m/sec)
Definition: tecs.h:230
float vert_pos_state()
Definition: tecs.h:136
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.
Definition: tecs.cpp:582
~TECS()=default
float _STE_rate_max
specific total energy rate upper limit achieved when throttle is at _throttle_setpoint_max (m**2/sec*...
Definition: tecs.h:244
float _hgt_setpoint_adj_prev
value of _hgt_setpoint_adj from previous frame (m)
Definition: tecs.h:239
void _detect_uncommanded_descent()
Detect an uncommanded descent.
Definition: tecs.cpp:399
void _update_STE_rate_lim()
Calculate specific total energy rate limits.
Definition: tecs.cpp:573
float _throttle_setpoint
normalized throttle demand (0..1)
Definition: tecs.h:207
void set_detect_underspeed_enabled(bool enabled)
Definition: tecs.h:101
float get_speed_weight()
Definition: tecs.h:90
float SEB_rate_error()
Definition: tecs.h:151
float _max_climb_rate
climb rate produced by max allowed throttle (m/sec)
Definition: tecs.h:188
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...
Definition: tecs.cpp:57
void reset_state()
Definition: tecs.h:92
void set_time_const_throt(float time_const_throt)
Definition: tecs.h:125
float _SKE_rate_setpoint
specific kinetic energy rate demand (m**2/sec**3)
Definition: tecs.h:255
float get_throttle_setpoint(void)
Definition: tecs.h:88
void _update_height_setpoint(float desired, float state)
Update the desired height.
Definition: tecs.cpp:222
TECS()=default
void set_vertical_accel_limit(float limit)
Definition: tecs.h:119
float _TAS_setpoint_adj
true airspeed demand tracked by the TECS algorithm (m/sec)
Definition: tecs.h:231
void _update_speed_setpoint()
Update the desired airspeed.
Definition: tecs.cpp:199
void set_heightrate_p(float heightrate_p)
Definition: tecs.h:113
float _hgt_estimate_freq
cross-over frequency of the height rate complementary filter (rad/sec)
Definition: tecs.h:186
float _throttle_time_constant
control time constant used by the throttle demand calculation (sec)
Definition: tecs.h:192
void _update_energy_estimates()
Update specific energy.
Definition: tecs.cpp:285
float _tas_estimate_freq
cross-over frequency of the true airspeed complementary filter (rad/sec)
Definition: tecs.h:187
float _speed_error_gain
gain from speed error to demanded speed rate (1/sec)
Definition: tecs.h:201
void set_speed_comp_filter_omega(float omega)
Definition: tecs.h:121
TECS & operator=(const TECS &)=delete
uint64_t _speed_update_timestamp
last timestamp of the speed function call
Definition: tecs.h:182
float _vert_pos_state
complimentary filter state - height (m)
Definition: tecs.h:213
float hgt_setpoint_adj()
Definition: tecs.h:135
void set_throttle_slewrate(float slewrate)
Definition: tecs.h:127
static constexpr float DT_DEFAULT
default value for _dt (sec)
Definition: tecs.h:269
float vert_vel_state()
Definition: tecs.h:142
float _indicated_airspeed_max
equivalent airspeed demand upper limit (m/sec)
Definition: tecs.h:203