Airspeed Selector: changes in airspeed library to account for new EAS state (equivalent airspeed)

Signed-off-by: Silvan Fuhrer <silvan@auterion.com>
This commit is contained in:
Silvan Fuhrer
2019-08-07 12:58:34 +02:00
committed by Roman Bapst
parent aae16cc594
commit 248e1818e2
3 changed files with 90 additions and 32 deletions
+46 -16
View File
@@ -55,8 +55,8 @@
* @param differential_pressure total_ pressure - static pressure
* @return indicated airspeed in m/s
*/
float calc_indicated_airspeed_corrected(enum AIRSPEED_COMPENSATION_MODEL pmodel, enum AIRSPEED_SENSOR_MODEL smodel,
float tube_len, float tube_dia_mm, float differential_pressure, float pressure_ambient, float temperature_celsius)
float calc_IAS_corrected(enum AIRSPEED_COMPENSATION_MODEL pmodel, enum AIRSPEED_SENSOR_MODEL smodel,
float tube_len, float tube_dia_mm, float differential_pressure, float pressure_ambient, float temperature_celsius)
{
// air density in kg/m3
@@ -184,16 +184,15 @@ float calc_indicated_airspeed_corrected(enum AIRSPEED_COMPENSATION_MODEL pmodel,
/**
* Calculate indicated airspeed.
* Calculate indicated airspeed (IAS).
*
* Note that the indicated airspeed is not the true airspeed because it
* lacks the air density compensation. Use the calc_true_airspeed functions to get
* the true airspeed.
* lacks the air density and instrument error compensation.
*
* @param differential_pressure total_ pressure - static pressure
* @return indicated airspeed in m/s
* @return IAS in m/s
*/
float calc_indicated_airspeed(float differential_pressure)
float calc_IAS(float differential_pressure)
{
@@ -207,32 +206,47 @@ float calc_indicated_airspeed(float differential_pressure)
}
/**
* Calculate true airspeed from indicated airspeed.
* Calculate true airspeed (TAS) from equivalent airspeed (EAS).
*
* Note that the true airspeed is NOT the groundspeed, because of the effects of wind
*
* @param speed_indicated current indicated airspeed
* @param speed_equivalent current equivalent airspeed
* @param pressure_ambient pressure at the side of the tube/airplane
* @param temperature_celsius air temperature in degrees celcius
* @return true airspeed in m/s
* @return TAS in m/s
*/
float calc_true_airspeed_from_indicated(float speed_indicated, float pressure_ambient, float temperature_celsius)
float calc_TAS_from_EAS(float speed_equivalent, float pressure_ambient, float temperature_celsius)
{
return speed_indicated * sqrtf(CONSTANTS_AIR_DENSITY_SEA_LEVEL_15C / get_air_density(pressure_ambient,
temperature_celsius));
return speed_equivalent * sqrtf(CONSTANTS_AIR_DENSITY_SEA_LEVEL_15C / get_air_density(pressure_ambient,
temperature_celsius));
}
/**
* Directly calculate true airspeed
* Calculate equivalent airspeed (EAS) from indicated airspeed (IAS).
* Note that we neglect the conversion from CAS (calibrated airspeed) to EAS.
*
* Note that the true airspeed is NOT the groundspeed, because of the effects of wind
* @param speed_indicated current indicated airspeed
* @param scale scale from IAS to CAS (accounting for instrument and pitot position erros)
* @return EAS in m/s
*/
float calc_EAS_from_IAS(float speed_indicated, float scale)
{
return speed_indicated * scale;
}
/**
* Directly calculate true airspeed (TAS)
*
* Here we assume to have no instrument or pitot position error (IAS = CAS),
* and neglect the CAS to EAS conversion (CAS = EAS).
* Note that the true airspeed is NOT the groundspeed, because of the effects of wind.
*
* @param total_pressure pressure inside the pitot/prandtl tube
* @param static_pressure pressure at the side of the tube/airplane
* @param temperature_celsius air temperature in degrees celcius
* @return true airspeed in m/s
*/
float calc_true_airspeed(float total_pressure, float static_pressure, float temperature_celsius)
float calc_TAS(float total_pressure, float static_pressure, float temperature_celsius)
{
float density = get_air_density(static_pressure, temperature_celsius);
@@ -254,3 +268,19 @@ float get_air_density(float static_pressure, float temperature_celsius)
{
return static_pressure / (CONSTANTS_AIR_GAS_CONST * (temperature_celsius - CONSTANTS_ABSOLUTE_NULL_CELSIUS));
}
/**
* Calculate equivalent airspeed (EAS) from true airspeed (TAS).
* It is the inverse function to calc_TAS_from_EAS()
*
*
* @param speed_true current true airspeed
* @param pressure_ambient pressure at the side of the tube/airplane
* @param temperature_celsius air temperature in degrees celcius
* @return EAS in m/s
*/
float calc_EAS_from_TAS(float speed_true, float pressure_ambient, float temperature_celsius)
{
return speed_true * sqrtf(get_air_density(pressure_ambient,
temperature_celsius) / CONSTANTS_AIR_DENSITY_SEA_LEVEL_15C);
}
+40 -14
View File
@@ -58,7 +58,7 @@ enum AIRSPEED_COMPENSATION_MODEL {
};
/**
* Calculate indicated airspeed.
* Calculate indicated airspeed (IAS).
*
* Note that the indicated airspeed is not the true airspeed because it
* lacks the air density compensation. Use the calc_true_airspeed functions to get
@@ -68,12 +68,12 @@ enum AIRSPEED_COMPENSATION_MODEL {
* @param static_pressure pressure at the side of the tube/airplane
* @return indicated airspeed in m/s
*/
__EXPORT float calc_indicated_airspeed_corrected(enum AIRSPEED_COMPENSATION_MODEL pmodel,
enum AIRSPEED_SENSOR_MODEL smodel,
float tube_len, float tube_dia_mm, float differential_pressure, float pressure_ambient, float temperature_celsius);
__EXPORT float calc_IAS_corrected(enum AIRSPEED_COMPENSATION_MODEL pmodel,
enum AIRSPEED_SENSOR_MODEL smodel,
float tube_len, float tube_dia_mm, float differential_pressure, float pressure_ambient, float temperature_celsius);
/**
* Calculate indicated airspeed.
* Calculate indicated airspeed (IAS).
*
* Note that the indicated airspeed is not the true airspeed because it
* lacks the air density compensation. Use the calc_true_airspeed functions to get
@@ -83,32 +83,45 @@ __EXPORT float calc_indicated_airspeed_corrected(enum AIRSPEED_COMPENSATION_MODE
* @param static_pressure pressure at the side of the tube/airplane
* @return indicated airspeed in m/s
*/
__EXPORT float calc_indicated_airspeed(float differential_pressure);
__EXPORT float calc_IAS(float differential_pressure);
/**
* Calculate true airspeed from indicated airspeed.
* Calculate true airspeed (TAS) from equivalent airspeed (EAS).
*
* Note that the true airspeed is NOT the groundspeed, because of the effects of wind
*
* @param speed_indicated current indicated airspeed
* @param speed_equivalent current equivalent airspeed
* @param pressure_ambient pressure at the side of the tube/airplane
* @param temperature_celsius air temperature in degrees celcius
* @return true airspeed in m/s
* @return TAS in m/s
*/
__EXPORT float calc_true_airspeed_from_indicated(float speed_indicated, float pressure_ambient,
float temperature_celsius);
__EXPORT float calc_TAS_from_EAS(float speed_indicated, float pressure_ambient,
float temperature_celsius);
/**
* Directly calculate true airspeed
* Calculate equivalent airspeed (EAS) from indicated airspeed (IAS).
* Note that we neglect the conversion from CAS (calibrated airspeed) to EAS.
*
* Note that the true airspeed is NOT the groundspeed, because of the effects of wind
* @param speed_indicated current indicated airspeed
* @param scale scale from IAS to CAS (accounting for instrument and pitot position erros)
* @return EAS in m/s
*/
__EXPORT float calc_EAS_from_IAS(float speed_indicated, float scale);
/**
* Directly calculate true airspeed (TAS)
*
* Here we assume to have no instrument or pitot position error (IAS = CAS),
* and neglect the CAS to EAS conversion (CAS = EAS).
* Note that the true airspeed is NOT the groundspeed, because of the effects of wind.
*
* @param total_pressure pressure inside the pitot/prandtl tube
* @param static_pressure pressure at the side of the tube/airplane
* @param temperature_celsius air temperature in degrees celcius
* @return true airspeed in m/s
*/
__EXPORT float calc_true_airspeed(float total_pressure, float static_pressure, float temperature_celsius);
__EXPORT float calc_TAS(float total_pressure, float static_pressure, float temperature_celsius);
/**
* Calculates air density.
@@ -118,6 +131,19 @@ __EXPORT float calc_true_airspeed(float total_pressure, float static_pressure, f
*/
__EXPORT float get_air_density(float static_pressure, float temperature_celsius);
/**
* Calculate equivalent airspeed (EAS) from true airspeed (TAS).
* It is the inverse function to calc_TAS_from_EAS()
*
*
* @param speed_true current true airspeed
* @param pressure_ambient pressure at the side of the tube/airplane
* @param temperature_celsius air temperature in degrees celcius
* @return EAS in m/s
*/
__EXPORT float calc_EAS_from_TAS(float speed_true, float pressure_ambient,
float temperature_celsius);
__END_DECLS
#endif
+4 -2
View File
@@ -1887,8 +1887,10 @@ MavlinkReceiver::handle_message_hil_sensor(mavlink_message_t *msg)
{
airspeed_s airspeed{};
float ias = calc_indicated_airspeed(imu.diff_pressure * 1e2f);
float tas = calc_true_airspeed_from_indicated(ias, imu.abs_pressure * 100, imu.temperature);
float ias = calc_IAS(imu.diff_pressure * 1e2f);
float scale = 1.0f; //assume no instrument or pitot placement errors
float eas = calc_EAS_from_IAS(ias, scale);
float tas = calc_TAS_from_EAS(eas, imu.abs_pressure * 100, imu.temperature);
airspeed.timestamp = timestamp;
airspeed.indicated_airspeed_m_s = ias;