Class final_mockable

Nested Relationships

Nested Types

Inheritance Relationships

Base Types

Class Documentation

class final_mockable : public tap::communication::sensors::imu::bmi088::Bmi088Data, public tap::communication::sensors::imu::ImuInterface

For register tables and descriptions, refer to the bmi088 datasheet: https://www.bosch-sensortec.com/media/boschsensortec/downloads/datasheets/bst-bmi088-ds001.pdf

Important notes about using this class:

  • This can only be used with the integrated IMU on the RoboMaster Development Board Type C.

  • For best results, IMU calibration should be performed each time the robot is turned on. The calibration parameters are not stored. Use requestRecalibration to recalibrate the IMU.

  • When calibrating, the IMU should be level (i.e. it should be in the position where you would consider the board to have 0 tilt in the pitch or roll axis relative to the z plane). Of

  • course, this is different depending on how the board is mounted to the robot and what you expect

  • roll and pitch to be defined as.

Public Functions

Bmi088(tap::Drivers *drivers)
void initialize(float sampleFrequency, float mahonyKp, float mahonyKi)

Starts and configures the bmi088. Blocks for < 200 ms.

void periodicIMUUpdate()

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

void read()

This function reads the IMU data from SPI

Note

This function blocks for 129 microseconds to read registers from the BMI088.

ImuState getImuState() const

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.

void requestRecalibration()

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.

inline virtual const char * getName () const final_mockable
inline virtual float getYaw () final _mockable
inline virtual float getPitch () final _mockable
inline virtual float getRoll () final _mockable
inline virtual float getGx () final _mockable
inline virtual float getGy () final _mockable
inline virtual float getGz () final _mockable
inline virtual float getAx () final _mockable
inline virtual float getAy () final _mockable
inline virtual float getAz () final _mockable
inline virtual float getTemp () final _mockable
inline uint32_t getPrevIMUDataReceivedTime() const
inline void setOffsetSamples(float samples)
inline void setAccOversampling(Acc::AccBandwidth oversampling)
inline void setAccOutputRate(Acc::AccOutputRate outputRate)
inline void setGyroOutputRate(Gyro::GyroBandwidth outputRate)
inline void setTargetTemperature(float temperatureC)

Public Members

float BMI088_OFFSET_SAMPLES = 1000

The number of samples we take in order to determine the mpu offsets.

Public Static Attributes

static Acc::AccRange_t ACC_RANGE = Acc::AccRange::G3
static Gyro::GyroRange_t GYRO_RANGE = Gyro::GyroRange::DPS2000
static float GYRO_RANGE_MAX_DS = 2000.0f

The maximum angular velocity in degrees / second that the gyro can read based on GYRO_RANGE specified above.

static float BMI088_TEMP_FACTOR = 0.125f
static float BMI088_TEMP_OFFSET = 23.0f
static float GYRO_DS_PER_GYRO_COUNT = GYRO_RANGE_MAX_DS / 32767.0f

Used to convert raw gyro values to units of degrees / second. Ratio has units (degrees / second) / gyro counts.

static float ACC_G_PER_ACC_COUNT = modm::pow(2, ACC_RANGE.value + 1) * 1.5f * tap::algorithms::ACCELERATION_GRAVITY / 32768.0f

Refer to page 27 of the bmi088 datasheet for explination of this equation. Used to convert raw accel values to units m/s^2. Ratio has units (m/s^2) / acc counts.