API

This documentation outlines the library for IMU.

DEV

Devices, representation of hardware that can be interfaced with. In general, devices are communicated with via some sort of IO interface, but that is not strictly a rule. An LED is a simplistic example of a device.

IMU

class IMU::IMU : public CANDevice

Main class for the IMU that manages its built-in BNO055 and manages CAN communication.

Public Functions

explicit IMU(BNO055 bno055)

Basic constructor for an IMU instance.

It calls the initialization routine of the BNO055.

Parameters

bno055[in] BNO instance to read data from

CO_OBJ_T *getObjectDictionary() override

Gets the object dictionary.

Returns

an object dictionary

uint8_t getNumElements() override

Gets the size of the Object Dictionary.

Returns

size of the Object Dictionary

uint8_t getNodeID() override

Get the device’s node ID.

Returns

The node ID of the can device.

void process()

Handle running the core logic of the IMU.

This involves calling upon BNO055 to retrieve and log data.

Public Static Attributes

static constexpr uint8_t NODE_ID = 9

The node ID is used to identify the device on the CAN network.

BNO055

class IMU::BNO055

A driver class for the BNO055 orientation sensor used in the IMU.

Notice: This class uses a non standard (possibly) version of i2c that does not work with the EVT-Core provided readReg and writeReg. For this reason, all i2c calls in this driver use the raw write and read functions.

Datasheet for BNO055 - https://cdn-shop.adafruit.com/datasheets/BST_BNO055_DS000_12.pdf

Public Types

enum BNO055Status

Represents potential errors that may take place when using the I2C interface.

Each method that interfaces over I2C could potentially return one of these errors, or OK if no error.

Values:

enumerator OK
enumerator FAIL_INIT
enumerator FAIL_SELF_TEST

Public Functions

BNO055(IO::I2C &i2C, uint8_t i2cSlaveAddress)

Initializer for a BNO055 sensor.

Takes in i2c to setup a connection with the board

Parameters
  • i2C[in] an initialized i2c session.

  • i2cSlaveAddress[in] the slave address that the BNO055 should use to communicate.

BNO055Status setup()

Sends all of the required i2c commands to initialize the chip.

Returns

whether the setup succeeded.

IO::I2C::I2CStatus getEuler(uint16_t &xBuffer, uint16_t &yBuffer, uint16_t &zBuffer)

Fetch the euler angle data.

Parameters
  • xBuffer[out] a buffer to store the x data in.

  • yBuffer[out] a buffer to store the y data in.

  • zBuffer[out] a buffer to store the z data in.

Returns

an i2c status reporting if the fetch worked or not.

IO::I2C::I2CStatus getGyroscope(uint16_t &xBuffer, uint16_t &yBuffer, uint16_t &zBuffer)

Fetch the gyroscope data.

Parameters
  • xBuffer[out] a buffer to store the x data in.

  • yBuffer[out] a buffer to store the y data in.

  • zBuffer[out] a buffer to store the z data in.

Returns

an i2c status reporting if the fetch worked or not.

IO::I2C::I2CStatus getLinearAccel(uint16_t &xBuffer, uint16_t &yBuffer, uint16_t &zBuffer)

Fetch the linear acceleration data.

Parameters
  • xBuffer[out] a buffer to store the x data in.

  • yBuffer[out] a buffer to store the y data in.

  • zBuffer[out] a buffer to store the z data in.

Returns

an i2c status reporting if the fetch worked or not.

IO::I2C::I2CStatus getAccelerometer(uint16_t &xBuffer, uint16_t &yBuffer, uint16_t &zBuffer)

Fetch the accelerometer data.

Parameters
  • xBuffer[out] a buffer to store the x data in.

  • yBuffer[out] a buffer to store the y data in.

  • zBuffer[out] a buffer to store the z data in.

Returns

an i2c status reporting if the fetch worked or not.

IO::I2C::I2CStatus getGravity(uint16_t &xBuffer, uint16_t &yBuffer, uint16_t &zBuffer)

Fetch the gravity data.

Parameters
  • xBuffer[out] a buffer to store the x data in.

  • yBuffer[out] a buffer to store the y data in.

  • zBuffer[out] a buffer to store the z data in.

Returns

an i2c status reporting if the fetch worked or not.