APM:Libraries
Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
AP_Baro Class Reference

#include <AP_Baro.h>

Collaboration diagram for AP_Baro:
[legend]

Classes

struct  sensor
 

Public Types

enum  baro_type_t { BARO_TYPE_AIR, BARO_TYPE_WATER }
 

Public Member Functions

 AP_Baro ()
 
 AP_Baro (const AP_Baro &other)=delete
 
AP_Barooperator= (const AP_Baro &)=delete
 
void init (void)
 
void update (void)
 
bool healthy (void) const
 
bool healthy (uint8_t instance) const
 
bool all_healthy (void) const
 
float get_pressure (void) const
 
float get_pressure (uint8_t instance) const
 
float get_temperature (void) const
 
float get_temperature (uint8_t instance) const
 
float get_pressure_correction (void) const
 
float get_pressure_correction (uint8_t instance) const
 
void accumulate (void)
 
void calibrate (bool save=true)
 
void update_calibration (void)
 
float get_altitude (void) const
 
float get_altitude (uint8_t instance) const
 
float get_altitude_difference (float base_pressure, float pressure) const
 
float get_EAS2TAS (void)
 
float get_air_density_ratio (void)
 
float get_climb_rate (void)
 
float get_ground_temperature (void) const
 
float get_ground_pressure (void) const
 
float get_ground_pressure (uint8_t i) const
 
void set_external_temperature (float temperature)
 
uint32_t get_last_update (void) const
 
uint32_t get_last_update (uint8_t instance) const
 
float get_external_temperature (void) const
 
float get_external_temperature (const uint8_t instance) const
 
void setHIL (float altitude_msl)
 
void setHIL (uint8_t instance, float pressure, float temperature, float altitude, float climb_rate, uint32_t last_update_ms)
 
void set_primary_baro (uint8_t primary)
 
void set_type (uint8_t instance, baro_type_t type)
 
baro_type_t get_type (uint8_t instance)
 
uint8_t register_sensor (void)
 
uint8_t num_instances (void) const
 
void set_hil_mode (void)
 
void set_baro_drift_altitude (float alt)
 
float get_baro_drift_offset (void)
 
void set_pressure_correction (uint8_t instance, float p_correction)
 
uint8_t get_filter_range () const
 
void set_log_baro_bit (uint32_t bit)
 
bool should_df_log () const
 

Static Public Member Functions

static AP_Baroget_instance (void)
 
static void SimpleAtmosphere (const float alt, float &sigma, float &delta, float &theta)
 
static void SimpleUnderWaterAtmosphere (float alt, float &rho, float &delta, float &theta)
 

Public Attributes

struct {
   float   pressure
 
   float   temperature
 
   float   altitude
 
   float   climb_rate
 
   uint32_t   last_update_ms
 
   bool   updated:1
 
   bool   have_alt:1
 
