### Table of Contents

# Atmospheric Pressure

The pressure measurement on MAVs allows to estimate the current altitude and, if two sensors are used, the current airspeed.

Wikipedia References:

- Pitot tube – Airspeed measurement

#### Units

# Airspeed

The airspeed (combination of groundspeed of the vehicle and wind speed) can be measured by comparing the pressure in a pitot tube (a tube oriented towards the front) and the ambient pressure, measured e.g. on the side of the airplane. * Not interested in the basics and want just C-code? Jump to the section below*.

### Calculating Indicated Airspeed / Stall Speed

The indicated airspeed is the true airspeed at sea level. If the MAV flies higher than sea level, the air density is less, so when the airspeed is kept constant on all altitudes, the true air speed (travelled distance, neglegting wind effects for now) will be higher at high altitudes. The indicated airspeed thus directly relates to the pressure in front of aircraft, which in turn relates to the speed at which stall occurs. So to prevent stall, always keep the indicated airspeed above the stall speed, no matter at which altitude the MAV is flying. Consequently this will be at a lower true air speed near sea level and at a high true air speed at very high altitudes in thin air.

Calculation of the indicated airspeed: The speed in a medium is

Where all variables are in SI units:

- is the indicated airspeed (which depends on altitude) in meters per second (m/s)
- is 1.225 kg/m³, the air density at sea level and 15 degrees Celsius
- stagnation or total pressure inside the pitot / Prandl tube, in Pascal, which is Newton per square meter (Pa → N/m²)
- static pressure, the pressure measured on the side of the airplane/tube, in Pascal, which is Newton per square meter (Pa → N/m²)

If you now expand the formula units using the unit definitions above, you end up (like expected) with m/s as unit of speed.

### Calculating True Airspeed for low speeds

The true airspeed is the vehicle's forward ground speed combined with wind speed. Please note that the wind has a direction, so the true airspeed contains only the part of the wind speed along the pitot tube axis. Please also note that the overall ground speed (including movements to the side through wind drift) is not equal to the true airspeed, as e.g. wind from the side can induce a speed with respect to the ground, which is not measured by the true airspeed.

*To estimate the true ground speed, it is best to fuse GPS speed and true airspeed into a consistent ground speed estimate (not covered in this article).*

The formula below applies for low speeds (lower subsonic range).

Where

- is the indicated airspeed (in m/s, which depends on altitude)
- is the true airspeed (in m/s)
- is 1.225 kg/m³, the air density at sea level and 15 degrees Celsius
- is the air density at the current altitude (in kg/m³, can be calculated from GPS altitude and/or barometric absolute pressure)

In this equation the kg/m³ cancels out and thus stays m/s from .

### Air Density for a specific temperature

This measure is used to compensate the speed calculation at different altitudes.

Where

- Is the density at this temperature in kg/m³
- Is the current static pressure in Pascal
- Is the specific gas constant for air, 287.1 J/(kg K)
- Is the current temperature in Kelvin (absolute temperature)

To get the absolute temperature, add 273,15 Kelvin to the temperature in degrees celcius

### C-Code

Indicated airspeed calculation with IEE754 single precision floating point format. You can change the function inputs from float to e.g. int32 to simplify the calculation.

/** * Calculate indicated airspeed. * * 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. * * @param differential_pressure total_ pressure - static pressure * @return indicated airspeed in m/s */ float calc_indicated_airspeed(float differential_pressure) { if (differential_pressure > 0) { return sqrtf((2.0f*differential_pressure) / CONSTANTS_AIR_DENSITY_SEA_LEVEL_15C); } else { return -sqrtf((2.0f*fabs(differential_pressure)) / CONSTANTS_AIR_DENSITY_SEA_LEVEL_15C); } } /** * Calculate true airspeed from indicated airspeed. * * Note that the true airspeed is NOT the groundspeed, because of the effects of wind * * @param speed_indicated current indicated 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 */ float calc_true_airspeed_from_indicated(float speed_indicated, float pressure_ambient, float temperature_celsius) { return speed_indicated * sqrtf(CONSTANTS_AIR_DENSITY_SEA_LEVEL_15C / get_air_density(pressure_ambient, temperature_celsius)); } /** * Directly calculate true airspeed * * 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 density = get_air_density(static_pressure, temperature_celsius); if (density < 0.0001f || !isfinite(density)) { density = CONSTANTS_AIR_DENSITY_SEA_LEVEL_15C; printf("[airspeed] Invalid air density, using density at sea level\n"); } float pressure_difference = total_pressure - static_pressure; if(pressure_difference > 0) { return sqrtf((2.0f*(pressure_difference)) / density); } else { return -sqrtf((2.0f*fabs(pressure_difference)) / density); } }

# Altitude

The current flight altitude can be calculated/estimated by measuring the absolute pressure around the airplane (at the sides of the plane/pitot/prandl tube) and by taking the current weather conditions (pressure) into account. In the MAV context this will be most likely done by calibrating the ground altitude before liftoff.

### Calculating the pressure altitude

To calculate the pressure altitude, the barometric formula has to be used. If the MAV is only active between 0 and 11000 meters (0-36'000 feet), it can be simplified. *For almost all MAVs the simplified version below is thus recommended to use.*

#### General Barometric Formula

The barometric formula that relates pressue and altitude is:

We solve it for the height :

Where:

- is the measured static pressure in Pascal (Pa, N/m²)
- is the pressure on bottom of layer
*b*in Pascal (Pa, N/m²) - is the temperature on bottom of layer
*b*in Kelvin (K) - is the gravity acceleration, 9.80665 m/s²
- is the molar mass of the earth's atmosphere, 0.0289644 kg/mol
- is the universal gas constant for air, 8.31432 N·m /(mol·K)
- is the temperature lapse rate in Kelvin per meter (K/m)
- is the current altitude in meters
- is the height at the bottom of layer
*b*in meters