@ -6,12 +6,13 @@ Manages the estimation of aircraft total energy, drag and vertical air velocity.
@@ -6,12 +6,13 @@ Manages the estimation of aircraft total energy, drag and vertical air velocity.
# include <AP_Logger/AP_Logger.h>
Variometer : : Variometer ( const AP_Vehicle : : FixedWing & parms ) :
_aparm ( parms )
Variometer : : Variometer ( const AP_Vehicle : : FixedWing & parms , PolarParams & polarParams ) :
_aparm ( parms ) ,
_polarParams ( polarParams )
{
}
void Variometer : : update ( const float thermal_bank , const float polar_K , const float polar_Cd0 , const float polar_B )
void Variometer : : update ( const float thermal_bank )
{
const AP_AHRS & _ahrs = AP : : ahrs ( ) ;
@ -26,7 +27,7 @@ void Variometer::update(const float thermal_bank, const float polar_K, const flo
@@ -26,7 +27,7 @@ void Variometer::update(const float thermal_bank, const float polar_K, const flo
float aspd_filt = _sp_filter . apply ( aspd ) ;
// Constrained airspeed.
const float minV = sqrtf ( polar_ K/ 1.5 ) ;
const float minV = sqrtf ( _polarParams . K / 1.5 ) ;
_aspd_filt_constrained = aspd_filt > minV ? aspd_filt : minV ;
tau = calculate_circling_time_constant ( radians ( thermal_bank ) ) ;
@ -62,7 +63,7 @@ void Variometer::update(const float thermal_bank, const float polar_K, const flo
@@ -62,7 +63,7 @@ void Variometer::update(const float thermal_bank, const float polar_K, const flo
// Compute still-air sinkrate
float roll = _ahrs . roll ;
float sinkrate = calculate_aircraft_sinkrate ( roll , polar_K , polar_Cd0 , polar_B ) ;
float sinkrate = calculate_aircraft_sinkrate ( roll ) ;
reading = raw_climb_rate + dsp_cor * _aspd_filt_constrained / GRAVITY_MSS + sinkrate ;
@ -73,7 +74,7 @@ void Variometer::update(const float thermal_bank, const float polar_K, const flo
@@ -73,7 +74,7 @@ void Variometer::update(const float thermal_bank, const float polar_K, const flo
_prev_update_time = AP_HAL : : micros64 ( ) ;
_expected_thermalling_sink = calculate_aircraft_sinkrate ( radians ( thermal_bank ) , polar_K , polar_Cd0 , polar_B ) ;
_expected_thermalling_sink = calculate_aircraft_sinkrate ( radians ( thermal_bank ) ) ;
// @LoggerMessage: VAR
// @Vehicles: Plane
@ -106,19 +107,16 @@ void Variometer::update(const float thermal_bank, const float polar_K, const flo
@@ -106,19 +107,16 @@ void Variometer::update(const float thermal_bank, const float polar_K, const flo
}
float Variometer : : calculate_aircraft_sinkrate ( float phi ,
const float polar_K ,
const float polar_CD0 ,
const float polar_B ) const
float Variometer : : calculate_aircraft_sinkrate ( float phi ) const
{
// Remove aircraft sink rate
float CL0 ; // CL0 = 2*W/(rho*S*V^2)
float C1 ; // C1 = CD0/CL0
float C2 ; // C2 = CDi0/CL0 = B*CL0
CL0 = polar_ K / ( _aspd_filt_constrained * _aspd_filt_constrained ) ;
CL0 = _polarParams . K / ( _aspd_filt_constrained * _aspd_filt_constrained ) ;
C1 = polar_ CD0 / CL0 ; // constant describing expected angle to overcome zero-lift drag
C2 = polar_ B * CL0 ; // constant describing expected angle to overcome lift induced drag at zero bank
C1 = _polarParams . CD0 / CL0 ; // constant describing expected angle to overcome zero-lift drag
C2 = _polarParams . B * CL0 ; // constant describing expected angle to overcome lift induced drag at zero bank
float cosphi = ( 1 - phi * phi / 2 ) ; // first two terms of mclaurin series for cos(phi)