2013-06-26 05:38:40 -03:00
|
|
|
/// @file AP_TECS.h
|
|
|
|
/// @brief Combined Total Energy Speed & Height Control. This is a instance of an
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Written by Paul Riseborough 2013 to provide:
|
|
|
|
* - Combined control of speed and height using throttle to control
|
|
|
|
* total energy and pitch angle to control exchange of energy between
|
|
|
|
* potential and kinetic.
|
|
|
|
* Selectable speed or height priority modes when calculating pitch angle
|
|
|
|
* - Fallback mode when no airspeed measurement is available that
|
2015-09-15 22:17:28 -03:00
|
|
|
* sets throttle based on height rate demand and switches pitch angle control to
|
2013-06-26 05:38:40 -03:00
|
|
|
* height priority
|
2015-09-15 22:17:28 -03:00
|
|
|
* - Underspeed protection that demands maximum throttle switches pitch angle control
|
2013-06-26 05:38:40 -03:00
|
|
|
* to speed priority mode
|
|
|
|
* - Relative ease of tuning through use of intuitive time constant, trim rate and damping parameters and the use
|
|
|
|
* of easy to measure aircraft performance data
|
|
|
|
*/
|
2016-02-17 21:25:50 -04:00
|
|
|
#pragma once
|
2013-06-26 05:38:40 -03:00
|
|
|
|
2015-08-11 03:28:46 -03:00
|
|
|
#include <AP_Math/AP_Math.h>
|
|
|
|
#include <AP_AHRS/AP_AHRS.h>
|
|
|
|
#include <AP_Param/AP_Param.h>
|
2022-09-29 20:10:41 -03:00
|
|
|
#include <AP_Vehicle/AP_FixedWing.h>
|
2022-03-03 23:29:48 -04:00
|
|
|
#include <Filter/AverageFilter.h>
|
2013-06-26 05:38:40 -03:00
|
|
|
|
2021-11-12 13:55:31 -04:00
|
|
|
class AP_Landing;
|
|
|
|
class AP_TECS {
|
2013-06-26 05:38:40 -03:00
|
|
|
public:
|
2022-09-29 20:10:41 -03:00
|
|
|
AP_TECS(AP_AHRS &ahrs, const AP_FixedWing &parms, const AP_Landing &landing, const uint32_t log_bitmask)
|
2017-12-12 21:06:14 -04:00
|
|
|
: _ahrs(ahrs)
|
|
|
|
, aparm(parms)
|
|
|
|
, _landing(landing)
|
2022-07-28 20:43:09 -03:00
|
|
|
, _log_bitmask(log_bitmask)
|
2017-12-12 21:06:14 -04:00
|
|
|
{
|
|
|
|
AP_Param::setup_object_defaults(this, var_info);
|
2015-09-15 22:17:28 -03:00
|
|
|
}
|
|
|
|
|
2017-08-30 14:49:28 -03:00
|
|
|
/* Do not allow copies */
|
2022-09-30 06:50:43 -03:00
|
|
|
CLASS_NO_COPY(AP_TECS);
|
2017-08-30 14:49:28 -03:00
|
|
|
|
2015-09-15 22:17:28 -03:00
|
|
|
// Update of the estimated height and height rate internal state
|
|
|
|
// Update of the inertial speed rate internal state
|
|
|
|
// Should be called at 50Hz or greater
|
2021-11-12 13:55:31 -04:00
|
|
|
void update_50hz(void);
|
2015-09-15 22:17:28 -03:00
|
|
|
|
|
|
|
// Update the control loop calculations
|
2022-11-12 17:05:10 -04:00
|
|
|
// Do not call slower than 10Hz or faster than 500Hz
|
2015-09-15 22:17:28 -03:00
|
|
|
void update_pitch_throttle(int32_t hgt_dem_cm,
|
|
|
|
int32_t EAS_dem_cm,
|
2022-09-29 20:10:41 -03:00
|
|
|
enum AP_FixedWing::FlightStage flight_stage,
|
2016-02-12 15:38:40 -04:00
|
|
|
float distance_beyond_land_wp,
|
2013-07-09 07:50:37 -03:00
|
|
|
int32_t ptchMinCO_cd,
|
2013-07-10 00:32:13 -03:00
|
|
|
int16_t throttle_nudge,
|
2015-09-15 22:17:28 -03:00
|
|
|
float hgt_afe,
|
2024-03-02 17:25:06 -04:00
|
|
|
float load_factor,
|
|
|
|
float pitch_trim_deg);
|
2015-09-15 22:17:28 -03:00
|
|
|
|
|
|
|
// demanded throttle in percentage
|
2016-01-30 03:23:05 -04:00
|
|
|
// should return -100 to 100, usually positive unless reverse thrust is enabled via _THRminf < 0
|
2021-11-12 13:55:31 -04:00
|
|
|
float get_throttle_demand(void) {
|
2021-09-18 14:56:30 -03:00
|
|
|
return _throttle_dem * 100.0f;
|
2015-09-15 22:17:28 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
// demanded pitch angle in centi-degrees
|
|
|
|
// should return between -9000 to +9000
|
2021-11-12 13:55:31 -04:00
|
|
|
int32_t get_pitch_demand(void) {
|
2015-09-15 22:17:28 -03:00
|
|
|
return int32_t(_pitch_dem * 5729.5781f);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Rate of change of velocity along X body axis in m/s^2
|
2021-11-12 13:55:31 -04:00
|
|
|
float get_VXdot(void) {
|
2015-09-15 22:17:28 -03:00
|
|
|
return _vel_dot;
|
|
|
|
}
|
|
|
|
|
|
|
|
// return current target airspeed
|
2021-11-12 13:55:31 -04:00
|
|
|
float get_target_airspeed(void) const {
|
2018-10-18 07:42:31 -03:00
|
|
|
return _TAS_dem_adj / _ahrs.get_EAS2TAS();
|
2015-09-15 22:17:28 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
// return maximum climb rate
|
2021-11-12 13:55:31 -04:00
|
|
|
float get_max_climbrate(void) const {
|
2015-09-15 22:17:28 -03:00
|
|
|
return _maxClimbRate;
|
|
|
|
}
|
|
|
|
|
2021-06-01 02:32:21 -03:00
|
|
|
// return maximum sink rate (+ve number down)
|
2021-11-12 13:55:31 -04:00
|
|
|
float get_max_sinkrate(void) const {
|
2021-06-01 02:32:21 -03:00
|
|
|
return _maxSinkRate;
|
|
|
|
}
|
|
|
|
|
2017-02-13 16:51:19 -04:00
|
|
|
// added to let SoaringContoller reset pitch integrator to zero
|
2021-11-12 13:55:31 -04:00
|
|
|
void reset_pitch_I(void) {
|
2022-11-12 17:05:10 -04:00
|
|
|
_integSEBdot = 0.0f;
|
|
|
|
_integKE = 0.0f;
|
2017-02-13 16:51:19 -04:00
|
|
|
}
|
2021-09-08 14:49:36 -03:00
|
|
|
|
|
|
|
// reset throttle integrator
|
|
|
|
void reset_throttle_I(void) {
|
|
|
|
_integTHR_state = 0.0;
|
|
|
|
}
|
|
|
|
|
2015-09-15 22:17:28 -03:00
|
|
|
// return landing sink rate
|
2021-11-12 13:55:31 -04:00
|
|
|
float get_land_sinkrate(void) const {
|
2015-09-15 22:17:28 -03:00
|
|
|
return _land_sink;
|
|
|
|
}
|
|
|
|
|
2016-04-13 13:07:33 -03:00
|
|
|
// return landing airspeed
|
2021-11-12 13:55:31 -04:00
|
|
|
float get_land_airspeed(void) const {
|
2016-04-13 13:07:33 -03:00
|
|
|
return _landAirspeed;
|
|
|
|
}
|
|
|
|
|
2015-12-26 23:07:06 -04:00
|
|
|
// return height rate demand, in m/s
|
|
|
|
float get_height_rate_demand(void) const {
|
|
|
|
return _hgt_rate_dem;
|
|
|
|
}
|
2016-01-08 20:13:08 -04:00
|
|
|
|
|
|
|
// set path_proportion
|
2021-11-12 13:55:31 -04:00
|
|
|
void set_path_proportion(float path_proportion) {
|
2016-01-08 20:13:08 -04:00
|
|
|
_path_proportion = constrain_float(path_proportion, 0.0f, 1.0f);
|
|
|
|
}
|
|
|
|
|
2018-10-18 09:51:21 -03:00
|
|
|
// set soaring flag
|
2021-11-12 13:55:31 -04:00
|
|
|
void set_gliding_requested_flag(bool gliding_requested) {
|
2018-10-18 09:51:21 -03:00
|
|
|
_flags.gliding_requested = gliding_requested;
|
|
|
|
}
|
|
|
|
|
|
|
|
// set propulsion failed flag
|
2021-11-12 13:55:31 -04:00
|
|
|
void set_propulsion_failed_flag(bool propulsion_failed) {
|
2018-10-18 09:51:21 -03:00
|
|
|
_flags.propulsion_failed = propulsion_failed;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-01-09 06:50:40 -04:00
|
|
|
// set pitch max limit in degrees
|
|
|
|
void set_pitch_max_limit(int8_t pitch_limit) {
|
|
|
|
_pitch_max_limit = pitch_limit;
|
|
|
|
}
|
2016-10-04 21:52:34 -03:00
|
|
|
|
2024-05-24 06:38:42 -03:00
|
|
|
// set minimum throttle override, [-1, -1] range
|
|
|
|
// it is applicable for one control cycle only
|
|
|
|
void set_throttle_min(const float thr_min);
|
|
|
|
|
|
|
|
// set minimum throttle override, [0, -1] range
|
|
|
|
// it is applicable for one control cycle only
|
|
|
|
void set_throttle_max(const float thr_max);
|
|
|
|
|
2016-10-04 21:52:34 -03:00
|
|
|
// force use of synthetic airspeed for one loop
|
|
|
|
void use_synthetic_airspeed(void) {
|
2016-10-19 23:22:39 -03:00
|
|
|
_use_synthetic_airspeed_once = true;
|
2016-10-04 21:52:34 -03:00
|
|
|
}
|
2020-02-06 00:43:16 -04:00
|
|
|
|
|
|
|
// reset on next loop
|
2021-11-12 13:55:31 -04:00
|
|
|
void reset(void) {
|
2020-02-06 00:43:16 -04:00
|
|
|
_need_reset = true;
|
|
|
|
}
|
|
|
|
|
2015-09-15 22:17:28 -03:00
|
|
|
// this supports the TECS_* user settable parameters
|
2013-06-26 05:38:40 -03:00
|
|
|
static const struct AP_Param::GroupInfo var_info[];
|
|
|
|
|
|
|
|
private:
|
|
|
|
// Last time update_50Hz was called
|
2016-07-12 02:01:26 -03:00
|
|
|
uint64_t _update_50hz_last_usec;
|
2015-09-15 22:17:28 -03:00
|
|
|
|
2013-06-26 05:38:40 -03:00
|
|
|
// Last time update_pitch_throttle was called
|
2016-07-12 02:01:26 -03:00
|
|
|
uint64_t _update_pitch_throttle_last_usec;
|
2013-06-26 05:38:40 -03:00
|
|
|
|
2015-09-15 22:17:28 -03:00
|
|
|
// reference to the AHRS object
|
2013-08-14 01:58:49 -03:00
|
|
|
AP_AHRS &_ahrs;
|
2013-06-26 05:38:40 -03:00
|
|
|
|
2022-09-29 20:10:41 -03:00
|
|
|
const AP_FixedWing &aparm;
|
2016-12-05 20:46:55 -04:00
|
|
|
|
2016-11-23 05:35:43 -04:00
|
|
|
// reference to const AP_Landing to access it's params
|
|
|
|
const AP_Landing &_landing;
|
2022-07-28 20:43:09 -03:00
|
|
|
|
|
|
|
// Logging bitmask
|
|
|
|
const uint32_t _log_bitmask;
|
|
|
|
|
2015-09-15 22:17:28 -03:00
|
|
|
// TECS tuning parameters
|
|
|
|
AP_Float _hgtCompFiltOmega;
|
2013-06-26 05:38:40 -03:00
|
|
|
AP_Float _spdCompFiltOmega;
|
|
|
|
AP_Float _maxClimbRate;
|
|
|
|
AP_Float _minSinkRate;
|
|
|
|
AP_Float _maxSinkRate;
|
|
|
|
AP_Float _timeConst;
|
2014-08-27 01:28:39 -03:00
|
|
|
AP_Float _landTimeConst;
|
2013-06-26 05:38:40 -03:00
|
|
|
AP_Float _ptchDamp;
|
2016-02-24 22:18:14 -04:00
|
|
|
AP_Float _land_pitch_damp;
|
2014-11-28 04:32:15 -04:00
|
|
|
AP_Float _landDamp;
|
2013-06-26 05:38:40 -03:00
|
|
|
AP_Float _thrDamp;
|
2016-02-23 18:46:55 -04:00
|
|
|
AP_Float _land_throttle_damp;
|
2013-06-26 05:38:40 -03:00
|
|
|
AP_Float _integGain;
|
2016-02-23 20:20:25 -04:00
|
|
|
AP_Float _integGain_takeoff;
|
|
|
|
AP_Float _integGain_land;
|
2013-06-26 05:38:40 -03:00
|
|
|
AP_Float _vertAccLim;
|
2015-09-15 22:17:28 -03:00
|
|
|
AP_Float _rollComp;
|
|
|
|
AP_Float _spdWeight;
|
|
|
|
AP_Float _spdWeightLand;
|
2014-02-22 13:54:37 -04:00
|
|
|
AP_Float _landThrottle;
|
2014-03-19 17:58:01 -03:00
|
|
|
AP_Float _landAirspeed;
|
2014-08-11 03:45:06 -03:00
|
|
|
AP_Float _land_sink;
|
2016-02-12 15:38:40 -04:00
|
|
|
AP_Float _land_sink_rate_change;
|
2015-09-15 22:17:28 -03:00
|
|
|
AP_Int8 _pitch_max;
|
|
|
|
AP_Int8 _pitch_min;
|
|
|
|
AP_Int8 _land_pitch_max;
|
2016-01-30 03:23:05 -04:00
|
|
|
AP_Float _maxSinkRate_approach;
|
2019-03-02 07:30:06 -04:00
|
|
|
AP_Int32 _options;
|
2022-11-12 17:05:10 -04:00
|
|
|
AP_Float _flare_holdoff_hgt;
|
|
|
|
AP_Float _hgt_dem_tconst;
|
2019-03-02 07:30:06 -04:00
|
|
|
|
|
|
|
enum {
|
2024-02-19 05:17:42 -04:00
|
|
|
OPTION_GLIDER_ONLY=(1<<0),
|
|
|
|
OPTION_DESCENT_SPEEDUP=(1<<1)
|
2019-03-02 07:30:06 -04:00
|
|
|
};
|
2015-09-15 22:17:28 -03:00
|
|
|
|
2018-10-18 07:42:57 -03:00
|
|
|
AP_Float _pitch_ff_v0;
|
|
|
|
AP_Float _pitch_ff_k;
|
2022-11-12 17:05:10 -04:00
|
|
|
AP_Float _accel_gf;
|
2018-10-18 07:42:57 -03:00
|
|
|
|
2016-01-09 06:50:40 -04:00
|
|
|
// temporary _pitch_max_limit. Cleared on each loop. Clear when >= 90
|
|
|
|
int8_t _pitch_max_limit = 90;
|
|
|
|
|
2015-09-15 22:17:28 -03:00
|
|
|
// current height estimate (above field elevation)
|
2016-07-12 02:01:26 -03:00
|
|
|
float _height;
|
2015-09-15 22:17:28 -03:00
|
|
|
|
2016-01-30 03:23:05 -04:00
|
|
|
// throttle demand in the range from -1.0 to 1.0, usually positive unless reverse thrust is enabled via _THRminf < 0
|
2016-07-12 02:01:26 -03:00
|
|
|
float _throttle_dem;
|
2015-09-15 22:17:28 -03:00
|
|
|
|
|
|
|
// pitch angle demand in radians
|
2016-07-12 02:01:26 -03:00
|
|
|
float _pitch_dem;
|
2015-09-15 22:13:11 -03:00
|
|
|
|
2015-09-15 22:17:28 -03:00
|
|
|
// estimated climb rate (m/s)
|
2016-07-12 02:01:26 -03:00
|
|
|
float _climb_rate;
|
2013-06-26 05:38:40 -03:00
|
|
|
|
2022-11-12 17:05:10 -04:00
|
|
|
// climb and sink rate limits
|
|
|
|
float _climb_rate_limit;
|
|
|
|
float _sink_rate_limit;
|
|
|
|
|
2015-09-15 22:17:28 -03:00
|
|
|
/*
|
|
|
|
a filter to estimate climb rate if we don't have it from the EKF
|
|
|
|
*/
|
|
|
|
struct {
|
|
|
|
// height filter second derivative
|
|
|
|
float dd_height;
|
2015-09-15 22:13:11 -03:00
|
|
|
|
2015-09-15 22:17:28 -03:00
|
|
|
// height integration
|
|
|
|
float height;
|
|
|
|
} _height_filter;
|
2013-06-26 05:38:40 -03:00
|
|
|
|
2015-09-15 22:17:28 -03:00
|
|
|
// Integrator state 4 - airspeed filter first derivative
|
2016-07-12 02:01:26 -03:00
|
|
|
float _integDTAS_state;
|
2013-06-26 05:38:40 -03:00
|
|
|
|
2015-09-15 22:17:28 -03:00
|
|
|
// Integrator state 5 - true airspeed
|
2016-07-12 02:01:26 -03:00
|
|
|
float _TAS_state;
|
2013-06-26 05:38:40 -03:00
|
|
|
|
2015-09-15 22:17:28 -03:00
|
|
|
// Integrator state 6 - throttle integrator
|
2016-07-12 02:01:26 -03:00
|
|
|
float _integTHR_state;
|
2013-06-26 05:38:40 -03:00
|
|
|
|
2022-11-12 17:05:10 -04:00
|
|
|
// energy balance error integral
|
|
|
|
float _integSEBdot;
|
|
|
|
|
|
|
|
// pitch demand kinetic energy error integral
|
|
|
|
float _integKE;
|
2013-06-26 05:38:40 -03:00
|
|
|
|
|
|
|
// throttle demand rate limiter state
|
2016-07-12 02:01:26 -03:00
|
|
|
float _last_throttle_dem;
|
2013-06-26 05:38:40 -03:00
|
|
|
|
|
|
|
// pitch demand rate limiter state
|
2016-07-12 02:01:26 -03:00
|
|
|
float _last_pitch_dem;
|
2013-06-26 05:38:40 -03:00
|
|
|
|
|
|
|
// Rate of change of speed along X axis
|
2016-07-12 02:01:26 -03:00
|
|
|
float _vel_dot;
|
2022-11-12 17:05:10 -04:00
|
|
|
float _vel_dot_lpf;
|
2013-06-26 05:38:40 -03:00
|
|
|
|
|
|
|
// Equivalent airspeed
|
2016-07-12 02:01:26 -03:00
|
|
|
float _EAS;
|
2013-06-26 05:38:40 -03:00
|
|
|
|
|
|
|
// True airspeed limits
|
2016-07-12 02:01:26 -03:00
|
|
|
float _TASmax;
|
|
|
|
float _TASmin;
|
2013-06-26 05:38:40 -03:00
|
|
|
|
2019-03-31 19:28:42 -03:00
|
|
|
// Current true airspeed demand
|
2016-07-12 02:01:26 -03:00
|
|
|
float _TAS_dem;
|
2013-06-26 05:38:40 -03:00
|
|
|
|
|
|
|
// Equivalent airspeed demand
|
2016-07-12 02:01:26 -03:00
|
|
|
float _EAS_dem;
|
2013-06-26 05:38:40 -03:00
|
|
|
|
|
|
|
// height demands
|
2022-11-12 17:05:10 -04:00
|
|
|
float _hgt_dem_in_raw; // height demand input from autopilot before any modification (m)
|
|
|
|
float _hgt_dem_in; // height demand input from autopilot after unachievable climb or descent limiting (m)
|
|
|
|
float _hgt_dem_in_prev; // previous value of _hgt_dem_in (m)
|
|
|
|
float _hgt_dem_lpf; // height demand after application of low pass filtering (m)
|
|
|
|
float _flare_hgt_dem_adj; // height rate demand duirng flare adjusted for height tracking offset at flare entry (m)
|
|
|
|
float _flare_hgt_dem_ideal; // height we want to fly at during flare (m)
|
|
|
|
float _hgt_dem; // height demand sent to control loops (m)
|
|
|
|
float _hgt_dem_prev; // _hgt_dem from previous frame (m)
|
|
|
|
|
|
|
|
// height rate demands
|
|
|
|
float _hgt_dem_rate_ltd; // height demand after application of the rate limiter (m)
|
|
|
|
float _hgt_rate_dem; // height rate demand sent to control loops
|
|
|
|
|
|
|
|
// offset applied to height demand post takeoff to compensate for height demand filter lag
|
|
|
|
float _post_TO_hgt_offset;
|
|
|
|
|
|
|
|
// last lag compensation offset applied to height demand
|
|
|
|
float _lag_comp_hgt_offset;
|
2013-06-26 05:38:40 -03:00
|
|
|
|
|
|
|
// Speed demand after application of rate limiting
|
|
|
|
// This is the demand tracked by the TECS control loops
|
2016-07-12 02:01:26 -03:00
|
|
|
float _TAS_dem_adj;
|
2013-06-26 05:38:40 -03:00
|
|
|
|
|
|
|
// Speed rate demand after application of rate limiting
|
|
|
|
// This is the demand tracked by the TECS control loops
|
2016-07-12 02:01:26 -03:00
|
|
|
float _TAS_rate_dem;
|
2022-11-12 17:05:10 -04:00
|
|
|
float _TAS_rate_dem_lpf;
|
2013-06-26 05:38:40 -03:00
|
|
|
|
2015-09-15 22:17:28 -03:00
|
|
|
// Total energy rate filter state
|
2016-07-12 02:01:26 -03:00
|
|
|
float _STEdotErrLast;
|
2013-06-26 05:38:40 -03:00
|
|
|
|
2023-01-09 23:54:04 -04:00
|
|
|
// time we started a takeoff
|
|
|
|
uint32_t _takeoff_start_ms;
|
|
|
|
|
2016-03-25 18:41:09 -03:00
|
|
|
struct flags {
|
|
|
|
// Underspeed condition
|
|
|
|
bool underspeed:1;
|
2013-06-26 05:38:40 -03:00
|
|
|
|
2016-03-25 18:41:09 -03:00
|
|
|
// Bad descent condition caused by unachievable airspeed demand
|
|
|
|
bool badDescent:1;
|
2016-03-25 17:43:39 -03:00
|
|
|
|
2016-03-25 18:41:09 -03:00
|
|
|
// true when plane is in auto mode and executing a land mission item
|
|
|
|
bool is_doing_auto_land:1;
|
2016-07-05 23:15:55 -03:00
|
|
|
|
|
|
|
// true when we have reached target speed in takeoff
|
|
|
|
bool reached_speed_takeoff:1;
|
2018-10-18 09:51:21 -03:00
|
|
|
|
|
|
|
// true if the soaring feature has requested gliding flight
|
|
|
|
bool gliding_requested:1;
|
|
|
|
|
|
|
|
// true when we are in gliding flight, in one of three situations;
|
|
|
|
// - THR_MAX=0
|
|
|
|
// - gliding has been requested e.g. by soaring feature
|
|
|
|
// - engine failure detected (detection not implemented currently)
|
|
|
|
bool is_gliding:1;
|
|
|
|
|
|
|
|
// true if a propulsion failure is detected.
|
|
|
|
bool propulsion_failed:1;
|
2022-11-12 17:05:10 -04:00
|
|
|
|
|
|
|
// true when a reset of airspeed and height states to current is performed on this frame
|
|
|
|
bool reset:1;
|
2024-02-19 05:17:42 -04:00
|
|
|
|
2016-03-25 18:41:09 -03:00
|
|
|
};
|
|
|
|
union {
|
|
|
|
struct flags _flags;
|
|
|
|
uint8_t _flags_byte;
|
|
|
|
};
|
2016-03-25 17:43:39 -03:00
|
|
|
|
|
|
|
// time when underspeed started
|
2016-07-12 02:01:26 -03:00
|
|
|
uint32_t _underspeed_start_ms;
|
2013-06-26 05:38:40 -03:00
|
|
|
|
2016-01-30 03:23:05 -04:00
|
|
|
// auto mode flightstage
|
2022-09-29 20:10:41 -03:00
|
|
|
enum AP_FixedWing::FlightStage _flight_stage;
|
2013-06-26 05:38:40 -03:00
|
|
|
|
2015-09-15 22:17:28 -03:00
|
|
|
// pitch demand before limiting
|
2016-07-12 02:01:26 -03:00
|
|
|
float _pitch_dem_unc;
|
2013-06-26 05:38:40 -03:00
|
|
|
|
2023-11-01 00:41:32 -03:00
|
|
|
// 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)
|
2013-06-26 05:38:40 -03:00
|
|
|
|
2015-09-15 22:17:28 -03:00
|
|
|
// Maximum and minimum floating point throttle limits
|
2016-07-12 02:01:26 -03:00
|
|
|
float _THRmaxf;
|
|
|
|
float _THRminf;
|
2024-05-24 06:38:42 -03:00
|
|
|
// Maximum and minimum throttle safety limits, set externally, typically by servos.cpp:apply_throttle_limits()
|
|
|
|
float _THRmaxf_ext = 1.0f;
|
|
|
|
float _THRminf_ext = -1.0f;
|
2013-06-26 05:38:40 -03:00
|
|
|
|
2015-09-15 22:17:28 -03:00
|
|
|
// Maximum and minimum floating point pitch limits
|
2016-07-12 02:01:26 -03:00
|
|
|
float _PITCHmaxf;
|
|
|
|
float _PITCHminf;
|
2013-06-26 05:38:40 -03:00
|
|
|
|
2021-11-15 15:22:15 -04:00
|
|
|
// 1 if throttle is clipping at max value, -1 if clipping at min value, 0 otherwise
|
2022-11-12 17:05:10 -04:00
|
|
|
enum class clipStatus : int8_t {
|
2021-11-15 15:22:15 -04:00
|
|
|
MIN = -1,
|
|
|
|
NONE = 0,
|
|
|
|
MAX = 1,
|
|
|
|
};
|
2022-11-12 17:05:10 -04:00
|
|
|
clipStatus _thr_clip_status;
|
2021-11-15 15:22:15 -04:00
|
|
|
|
2013-06-26 05:38:40 -03:00
|
|
|
// Specific energy quantities
|
2016-07-12 02:01:26 -03:00
|
|
|
float _SPE_dem;
|
|
|
|
float _SKE_dem;
|
|
|
|
float _SPEdot_dem;
|
|
|
|
float _SKEdot_dem;
|
|
|
|
float _SPE_est;
|
|
|
|
float _SKE_est;
|
|
|
|
float _SPEdot;
|
|
|
|
float _SKEdot;
|
2013-06-26 05:38:40 -03:00
|
|
|
|
2022-11-12 17:05:10 -04:00
|
|
|
// variables used for precision landing pitch control
|
|
|
|
float _hgt_at_start_of_flare;
|
|
|
|
float _hgt_rate_at_flare_entry;
|
|
|
|
float _hgt_afe;
|
|
|
|
float _pitch_min_at_flare_entry;
|
|
|
|
|
|
|
|
// used to scale max climb and sink limits to match vehicle ability
|
|
|
|
float _max_climb_scaler;
|
|
|
|
float _max_sink_scaler;
|
2024-02-19 05:17:42 -04:00
|
|
|
float _sink_fraction;
|
2022-11-12 17:05:10 -04:00
|
|
|
|
2015-09-15 22:17:28 -03:00
|
|
|
// Specific energy error quantities
|
2016-07-12 02:01:26 -03:00
|
|
|
float _STE_error;
|
2013-06-26 05:38:40 -03:00
|
|
|
|
2022-11-12 17:05:10 -04:00
|
|
|
// 1 when specific energy balance rate demand is clipping in the up direction
|
|
|
|
// -1 when specific energy balance rate demand is clipping in the down direction
|
|
|
|
// 0 when not clipping
|
|
|
|
clipStatus _SEBdot_dem_clip;
|
|
|
|
|
2015-09-15 22:17:28 -03:00
|
|
|
// Time since last update of main TECS loop (seconds)
|
2016-07-12 02:01:26 -03:00
|
|
|
float _DT;
|
2013-06-26 05:38:40 -03:00
|
|
|
|
2022-11-27 03:18:29 -04:00
|
|
|
// true when class variables used for flare control have been initialised
|
|
|
|
// on flare entry
|
|
|
|
bool _flare_initialised;
|
2014-08-27 07:13:01 -03:00
|
|
|
|
2016-01-08 20:13:08 -04:00
|
|
|
// percent traveled along the previous and next waypoints
|
2016-07-12 02:01:26 -03:00
|
|
|
float _path_proportion;
|
2016-01-08 20:13:08 -04:00
|
|
|
|
2016-07-12 02:01:26 -03:00
|
|
|
float _distance_beyond_land_wp;
|
2016-02-12 15:38:40 -04:00
|
|
|
|
2019-04-14 03:03:24 -03:00
|
|
|
float _land_pitch_min = -90;
|
|
|
|
|
2020-02-06 00:43:16 -04:00
|
|
|
// need to reset on next loop
|
|
|
|
bool _need_reset;
|
|
|
|
|
2024-05-24 06:38:42 -03:00
|
|
|
// Checks if we reset at the beginning of takeoff.
|
|
|
|
bool _flag_have_reset_after_takeoff;
|
|
|
|
|
2022-11-12 17:05:10 -04:00
|
|
|
float _SKE_weighting;
|
2016-10-04 21:52:34 -03:00
|
|
|
|
2016-10-19 23:22:39 -03:00
|
|
|
AP_Int8 _use_synthetic_airspeed;
|
|
|
|
|
2016-10-04 21:52:34 -03:00
|
|
|
// use synthetic airspeed for next loop
|
2016-10-19 23:22:39 -03:00
|
|
|
bool _use_synthetic_airspeed_once;
|
2022-11-12 17:05:10 -04:00
|
|
|
|
|
|
|
// using airspeed in throttle calculation this frame
|
|
|
|
bool _using_airspeed_for_throttle;
|
|
|
|
|
|
|
|
// low pass filters used for crossover filter that combines demanded and measured pitch
|
|
|
|
// when calculating a pitch to throttle mapping.
|
|
|
|
LowPassFilterFloat _pitch_demand_lpf;
|
|
|
|
LowPassFilterFloat _pitch_measured_lpf;
|
|
|
|
|
|
|
|
// aerodynamic load factor
|
|
|
|
float _load_factor;
|
|
|
|
|
2013-06-26 05:38:40 -03:00
|
|
|
// Update the airspeed internal state using a second order complementary filter
|
2022-11-12 17:05:10 -04:00
|
|
|
void _update_speed(float DT);
|
2013-06-26 05:38:40 -03:00
|
|
|
|
|
|
|
// Update the demanded airspeed
|
|
|
|
void _update_speed_demand(void);
|
|
|
|
|
|
|
|
// Update the demanded height
|
|
|
|
void _update_height_demand(void);
|
|
|
|
|
2015-09-15 22:17:28 -03:00
|
|
|
// Detect an underspeed condition
|
|
|
|
void _detect_underspeed(void);
|
2013-06-26 05:38:40 -03:00
|
|
|
|
2015-09-15 22:17:28 -03:00
|
|
|
// Update Specific Energy Quantities
|
|
|
|
void _update_energies(void);
|
2013-06-26 05:38:40 -03:00
|
|
|
|
2015-09-15 22:17:28 -03:00
|
|
|
// Update Demanded Throttle
|
2016-07-05 23:15:55 -03:00
|
|
|
void _update_throttle_with_airspeed(void);
|
2013-06-26 05:38:40 -03:00
|
|
|
|
2015-09-15 22:17:28 -03:00
|
|
|
// Update Demanded Throttle Non-Airspeed
|
2024-03-02 17:25:06 -04:00
|
|
|
void _update_throttle_without_airspeed(int16_t throttle_nudge, float pitch_trim_deg);
|
2013-07-04 18:48:28 -03:00
|
|
|
|
2024-05-24 06:38:42 -03:00
|
|
|
// Constrain throttle demand and record clipping
|
|
|
|
void constrain_throttle();
|
|
|
|
|
2016-02-23 20:20:25 -04:00
|
|
|
// get integral gain which is flight_stage dependent
|
|
|
|
float _get_i_gain(void);
|
|
|
|
|
2015-09-15 22:17:28 -03:00
|
|
|
// Detect Bad Descent
|
|
|
|
void _detect_bad_descent(void);
|
2013-06-26 05:38:40 -03:00
|
|
|
|
2015-09-15 22:17:28 -03:00
|
|
|
// Update Demanded Pitch Angle
|
|
|
|
void _update_pitch(void);
|
2013-06-26 05:38:40 -03:00
|
|
|
|
2015-09-15 22:17:28 -03:00
|
|
|
// Initialise states and variables
|
|
|
|
void _initialise_states(int32_t ptchMinCO_cd, float hgt_afe);
|
2013-06-26 05:38:40 -03:00
|
|
|
|
2015-09-15 22:17:28 -03:00
|
|
|
// Calculate specific total energy rate limits
|
|
|
|
void _update_STE_rate_lim(void);
|
2013-06-26 05:38:40 -03:00
|
|
|
|
|
|
|
// declares a 5point average filter using floats
|
2015-09-15 22:17:28 -03:00
|
|
|
AverageFilterFloat_Size5 _vdot_filter;
|
2014-08-27 01:28:39 -03:00
|
|
|
|
2015-09-15 22:17:28 -03:00
|
|
|
// current time constant
|
|
|
|
float timeConstant(void) const;
|
2024-05-24 06:38:42 -03:00
|
|
|
|
|
|
|
// Update the allowable throttle range.
|
|
|
|
void _update_throttle_limits();
|
2013-06-26 05:38:40 -03:00
|
|
|
};
|