Skip to content

Commit

Permalink
Airspeed Selector: changes in airspeed library to account for new EAS…
Browse files Browse the repository at this point in the history
… state (equivalent airspeed)

Signed-off-by: Silvan Fuhrer <silvan@auterion.com>
  • Loading branch information
sfuhrer authored and RomanBapst committed Aug 9, 2019
1 parent aae16cc commit 248e181
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 32 deletions.
62 changes: 46 additions & 16 deletions src/lib/airspeed/airspeed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
{


Expand All @@ -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);

Expand All @@ -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);
}
54 changes: 40 additions & 14 deletions src/lib/airspeed/airspeed.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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.
Expand All @@ -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
6 changes: 4 additions & 2 deletions src/modules/mavlink/mavlink_receiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 248e181

Please sign in to comment.