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 | Static Public Member Functions | Public Attributes | Private Attributes | List of all members
MagCompass Class Reference

Decide whether or not to rotate magnetometer measurements. More...

#include <compass.h>

Public Member Functions

 MagCompass (TwoWire *userWire=&SENSOR_I2C)
 The compass class is in charge of taking magnetometer measurements and computing tilt-compensated (magnetic) heading. More...
 
 ~MagCompass ()
 
 MagCompass (const MagCompass &)=delete
 
MagCompassoperator= (const MagCompass &)=delete
 
bool Initialize ()
 Initialize the compass. More...
 
bool Update ()
 Update the compass. More...
 
float GetHeading (Vectorf AccelMeas)
 Compute and return tilt-compensated magnetic heading based on accelerometer data. More...
 

Static Public Member Functions

static MagCompassGetInstance ()
 

Public Attributes

uint32_t prevUpdateMicros
 
Vectorf Mag
 
Vectorf MagRaw
 

Private Attributes

float heading
 
LIS3MDL_Mag MagSensor
 
LIS3MDL_MeasRange_t magMeasRange
 
TwoWire * SensorWire
 

Detailed Description

Decide whether or not to rotate magnetometer measurements.

The Magnetometer in the GPS is upside down and rotated. By default, apply rotations to align measurements with the body frame.

Constructor & Destructor Documentation

◆ MagCompass() [1/2]

MagCompass::MagCompass ( TwoWire *  userWire = &SENSOR_I2C)

The compass class is in charge of taking magnetometer measurements and computing tilt-compensated (magnetic) heading.

Constructor for the compass class. Be sure to specify the I2C bus that the sensor is connected to.

Parameters
userWireI2C bus the compass is connected to. Default Wire2

◆ ~MagCompass()

MagCompass::~MagCompass ( )

◆ MagCompass() [2/2]

MagCompass::MagCompass ( const MagCompass )
delete

Member Function Documentation

◆ GetHeading()

float MagCompass::GetHeading ( Vectorf  AccelMeas)

Compute and return tilt-compensated magnetic heading based on accelerometer data.

Tilt-compensation equations can be found in: https://www.cypress.com/file/130456/download

Parameters
AccelMeas[m/s/s] Vectorf of accelerometer measurements
Returns
[rad] Tilt-compensated heading

◆ GetInstance()

MagCompass & MagCompass::GetInstance ( )
static

◆ Initialize()

bool MagCompass::Initialize ( )

Initialize the compass.

Configures magnetometer sensor.

Returns
True is success, false if not.

◆ operator=()

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

◆ Update()

bool MagCompass::Update ( )

Update the compass.

Record magnetometer data, rotate sensor data to the body frame, and apply calibration.

Returns
True if successful, false if not.

Member Data Documentation

◆ heading

float MagCompass::heading
private

◆ Mag

Vectorf MagCompass::Mag

◆ magMeasRange

LIS3MDL_MeasRange_t MagCompass::magMeasRange
private

◆ MagRaw

Vectorf MagCompass::MagRaw

◆ MagSensor

LIS3MDL_Mag MagCompass::MagSensor
private

◆ prevUpdateMicros

uint32_t MagCompass::prevUpdateMicros

◆ SensorWire

TwoWire* MagCompass::SensorWire
private

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