You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: core/src/earth.rs
+61-29Lines changed: 61 additions & 29 deletions
Original file line number
Diff line number
Diff line change
@@ -32,21 +32,9 @@
32
32
//! are primarily used to convert between the ECEF and local-level frames. The rotations
33
33
//! from the local level frame to the body frame can be taken care of by the `nalgebra`
34
34
//! crate, which provides the necessary rotation matrices using the Rotation3 type.
35
-
36
-
// ----------
37
-
// Working notes:
38
-
// The canonical strapdown navigation state vector is WGS84 geodetic position (latitude, longitude, altitude) and local tangent plane (NED) velocities (north, east,
39
-
// down). The state vector is updated by integrating the IMU measurements (body frame) to estimate the position and velocity of the sensor. Velocities are updated
40
-
// in NED, whereas the positions are updated in WGS84.
41
-
// ----------
42
-
// Rotations can be handled using nalgebra's Rotation3 type, which can be converted to a DCM using the into() method. The Rotation3 type can be created from
43
-
// Euler angles for the body to local-level frame rotation. The inverse of the Rotation3 type can be used to convert from the local-level frame to the body frame.
44
-
// ----------
45
35
usecrate::{wrap_latitude, wrap_to_180};
46
36
use::nalgebra::{Matrix3,Vector3};
47
37
use::nav_types::{ECEF,WGS84};
48
-
49
-
// Earth constants (WGS84)
50
38
/// Earth's rotation rate rad/s ($\omega_{ie}$)
51
39
pubconstRATE:f64 = 7.2921159e-5;
52
40
/// Earth's rotation rate rad/s ($\omega_{ie}$) in a vector form
/// Rough conversion factor from degrees to meters for latitude/longitude via nautical miles (1 degree ~ 60 nautical miles; 1 nautical mile ~ 1852 meters)
84
74
pubconstDEGREES_TO_METERS:f64 = 60.0*1852.0;
85
-
75
+
/// Sea-level atmospheric pressure in pascals
76
+
pubconstSEA_LEVEL_PRESSURE:f64 = 101325.0;// Pa, standard sea-level pressure
77
+
/// Temperature lapse rate in Kelvin per meter
78
+
pubconstTEMPERATURE_LAPSE_RATE:f64 = 0.00976;// K/m, standard temperature lapse rate in the troposphere
79
+
/// Constant-pressure specific heat
80
+
pubconstCONSTANT_PRESSURE_SPECIFIC_HEAT:f64 = 1004.68506;// J/(kg·K), specific heat at constant pressure for dry air
81
+
/// Sea level standard temperature in Kelvin
82
+
pubconstSEA_LEVEL_STANDARD_TEMPERATURE:f64 = 288.15;// K, standard sea-level temperature
83
+
/// Molar mass of dry air in kg/mol
84
+
pubconstMOLAR_MASS_DRY_AIR:f64 = 0.02896968;// kg/mol, molar mass of dry air
85
+
/// Universal gas constant in J/(mol·K)
86
+
pubconstUNIVERSAL_GAS_CONSTANT:f64 = 8.314462618;// J/(mol·K), universal gas constant
87
+
/// Calculate the barometric altitude from pressure and temperature
88
+
///
89
+
/// This function calculates the barometric altitude using the barometric formula, which relates
90
+
/// the pressure at a given altitude to the pressure at sea level. The formula is based on the
91
+
/// assumption of an isothermal atmosphere and the ideal gas law.
92
+
///
93
+
/// # Arguments
94
+
/// - `pressure` - The atmospheric pressure at the given altitude in pascals
95
+
///
96
+
/// # Returns
97
+
/// The barometric altitude in meters
98
+
pubfnbarometric_altitude(pressure:f64) -> f64{
99
+
let exponent:f64 = -((UNIVERSAL_GAS_CONSTANT*TEMPERATURE_LAPSE_RATE) / (G0*MOLAR_MASS_DRY_AIR));
0 commit comments