   bool   have_last_update:1
 
_hil
 

Static Public Attributes

static const struct AP_Param::GroupInfo var_info []
 

Private Member Functions

bool _add_backend (AP_Baro_Backend *backend)
 

Private Attributes

uint8_t _num_drivers
 
AP_Baro_Backenddrivers [BARO_MAX_DRIVERS]
 
uint8_t _num_sensors
 
uint8_t _primary
 
uint32_t _log_baro_bit = -1
 
struct AP_Baro::sensor sensors [BARO_MAX_INSTANCES]
 
AP_Float _alt_offset
 
float _alt_offset_active
 
AP_Int8 _primary_baro
 
AP_Int8 _ext_bus
 
float _last_altitude_EAS2TAS
 
float _EAS2TAS
 
float _external_temperature
 
uint32_t _last_external_temperature_ms
 
DerivativeFilterFloat_Size7 _climb_rate_filter
 
AP_Float _specific_gravity
 
AP_Float _user_ground_temperature
 
bool _hil_mode:1
 
float _guessed_ground_temperature
 
uint32_t _last_notify_ms
 
AP_Int8 _filter_range
 

Static Private Attributes

static AP_Baro_instance
 

Friends

class AP_Baro_Backend
 
class AP_Baro_SITL
 

Detailed Description

Definition at line 21 of file AP_Baro.h.

Member Enumeration Documentation

◆ baro_type_t

Enumerator
BARO_TYPE_AIR 
BARO_TYPE_WATER 

Definition at line 39 of file AP_Baro.h.

Constructor & Destructor Documentation

◆ AP_Baro() [1/2]

AP_Baro::AP_Baro ( )

Definition at line 155 of file AP_Baro.cpp.

Here is the call graph for this function:

◆ AP_Baro() [2/2]

AP_Baro::AP_Baro ( const AP_Baro other)
delete

Member Function Documentation

◆ _add_backend()

bool AP_Baro::_add_backend ( AP_Baro_Backend backend)
private

Definition at line 371 of file AP_Baro.cpp.

Referenced by init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ accumulate()

void AP_Baro::accumulate ( void  )

Definition at line 694 of file AP_Baro.cpp.

Referenced by get_pressure_correction(), and loop().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ all_healthy()

bool AP_Baro::all_healthy ( void  ) const

Definition at line 717 of file AP_Baro.cpp.

Referenced by healthy().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ calibrate()

void AP_Baro::calibrate ( bool  save = true)

Definition at line 164 of file AP_Baro.cpp.

Referenced by get_pressure_correction(), and setup().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_air_density_ratio()

float AP_Baro::get_air_density_ratio ( void  )

Definition at line 306 of file AP_Baro.cpp.

Referenced by get_altitude().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_altitude() [1/2]

float AP_Baro::get_altitude ( void  ) const
inline

Definition at line 84 of file AP_Baro.h.

Referenced by HALSITL::SITL_State::_simulator_servos(), get_altitude(), get_EAS2TAS(), AP_AHRS_DCM::get_position(), AP_AHRS_DCM::get_relative_position_D_home(), AP_AHRS_NavEKF::get_relative_position_D_home(), DataFlash_Class::Log_Write_Baro_instance(), loop(), NavEKF2_core::readBaroData(), NavEKF3_core::readBaroData(), update(), and AP_TECS::update_50hz().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_altitude() [2/2]

float AP_Baro::get_altitude ( uint8_t  instance) const
inline

Definition at line 85 of file AP_Baro.h.

Here is the call graph for this function:

◆ get_altitude_difference()

float AP_Baro::get_altitude_difference ( float  base_pressure,
float  pressure 
) const

Definition at line 271 of file AP_Baro.cpp.

Referenced by AP_AdvancedFailsafe::check_altlimit(), get_altitude(), AP_ADSB::send_dynamic_out(), and update().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_baro_drift_offset()

float AP_Baro::get_baro_drift_offset ( void  )
inline

Definition at line 167 of file AP_Baro.h.

Referenced by DataFlash_Class::Log_Write_Baro_instance().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_climb_rate()

float AP_Baro::get_climb_rate ( void  )

Definition at line 319 of file AP_Baro.cpp.

Referenced by get_altitude(), DataFlash_Class::Log_Write_Baro_instance(), and loop().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_EAS2TAS()

float AP_Baro::get_EAS2TAS ( void  )

Definition at line 288 of file AP_Baro.cpp.

Referenced by get_air_density_ratio(), and get_altitude().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_external_temperature() [1/2]

float AP_Baro::get_external_temperature ( void  ) const
inline

Definition at line 122 of file AP_Baro.h.

Referenced by calibrate(), get_external_temperature(), and update_calibration().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_external_temperature() [2/2]

float AP_Baro::get_external_temperature ( const uint8_t  instance) const

Definition at line 353 of file AP_Baro.cpp.

Here is the call graph for this function:

◆ get_filter_range()

uint8_t AP_Baro::get_filter_range ( ) const
inline

Definition at line 178 of file AP_Baro.h.

Referenced by AP_Baro_Backend::pressure_ok().

Here is the caller graph for this function:

◆ get_ground_pressure() [1/2]

float AP_Baro::get_ground_pressure ( void  ) const
inline

Definition at line 107 of file AP_Baro.h.

Referenced by get_ground_pressure(), GCS_MAVLINK::send_scaled_pressure(), and GCS_MAVLINK::send_scaled_pressure3().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_ground_pressure() [2/2]

float AP_Baro::get_ground_pressure ( uint8_t  i) const
inline

Definition at line 108 of file AP_Baro.h.

Here is the call graph for this function:

◆ get_ground_temperature()

float AP_Baro::get_ground_temperature ( void  ) const

Definition at line 331 of file AP_Baro.cpp.

Referenced by get_altitude(), get_altitude_difference(), get_EAS2TAS(), and DataFlash_Class::Log_Write_Baro_instance().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_instance()

static AP_Baro* AP_Baro::get_instance ( void  )
inlinestatic

Definition at line 34 of file AP_Baro.h.

Referenced by AP_Airspeed_SDP3X::_correct_pressure(), and AP::baro().

Here is the caller graph for this function:

◆ get_last_update() [1/2]

uint32_t AP_Baro::get_last_update ( void  ) const
inline

Definition at line 116 of file AP_Baro.h.

Referenced by AP_AdvancedFailsafe::check_altlimit(), get_last_update(), DataFlash_Class::Log_Write_Baro_instance(), NavEKF2_core::readBaroData(), NavEKF3_core::readBaroData(), and update().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_last_update() [2/2]

uint32_t AP_Baro::get_last_update ( uint8_t  instance) const
inline

Definition at line 117 of file AP_Baro.h.

◆ get_pressure() [1/2]

float AP_Baro::get_pressure ( void  ) const
inline

Definition at line 59 of file AP_Baro.h.

Referenced by AP_Airspeed_SDP3X::_correct_pressure(), HALSITL::SITL_State::_update_airspeed(), AP_AdvancedFailsafe::check_altlimit(), get_EAS2TAS(), get_pressure(), AP_TempCalibration::learn_calibration(), DataFlash_Class::Log_Write_Baro_instance(), loop(), AP_ADSB::send_dynamic_out(), GCS_MAVLINK::send_scaled_pressure(), GCS_MAVLINK::send_scaled_pressure3(), GCS_MAVLINK::send_sensor_offsets(), and update_calibration().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_pressure() [2/2]

float AP_Baro::get_pressure ( uint8_t  instance) const
inline

Definition at line 60 of file AP_Baro.h.

◆ get_pressure_correction() [1/2]

float AP_Baro::get_pressure_correction ( void  ) const
inline

Definition at line 67 of file AP_Baro.h.

Referenced by get_pressure_correction().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_pressure_correction() [2/2]

float AP_Baro::get_pressure_correction ( uint8_t  instance) const
inline

Definition at line 68 of file AP_Baro.h.

Here is the call graph for this function:

◆ get_temperature() [1/2]

float AP_Baro::get_temperature ( void  ) const
inline

Definition at line 63 of file AP_Baro.h.

Referenced by AP_TempCalibration::apply_calibration(), get_external_temperature(), get_temperature(), AP_TempCalibration::learn_calibration(), DataFlash_Class::Log_Write_Baro_instance(), loop(), GCS_MAVLINK::send_scaled_pressure(), GCS_MAVLINK::send_scaled_pressure3(), GCS_MAVLINK::send_sensor_offsets(), and AP_TempCalibration::setup_learning().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_temperature() [2/2]

float AP_Baro::get_temperature ( uint8_t  instance) const
inline

Definition at line 64 of file AP_Baro.h.

◆ get_type()

baro_type_t AP_Baro::get_type ( uint8_t  instance)
inline

Definition at line 139 of file AP_Baro.h.

◆ healthy() [1/2]

bool AP_Baro::healthy ( void  ) const
inline

Definition at line 52 of file AP_Baro.h.

Referenced by all_healthy(), AP_TempCalibration::apply_calibration(), calibrate(), healthy(), AP_TempCalibration::learn_calibration(), DataFlash_Class::Log_Write_Baro(), loop(), AP_ADSB::send_dynamic_out(), update(), and update_calibration().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ healthy() [2/2]

bool AP_Baro::healthy ( uint8_t  instance) const
inline

Definition at line 53 of file AP_Baro.h.

Here is the call graph for this function:

◆ init()

void AP_Baro::init ( void  )

Definition at line 398 of file AP_Baro.cpp.

Referenced by setup().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ num_instances()

uint8_t AP_Baro::num_instances ( void  ) const
inline

Definition at line 158 of file AP_Baro.h.

Referenced by DataFlash_Class::Log_Write_Baro(), GCS_MAVLINK::send_scaled_pressure(), and GCS_MAVLINK::send_scaled_pressure3().

Here is the caller graph for this function:

◆ operator=()

AP_Baro& AP_Baro::operator= ( const AP_Baro )
delete

◆ register_sensor()

uint8_t AP_Baro::register_sensor ( void  )

Definition at line 705 of file AP_Baro.cpp.

Referenced by AP_Baro_BMP085::_init(), AP_Baro_BMP280::_init(), AP_Baro_LPS2XH::_init(), AP_Baro_MS56XX::_init(), AP_Baro_KellerLD::_init(), AP_Baro_HIL::AP_Baro_HIL(), AP_Baro_SITL::AP_Baro_SITL(), AP_Baro_FBM320::init(), AP_Baro_DPS280::init(), and AP_Baro_ICM20789::init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_baro_drift_altitude()

void AP_Baro::set_baro_drift_altitude ( float  alt)
inline

Definition at line 164 of file AP_Baro.h.

◆ set_external_temperature()

void AP_Baro::set_external_temperature ( float  temperature)

Definition at line 344 of file AP_Baro.cpp.

Referenced by get_ground_pressure().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_hil_mode()

void AP_Baro::set_hil_mode ( void  )
inline

Definition at line 161 of file AP_Baro.h.

◆ set_log_baro_bit()

void AP_Baro::set_log_baro_bit ( uint32_t  bit)
inline

Definition at line 181 of file AP_Baro.h.

Here is the call graph for this function:

◆ set_pressure_correction()

void AP_Baro::set_pressure_correction ( uint8_t  instance,
float  p_correction 
)

Definition at line 728 of file AP_Baro.cpp.

Referenced by AP_TempCalibration::apply_calibration(), and get_baro_drift_offset().

Here is the caller graph for this function:

◆ set_primary_baro()

void AP_Baro::set_primary_baro ( uint8_t  primary)
inline

Definition at line 133 of file AP_Baro.h.

◆ set_type()

void AP_Baro::set_type ( uint8_t  instance,
baro_type_t  type 
)
inline

Definition at line 136 of file AP_Baro.h.

Referenced by AP_Baro_MS56XX::_init(), AP_Baro_KellerLD::_init(), and AP_Baro_SITL::AP_Baro_SITL().

Here is the caller graph for this function:

◆ setHIL() [1/2]

void AP_Baro::setHIL ( float  altitude_msl)

Definition at line 83 of file AP_Baro_HIL.cpp.

Referenced by get_external_temperature().

Here is the caller graph for this function:

◆ setHIL() [2/2]

void AP_Baro::setHIL ( uint8_t  instance,
float  pressure,
float  temperature,
float  altitude,
float  climb_rate,
uint32_t  last_update_ms 
)

Definition at line 99 of file AP_Baro_HIL.cpp.

◆ should_df_log()

bool AP_Baro::should_df_log ( ) const

Definition at line 603 of file AP_Baro.cpp.

Referenced by set_log_baro_bit(), and update().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SimpleAtmosphere()

void AP_Baro::SimpleAtmosphere ( const float  alt,
float &  sigma,
float &  delta,
float &  theta 
)
static

Definition at line 20 of file AP_Baro_HIL.cpp.

Referenced by AP_Baro_SITL::_timer(), and get_baro_drift_offset().

Here is the caller graph for this function:

◆ SimpleUnderWaterAtmosphere()

void AP_Baro::SimpleUnderWaterAtmosphere ( float  alt,
float &  rho,
float &  delta,
float &  theta 
)
static

Definition at line 43 of file AP_Baro_HIL.cpp.

Referenced by AP_Baro_SITL::_timer(), and get_baro_drift_offset().

Here is the caller graph for this function:

◆ update()

void AP_Baro::update ( void  )

Definition at line 621 of file AP_Baro.cpp.

Referenced by calibrate(), and loop().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_calibration()

void AP_Baro::update_calibration ( void  )

Definition at line 246 of file AP_Baro.cpp.

Referenced by GCS_MAVLINK::_handle_command_preflight_calibration_baro(), get_pressure_correction(), NavEKF2_core::resetHeightDatum(), and NavEKF3_core::resetHeightDatum().

Here is the call graph for this function:
Here is the caller graph for this function:

Friends And Related Function Documentation

◆ AP_Baro_Backend

friend class AP_Baro_Backend
friend

Definition at line 23 of file AP_Baro.h.

◆ AP_Baro_SITL

friend class AP_Baro_SITL
friend

Definition at line 24 of file AP_Baro.h.

Referenced by init().

Member Data Documentation

◆ _alt_offset

AP_Float AP_Baro::_alt_offset
private

Definition at line 214 of file AP_Baro.h.

Referenced by calibrate(), set_baro_drift_altitude(), and update().

◆ _alt_offset_active

float AP_Baro::_alt_offset_active
private

Definition at line 215 of file AP_Baro.h.

Referenced by get_baro_drift_offset(), and update().

◆ _climb_rate_filter

DerivativeFilterFloat_Size7 AP_Baro::_climb_rate_filter
private

Definition at line 222 of file AP_Baro.h.

Referenced by get_climb_rate(), and update().

◆ _EAS2TAS

float AP_Baro::_EAS2TAS
private

Definition at line 219 of file AP_Baro.h.

Referenced by get_EAS2TAS(), and update_calibration().

◆ _ext_bus

AP_Int8 AP_Baro::_ext_bus
private

Definition at line 217 of file AP_Baro.h.

Referenced by init().

◆ _external_temperature

float AP_Baro::_external_temperature
private

Definition at line 220 of file AP_Baro.h.

Referenced by get_external_temperature(), and set_external_temperature().

◆ _filter_range

AP_Int8 AP_Baro::_filter_range
private

Definition at line 232 of file AP_Baro.h.

Referenced by get_filter_range().

◆ _guessed_ground_temperature

float AP_Baro::_guessed_ground_temperature
private

Definition at line 226 of file AP_Baro.h.

Referenced by calibrate(), get_ground_temperature(), and update_calibration().

◆ _hil

struct { ... } AP_Baro::_hil

◆ _hil_mode

bool AP_Baro::_hil_mode
private

Definition at line 225 of file AP_Baro.h.

Referenced by init(), set_hil_mode(), and update().

◆ _instance

AP_Baro * AP_Baro::_instance
staticprivate

Definition at line 186 of file AP_Baro.h.

Referenced by AP_Baro(), and get_instance().

◆ _last_altitude_EAS2TAS

float AP_Baro::_last_altitude_EAS2TAS
private

Definition at line 218 of file AP_Baro.h.

Referenced by get_EAS2TAS().

◆ _last_external_temperature_ms

uint32_t AP_Baro::_last_external_temperature_ms
private

Definition at line 221 of file AP_Baro.h.

Referenced by get_external_temperature(), and set_external_temperature().

◆ _last_notify_ms

uint32_t AP_Baro::_last_notify_ms
private

Definition at line 229 of file AP_Baro.h.

Referenced by update_calibration().

◆ _log_baro_bit

uint32_t AP_Baro::_log_baro_bit = -1
private

Definition at line 198 of file AP_Baro.h.

Referenced by set_log_baro_bit(), and should_df_log().

◆ _num_drivers

uint8_t AP_Baro::_num_drivers
private

Definition at line 189 of file AP_Baro.h.

Referenced by _add_backend(), accumulate(), init(), and update().

◆ _num_sensors

uint8_t AP_Baro::_num_sensors
private

◆ _primary

uint8_t AP_Baro::_primary
private

◆ _primary_baro

AP_Int8 AP_Baro::_primary_baro
private

Definition at line 216 of file AP_Baro.h.

Referenced by set_primary_baro(), and update().

◆ _specific_gravity

AP_Float AP_Baro::_specific_gravity
private

Definition at line 223 of file AP_Baro.h.

Referenced by update().

◆ _user_ground_temperature

AP_Float AP_Baro::_user_ground_temperature
private

Definition at line 224 of file AP_Baro.h.

Referenced by get_ground_temperature(), and init().

◆ altitude

float AP_Baro::altitude

Definition at line 145 of file AP_Baro.h.

Referenced by get_EAS2TAS(), get_external_temperature(), and update().

◆ climb_rate

float AP_Baro::climb_rate

Definition at line 146 of file AP_Baro.h.

Referenced by get_external_temperature().

◆ drivers

AP_Baro_Backend* AP_Baro::drivers[BARO_MAX_DRIVERS]
private

Definition at line 190 of file AP_Baro.h.

Referenced by _add_backend(), accumulate(), init(), and update().

◆ have_alt

bool AP_Baro::have_alt

Definition at line 149 of file AP_Baro.h.

◆ have_last_update

bool AP_Baro::have_last_update

Definition at line 150 of file AP_Baro.h.

◆ last_update_ms

uint32_t AP_Baro::last_update_ms

Definition at line 147 of file AP_Baro.h.

Referenced by get_external_temperature().

◆ pressure

float AP_Baro::pressure

Definition at line 143 of file AP_Baro.h.

Referenced by get_altitude(), and AP_Baro_HIL::update().

◆ sensors

struct AP_Baro::sensor AP_Baro::sensors[BARO_MAX_INSTANCES]
private

◆ temperature

float AP_Baro::temperature

Definition at line 144 of file AP_Baro.h.

Referenced by get_ground_pressure(), set_external_temperature(), and AP_Baro_HIL::update().

◆ updated

bool AP_Baro::updated

Definition at line 148 of file AP_Baro.h.

Referenced by AP_Baro_HIL::update().

◆ var_info

const AP_Param::GroupInfo AP_Baro::var_info
static

Definition at line 120 of file AP_Baro.h.

Referenced by AP_Baro().


The documentation for this class was generated from the following files: