Gyroscope Sensor: BNO055

Background

On the CrazyCar a Gyroscope/Accelometer (BNO055) is included. It can be used to log data e.g. if you drive into a curve and want to know how much force was put onto the car and in which orientation it is. Our goal was to get this sensor to work. The first thing was to find an exisiting library and to adapt it, so that it fits for our purpose. As we researched we stumbled upon this library: https://github.com/fm4dd/pi-bno055 This is a project that was already made for the raspberry pi which was perfect. Problems:

  • it used global variables a lot which makes it hard to re-use in larger projects

  • it was not object-oriented

  • it was not written in c++

  • we did not need all of the functions, so we made it a bit more lightweight

The license that this project has, is the MIT license, that means that we can modify the code and publish it, but the developer gives no warranty if everything works properly.

Link to the datasheet of the sensor. https://www.bosch-sensortec.com/media/boschsensortec/downloads/datasheets/bst-bno055-ds000.pdf

Class Description

Todo

Gyroscope

class Bno055

Class for Bno055 to measure with the gyroscope and accelerator for the rp

The mode is set by default to measure with the gyroscope and accelerator. The class has 3 functions to read the measurements and a function to create a csv file with a timestamp, Orientation, gyroscope Data and accelerator Data.

Public Functions

Bno055(const char *i2cbus, const char *i2caddr)

Parameters of the constructor

The constructor also starts the i2c communication with sensor with the parameters from before. It also sets the mod for the used sensors and the fusion data, which is calculated by the sensor.

Parameters:
  • i2cbus – This is the i2cbus, which is used for the communication with the sensor.

  • i2caddr – This is the adress of the sensor. The sensor can use two addresses 0x28 or 0x29. The sensor has a the adress 0x28 when the ADD Pin is connected to ground and 0x29 when it is not connected.

bno get_sensor_data_gyr()

Dump the register pages of the Sensor

This function reads the hole register of the sensor and displays it on the consol.

bno get_sensor_data_eul()

Reading the gyroscope data This function reads 3 Values out of the register of the Sensor and writes the values in a struct. This Values are values are the x, y and z values of the gyroscope from the sensor.

bno get_sensor_data_acc()

Reading the fusion data data This function reads 3 Values out of the register of the Sensor and writes the values in a struct. This Values are calculated values from the sensor. In this class the values are caculated with the gyroscope and accelerator data.

void csv_bno055_create(const char *csvfile, bool newfile)

Reading the accelerator data This function reads 3 Values out of the register of the Sensor and writes the values in a struct. This Values are values are the x, y and z values of the accelerator from the sensor.