2017-04-27 18:44:03 -03:00
|
|
|
|
|
|
|
/* Variometer class by Samuel Tabor
|
|
|
|
|
|
|
|
Manages the estimation of aircraft total energy, drag and vertical air velocity.
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <AP_AHRS/AP_AHRS.h>
|
|
|
|
#include <AP_Param/AP_Param.h>
|
|
|
|
#include <AP_SpdHgtControl/AP_SpdHgtControl.h>
|
2019-03-26 12:29:53 -03:00
|
|
|
#include <Filter/AverageFilter.h>
|
2017-04-27 18:44:03 -03:00
|
|
|
|
|
|
|
#define ASPD_FILT 0.05
|
|
|
|
#define TE_FILT 0.03
|
|
|
|
#define TE_FILT_DISPLAYED 0.15
|
|
|
|
|
|
|
|
class Variometer {
|
|
|
|
|
|
|
|
const AP_Vehicle::FixedWing &_aparm;
|
|
|
|
|
|
|
|
// store time of last update
|
2019-08-07 19:33:06 -03:00
|
|
|
uint64_t _prev_update_time;
|
2017-04-27 18:44:03 -03:00
|
|
|
|
|
|
|
float _last_alt;
|
|
|
|
|
|
|
|
float _aspd_filt;
|
2019-06-23 04:35:33 -03:00
|
|
|
float _aspd_filt_constrained;
|
|
|
|
|
2017-04-27 18:44:03 -03:00
|
|
|
float _last_aspd;
|
|
|
|
float _last_roll;
|
|
|
|
float _last_total_E;
|
2019-06-22 13:02:35 -03:00
|
|
|
float _expected_thermalling_sink;
|
2017-04-27 18:44:03 -03:00
|
|
|
|
2019-03-26 12:29:53 -03:00
|
|
|
// declares a 5point average filter using floats
|
|
|
|
AverageFilterFloat_Size5 _vdot_filter;
|
|
|
|
|
|
|
|
AverageFilterFloat_Size5 _sp_filter;
|
|
|
|
|
2019-06-08 09:51:00 -03:00
|
|
|
// low pass filter @ 30s time constant
|
|
|
|
LowPassFilter<float> _climb_filter;
|
|
|
|
|
2019-06-28 10:29:04 -03:00
|
|
|
LowPassFilter<float> _vdot_filter2;
|
|
|
|
|
2017-04-27 18:44:03 -03:00
|
|
|
public:
|
2020-05-05 01:41:17 -03:00
|
|
|
Variometer(const AP_Vehicle::FixedWing &parms);
|
2017-04-27 18:44:03 -03:00
|
|
|
float alt;
|
|
|
|
float reading;
|
|
|
|
float filtered_reading;
|
|
|
|
float displayed_reading;
|
2019-06-08 09:51:00 -03:00
|
|
|
float raw_climb_rate;
|
|
|
|
float smoothed_climb_rate;
|
2020-01-11 11:14:06 -04:00
|
|
|
float tau;
|
2017-04-27 18:44:03 -03:00
|
|
|
|
|
|
|
void update(const float polar_K, const float polar_CD0, const float polar_B);
|
2019-06-23 04:52:38 -03:00
|
|
|
float calculate_aircraft_sinkrate(float phi, const float polar_K, const float polar_CD0, const float polar_B);
|
2017-04-27 18:44:03 -03:00
|
|
|
|
2019-06-08 09:51:00 -03:00
|
|
|
void reset_filter(float value) { _climb_filter.reset(value);}
|
2019-06-22 13:02:35 -03:00
|
|
|
|
|
|
|
float get_airspeed(void) {return _aspd_filt;};
|
|
|
|
|
|
|
|
float get_exp_thermalling_sink(void) {return _expected_thermalling_sink;};
|
2019-06-23 04:35:33 -03:00
|
|
|
|
|
|
|
float calculate_circling_time_constant();
|
2017-04-27 18:44:03 -03:00
|
|
|
};
|
|
|
|
|