Hummingbird Flight Software
Flight software for the Hummingbird FCU quadcopter flight controller. Designed to run on the Teensy 4.1. Developed with VSCode+PlatformIO.
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
BaroAltimeter Class Reference

#include <baro_altimeter.h>

Inheritance diagram for BaroAltimeter:

Public Member Functions

 BaroAltimeter ()
 This class encompasses all functions to create a barometric altimeter for the drone, based on Adafruit's BMP388 sensor library. More...
 
bool ConnectToSensor (TwoWire *userWire=&Wire2)
 Attempt to connect to the BMP388 pressure/temperature sensor by running Adafruit's BMP_3XX.begin() method. More...
 
bool ConfigureSensorParams (uint8_t presOS=BMP3_NO_OVERSAMPLING, uint8_t tempOS=BMP3_NO_OVERSAMPLING, uint8_t iirCoef=BMP3_IIR_FILTER_COEFF_3, uint8_t sensODR=BMP3_ODR_50_HZ)
 Configure BMP388 oversampling, IIR filtering, and ODR. More...
 
bool Initialize ()
 Initialize the altimeter class. More...
 
bool SetMSLPres (float presMSL_Pa=101325.0f)
 
bool ReadSensor ()
 Read raw pressure and temperature data from BMP388. More...
 
float GetMSLPres ()
 
float GetAltitudeMSL ()
 
float GetAltitude ()
 
float GetLaunchAltMSL ()
 
float GetGroundPres ()
 
float GetGroundTemp ()
 
float GetPressure ()
 
float GetTemp ()
 
float GetVertSpeed ()
 

Public Attributes

bool isMSLPSet
 
bool isConnected
 
bool isConfigured
 
bool isReady
 

Private Member Functions

bool _ReadGroundPresTemp (uint8_t n, unsigned long measDelay)
 Measure the ground-level pressure and temperature by taking the average of a few readings. More...
 
bool _SetTakeoffAltitude ()
 Compute the altitude above MSL at the T/O location. More...
 

Private Attributes

float _p
 
float _pRaw
 
float _t
 
float _tRaw
 
float _altMSL
 
float _lastAltMSL
 
float _alt
 
float _groundPres
 
float _groundTemp
 
float _groundAltMSL
 
float _mslPres
 
float _vertSpeed
 
unsigned long _lastMeasMillis
 
unsigned long _currMeasMillis
 
MedianFilter _PresFastFilter
 
LowPassFilter _PresSlowFilter
 
LowPassFilter _TempSlowFilter
 

Constructor & Destructor Documentation

◆ BaroAltimeter()

BaroAltimeter::BaroAltimeter ( )

This class encompasses all functions to create a barometric altimeter for the drone, based on Adafruit's BMP388 sensor library.

This class is responsible for:

  • Initializing the sensor
  • Reading pressure and temperature
  • Filtering raw measurements
  • Computing change in altitude from T/O location
  • Computing vertical speed

Member Function Documentation

◆ _ReadGroundPresTemp()

bool BaroAltimeter::_ReadGroundPresTemp ( uint8_t  n,
unsigned long  measDelay 
)
private

Measure the ground-level pressure and temperature by taking the average of a few readings.

Parameters
nNumber of measurements to take
measDelayArduino 'delay()' between measurements in milliseconds
Returns
True if success, false if not.

◆ _SetTakeoffAltitude()

bool BaroAltimeter::_SetTakeoffAltitude ( )
private

Compute the altitude above MSL at the T/O location.

Uses equation from Ardupilot's source code.

◆ ConfigureSensorParams()

bool BaroAltimeter::ConfigureSensorParams ( uint8_t  presOS = BMP3_NO_OVERSAMPLING,
uint8_t  tempOS = BMP3_NO_OVERSAMPLING,
uint8_t  iirCoef = BMP3_IIR_FILTER_COEFF_3,
uint8_t  sensODR = BMP3_ODR_50_HZ 
)

Configure BMP388 oversampling, IIR filtering, and ODR.

Refer to Adafruit_BMP_3XX.h for config. options

Parameters
presOSPressure oversampling
tempSOTemperature oversampling
iirCoefInfinite impulse response (IIR) filter coef.
sensODROutput data rate [Hz]
Returns
True if successfully configured, false if not.

◆ ConnectToSensor()

bool BaroAltimeter::ConnectToSensor ( TwoWire *  userWire = &Wire2)

Attempt to connect to the BMP388 pressure/temperature sensor by running Adafruit's BMP_3XX.begin() method.

Returns false if it could't connect to the sensor.

Parameters
userWireI2C bus that the sensor is connected to. Default Wire2.
Returns
True if success, false if not.

◆ GetAltitude()

float BaroAltimeter::GetAltitude ( )

◆ GetAltitudeMSL()

float BaroAltimeter::GetAltitudeMSL ( )

◆ GetGroundPres()

float BaroAltimeter::GetGroundPres ( )

◆ GetGroundTemp()

float BaroAltimeter::GetGroundTemp ( )

◆ GetLaunchAltMSL()

float BaroAltimeter::GetLaunchAltMSL ( )

◆ GetMSLPres()

float BaroAltimeter::GetMSLPres ( )

◆ GetPressure()

float BaroAltimeter::GetPressure ( )

◆ GetTemp()

float BaroAltimeter::GetTemp ( )

◆ GetVertSpeed()

float BaroAltimeter::GetVertSpeed ( )

◆ Initialize()

bool BaroAltimeter::Initialize ( )

Initialize the altimeter class.

Measures ground temperature and pressure and sets takeoff altitude parameters.

Returns
True if successful, flase if not.

◆ ReadSensor()

bool BaroAltimeter::ReadSensor ( )

Read raw pressure and temperature data from BMP388.

Returns
True if a valid reading was done, false if not.

◆ SetMSLPres()

bool BaroAltimeter::SetMSLPres ( float  presMSL_Pa = 101325.0f)

Member Data Documentation

◆ _alt

float BaroAltimeter::_alt
private

◆ _altMSL

float BaroAltimeter::_altMSL
private

◆ _currMeasMillis

unsigned long BaroAltimeter::_currMeasMillis
private

◆ _groundAltMSL

float BaroAltimeter::_groundAltMSL
private

◆ _groundPres

float BaroAltimeter::_groundPres
private

◆ _groundTemp

float BaroAltimeter::_groundTemp
private

◆ _lastAltMSL

float BaroAltimeter::_lastAltMSL
private

◆ _lastMeasMillis

unsigned long BaroAltimeter::_lastMeasMillis
private

◆ _mslPres

float BaroAltimeter::_mslPres
private

◆ _p

float BaroAltimeter::_p
private

◆ _pRaw

float BaroAltimeter::_pRaw
private

◆ _PresFastFilter

MedianFilter BaroAltimeter::_PresFastFilter
private

◆ _PresSlowFilter

LowPassFilter BaroAltimeter::_PresSlowFilter
private

◆ _t

float BaroAltimeter::_t
private

◆ _TempSlowFilter

LowPassFilter BaroAltimeter::_TempSlowFilter
private

◆ _tRaw

float BaroAltimeter::_tRaw
private

◆ _vertSpeed

float BaroAltimeter::_vertSpeed
private

◆ isConfigured

bool BaroAltimeter::isConfigured

◆ isConnected

bool BaroAltimeter::isConnected

◆ isMSLPSet

bool BaroAltimeter::isMSLPSet

◆ isReady

bool BaroAltimeter::isReady

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