Fang-Robotics-MCB
Fang Robotics Team Codebase
Loading...
Searching...
No Matches
tap::communication::sensors::imu::AbstractIMU Class Referenceabstract

#include <abstract_imu.hpp>

Inheritance diagram for tap::communication::sensors::imu::AbstractIMU:
Collaboration diagram for tap::communication::sensors::imu::AbstractIMU:

Classes

struct  ImuData
 

Public Member Functions

 AbstractIMU (const Transform &mountingTransform=Transform::identity())
 
void setMountingTransform (const Transform &transform)
 
virtual ~AbstractIMU ()=default
 
virtual void initialize (float sampleFrequency, float mahonyKp, float mahonyKi)
 
virtual void requestCalibration ()
 
virtual void periodicIMUUpdate ()
 
virtual ImuState getImuState () const
 
mockable float getAx () const override
 
mockable float getAy () const override
 
mockable float getAz () const override
 
mockable float getAzMinusG () const
 
mockable float getGx () const override
 
mockable float getGy () const override
 
mockable float getGz () const override
 
mockable float getTemp () const
 
virtual float getYaw () const override
 
virtual float getPitch () const override
 
virtual float getRoll () const override
 
void setCalibrationSamples (int sampleCount)
 
- Public Member Functions inherited from tap::communication::sensors::imu::ImuInterface
virtual const char * getName () const =0
 

Protected Member Functions

void resetOffsets ()
 
void computeOffsets ()
 
void setAccelOffset (float x, float y, float z)
 
void setGyroOffset (float x, float y, float z)
 
void applyTransform (ImuData &data)
 
virtual float getAccelerationSensitivity () const =0
 

Protected Attributes

tap::algorithms::transforms::Transform mountingTransform
 
Mahony mahonyAlgorithm
 
ImuState imuState = ImuState::IMU_NOT_CONNECTED
 
int calibrationSample = 0
 
int offsetSampleCount = 1000
 
ImuData imuData
 
tap::arch::PeriodicMicroTimer readTimeout
 
uint32_t prevIMUDataReceivedTime = 0
 

Additional Inherited Members

- Public Types inherited from tap::communication::sensors::imu::ImuInterface
enum class  ImuState { IMU_NOT_CONNECTED , IMU_NOT_CALIBRATED , IMU_CALIBRATING , IMU_CALIBRATED }
 

Detailed Description

A class that represents any directly connected IMU.

Constructor & Destructor Documentation

◆ AbstractIMU()

tap::communication::sensors::imu::AbstractIMU::AbstractIMU ( const Transform mountingTransform = Transform::identity())
inline

◆ ~AbstractIMU()

virtual tap::communication::sensors::imu::AbstractIMU::~AbstractIMU ( )
virtualdefault

Member Function Documentation

◆ applyTransform()

void tap::communication::sensors::imu::AbstractIMU::applyTransform ( ImuData data)
inlineprotected

◆ computeOffsets()

void tap::communication::sensors::imu::AbstractIMU::computeOffsets ( )
protected

◆ getAccelerationSensitivity()

virtual float tap::communication::sensors::imu::AbstractIMU::getAccelerationSensitivity ( ) const
inlineprotectedpure virtual

◆ getAx()

mockable float tap::communication::sensors::imu::AbstractIMU::getAx ( ) const
inlineoverridevirtual

Returns the linear acceleration in the x direction, in $\frac{\mbox{m}}{\mbox{second}^2}$.

Implements tap::communication::sensors::imu::ImuInterface.

◆ getAy()

mockable float tap::communication::sensors::imu::AbstractIMU::getAy ( ) const
inlineoverridevirtual

Returns the linear acceleration in the y direction, in $\frac{\mbox{m}}{\mbox{second}^2}$.

Implements tap::communication::sensors::imu::ImuInterface.

◆ getAz()

mockable float tap::communication::sensors::imu::AbstractIMU::getAz ( ) const
inlineoverridevirtual

Returns the linear acceleration in the z direction, in $\frac{\mbox{m}}{\mbox{second}^2}$.

Implements tap::communication::sensors::imu::ImuInterface.

◆ getAzMinusG()

mockable float tap::communication::sensors::imu::AbstractIMU::getAzMinusG ( ) const
inline

◆ getGx()

mockable float tap::communication::sensors::imu::AbstractIMU::getGx ( ) const
inlineoverridevirtual

Returns the gyroscope reading (rotational speed) in the x direction, in $\frac{\mbox{radians}}{\mbox{second}}$.

Implements tap::communication::sensors::imu::ImuInterface.

◆ getGy()

mockable float tap::communication::sensors::imu::AbstractIMU::getGy ( ) const
inlineoverridevirtual

Returns the gyroscope reading (rotational speed) in the y direction, in $\frac{\mbox{radians}}{\mbox{second}}$.

Implements tap::communication::sensors::imu::ImuInterface.

◆ getGz()

mockable float tap::communication::sensors::imu::AbstractIMU::getGz ( ) const
inlineoverridevirtual

Returns the gyroscope reading (rotational speed) in the z direction, in $\frac{\mbox{radians}}{\mbox{second}}$.

Implements tap::communication::sensors::imu::ImuInterface.

◆ getImuState()

virtual ImuState tap::communication::sensors::imu::AbstractIMU::getImuState ( ) const
inlinevirtual

Returns the state of the IMU. Can be not connected, connected but not calibrated, or calibrated. When not connected, IMU data will be garbage. When not calibrated, IMU data is valid but the computed yaw angle data will drift. When calibrating, the IMU data is invalid. When calibrated, the IMU data is valid and assuming proper calibration the IMU data should not drift.

To be safe, whenever you call the functions below, call this function to ensure the data you are about to receive is not garbage.

◆ getPitch()

virtual float tap::communication::sensors::imu::AbstractIMU::getPitch ( ) const
inlineoverridevirtual

Returns pitch angle in radians.

Implements tap::communication::sensors::imu::ImuInterface.

◆ getRoll()

virtual float tap::communication::sensors::imu::AbstractIMU::getRoll ( ) const
inlineoverridevirtual

Returns roll angle in radians.

Implements tap::communication::sensors::imu::ImuInterface.

◆ getTemp()

mockable float tap::communication::sensors::imu::AbstractIMU::getTemp ( ) const
inline

◆ getYaw()

virtual float tap::communication::sensors::imu::AbstractIMU::getYaw ( ) const
inlineoverridevirtual

Returns yaw angle. in radians.

Implements tap::communication::sensors::imu::ImuInterface.

◆ initialize()

void tap::communication::sensors::imu::AbstractIMU::initialize ( float  sampleFrequency,
float  mahonyKp,
float  mahonyKi 
)
virtual

◆ periodicIMUUpdate()

void tap::communication::sensors::imu::AbstractIMU::periodicIMUUpdate ( )
virtual

Call this function at same rate as intialized sample frequency. Performs the mahony AHRS algorithm to compute pitch/roll/yaw.

Reimplemented in tap::communication::sensors::imu::bmi088::final_mockable.

◆ requestCalibration()

void tap::communication::sensors::imu::AbstractIMU::requestCalibration ( )
virtual

When this function is called, the bmi088 enters a calibration state during which time, gyro/accel calibration offsets will be computed and the mahony algorithm reset. When calibrating, angle, accelerometer, and gyroscope values will return 0. When calibrating the BMI088 should be level, otherwise the IMU will be calibrated incorrectly.

◆ resetOffsets()

void tap::communication::sensors::imu::AbstractIMU::resetOffsets ( )
protected

◆ setAccelOffset()

void tap::communication::sensors::imu::AbstractIMU::setAccelOffset ( float  x,
float  y,
float  z 
)
protected

◆ setCalibrationSamples()

void tap::communication::sensors::imu::AbstractIMU::setCalibrationSamples ( int  sampleCount)
inline

◆ setGyroOffset()

void tap::communication::sensors::imu::AbstractIMU::setGyroOffset ( float  x,
float  y,
float  z 
)
protected

◆ setMountingTransform()

void tap::communication::sensors::imu::AbstractIMU::setMountingTransform ( const Transform transform)

Member Data Documentation

◆ calibrationSample

int tap::communication::sensors::imu::AbstractIMU::calibrationSample = 0
protected

◆ imuData

ImuData tap::communication::sensors::imu::AbstractIMU::imuData
protected

◆ imuState

ImuState tap::communication::sensors::imu::AbstractIMU::imuState = ImuState::IMU_NOT_CONNECTED
protected

◆ mahonyAlgorithm

Mahony tap::communication::sensors::imu::AbstractIMU::mahonyAlgorithm
protected

◆ mountingTransform

tap::algorithms::transforms::Transform tap::communication::sensors::imu::AbstractIMU::mountingTransform
protected

◆ offsetSampleCount

int tap::communication::sensors::imu::AbstractIMU::offsetSampleCount = 1000
protected

◆ prevIMUDataReceivedTime

uint32_t tap::communication::sensors::imu::AbstractIMU::prevIMUDataReceivedTime = 0
protected

◆ readTimeout

tap::arch::PeriodicMicroTimer tap::communication::sensors::imu::AbstractIMU::readTimeout
protected

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