Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Path: blob/master/libraries/AP_Baro/AP_Baro_HIL.cpp
Views: 1798
#include "AP_Baro.h"12#include <AP_HAL/AP_HAL.h>3#include <AP_Math/definitions.h>45extern const AP_HAL::HAL& hal;67// ==========================================================================8// based on tables.cpp from http://www.pdas.com/atmosdownload.html910void AP_Baro::SimpleUnderWaterAtmosphere(11float alt, // depth, km.12float& rho, // density/sea-level13float& delta, // pressure/sea-level standard pressure14float& theta) // temperature/sea-level standard temperature15{16// Values and equations based on:17// https://en.wikipedia.org/wiki/Standard_sea_level18const float seaDensity = 1.024f; // g/cm319const float maxSeaDensity = 1.028f; // g/cm320const float pAC = maxSeaDensity - seaDensity; // pycnocline angular coefficient2122// From: https://www.windows2universe.org/earth/Water/density.html23rho = seaDensity;24if (alt < 1.0f) {25// inside pycnocline26rho += pAC*alt;27} else {28rho += pAC;29}30rho = rho/seaDensity;3132// From: https://www.grc.nasa.gov/www/k-12/WindTunnel/Activities/fluid_pressure.html33// \f$P = \rho (kg) \cdot gravity (m/s2) \cdot depth (m)\f$34// \f$P_{atmosphere} = 101.325 kPa\f$35// \f$P_{total} = P_{atmosphere} + P_{fluid}\f$36delta = (SSL_AIR_PRESSURE + (seaDensity * 1e3) * GRAVITY_MSS * (alt * 1e3)) / SSL_AIR_PRESSURE;3738// From: http://residualanalysis.blogspot.com.br/2010/02/temperature-of-ocean-water-at-given.html39// \f$T(D)\f$ Temperature underwater at given temperature40// \f$S\f$ Surface temperature at the surface41// \f$T(D)\approx\frac{S}{1.8 \cdot 10^{-4} \cdot S \cdot T + 1}\f$42const float seaTempSurface = KELVIN_TO_C(SSL_AIR_TEMPERATURE); // Celsius43const float S = seaTempSurface * 0.338f;44theta = 1.0f / ((1.8e-4f) * S * (alt * 1e3f) + 1.0f);45}464748