BNO055 module
Houses BOSCH BNO055IMU python library and test program.
- class BNO055.BNO055(i2c, sensorId=-1, address=40)
Bases:
object
Controls BNO055 IMU.
- Parameters:
i2c (machine.I2C) – Preconfigured IMU I2C channel.
sensorId (int, optional) – Sensor ID. Defaults to -1.
address (hexadecimal, optional) – Hex sensor I2C address. Defaults to 0x28.
- ACCEL_OFFSET_X_LSB_ADDR = 85
- ACCEL_OFFSET_X_MSB_ADDR = 86
- ACCEL_OFFSET_Y_LSB_ADDR = 87
- ACCEL_OFFSET_Y_MSB_ADDR = 88
- ACCEL_OFFSET_Z_LSB_ADDR = 89
- ACCEL_OFFSET_Z_MSB_ADDR = 90
- ACCEL_RADIUS_LSB_ADDR = 103
- ACCEL_RADIUS_MSB_ADDR = 104
- AXIS_REMAP_NEGATIVE = 1
- AXIS_REMAP_POSITIVE = 0
- AXIS_REMAP_X = 0
- AXIS_REMAP_Y = 1
- AXIS_REMAP_Z = 2
- BNO055_ACCEL_DATA_X_LSB_ADDR = 8
- BNO055_ACCEL_DATA_X_MSB_ADDR = 9
- BNO055_ACCEL_DATA_Y_LSB_ADDR = 10
- BNO055_ACCEL_DATA_Y_MSB_ADDR = 11
- BNO055_ACCEL_DATA_Z_LSB_ADDR = 12
- BNO055_ACCEL_DATA_Z_MSB_ADDR = 13
- BNO055_ACCEL_REV_ID_ADDR = 1
- BNO055_ADDRESS_A = 40
- BNO055_ADDRESS_B = 41
- BNO055_AXIS_MAP_CONFIG_ADDR = 65
- BNO055_AXIS_MAP_SIGN_ADDR = 66
- BNO055_BL_REV_ID_ADDR = 6
- BNO055_CALIB_STAT_ADDR = 53
- BNO055_CHIP_ID_ADDR = 0
- BNO055_DATA_SELECT_ADDR = 60
- BNO055_EULER_H_LSB_ADDR = 26
- BNO055_EULER_H_MSB_ADDR = 27
- BNO055_EULER_P_LSB_ADDR = 30
- BNO055_EULER_P_MSB_ADDR = 31
- BNO055_EULER_R_LSB_ADDR = 28
- BNO055_EULER_R_MSB_ADDR = 29
- BNO055_GRAVITY_DATA_X_LSB_ADDR = 46
- BNO055_GRAVITY_DATA_X_MSB_ADDR = 47
- BNO055_GRAVITY_DATA_Y_LSB_ADDR = 48
- BNO055_GRAVITY_DATA_Y_MSB_ADDR = 49
- BNO055_GRAVITY_DATA_Z_LSB_ADDR = 50
- BNO055_GRAVITY_DATA_Z_MSB_ADDR = 51
- BNO055_GYRO_DATA_X_LSB_ADDR = 20
- BNO055_GYRO_DATA_X_MSB_ADDR = 21
- BNO055_GYRO_DATA_Y_LSB_ADDR = 22
- BNO055_GYRO_DATA_Y_MSB_ADDR = 23
- BNO055_GYRO_DATA_Z_LSB_ADDR = 24
- BNO055_GYRO_DATA_Z_MSB_ADDR = 25
- BNO055_GYRO_REV_ID_ADDR = 3
- BNO055_ID = 160
- BNO055_INTR_STAT_ADDR = 55
- BNO055_LINEAR_ACCEL_DATA_X_LSB_ADDR = 40
- BNO055_LINEAR_ACCEL_DATA_X_MSB_ADDR = 41
- BNO055_LINEAR_ACCEL_DATA_Y_LSB_ADDR = 42
- BNO055_LINEAR_ACCEL_DATA_Y_MSB_ADDR = 43
- BNO055_LINEAR_ACCEL_DATA_Z_LSB_ADDR = 44
- BNO055_LINEAR_ACCEL_DATA_Z_MSB_ADDR = 45
- BNO055_MAG_DATA_X_LSB_ADDR = 14
- BNO055_MAG_DATA_X_MSB_ADDR = 15
- BNO055_MAG_DATA_Y_LSB_ADDR = 16
- BNO055_MAG_DATA_Y_MSB_ADDR = 17
- BNO055_MAG_DATA_Z_LSB_ADDR = 18
- BNO055_MAG_DATA_Z_MSB_ADDR = 19
- BNO055_MAG_REV_ID_ADDR = 2
- BNO055_OPR_MODE_ADDR = 61
- BNO055_PAGE_ID_ADDR = 7
- BNO055_PWR_MODE_ADDR = 62
- BNO055_QUATERNION_DATA_W_LSB_ADDR = 32
- BNO055_QUATERNION_DATA_W_MSB_ADDR = 33
- BNO055_QUATERNION_DATA_X_LSB_ADDR = 34
- BNO055_QUATERNION_DATA_X_MSB_ADDR = 35
- BNO055_QUATERNION_DATA_Y_LSB_ADDR = 36
- BNO055_QUATERNION_DATA_Y_MSB_ADDR = 37
- BNO055_QUATERNION_DATA_Z_LSB_ADDR = 38
- BNO055_QUATERNION_DATA_Z_MSB_ADDR = 39
- BNO055_SELFTEST_RESULT_ADDR = 54
- BNO055_SIC_MATRIX_0_LSB_ADDR = 67
- BNO055_SIC_MATRIX_0_MSB_ADDR = 68
- BNO055_SIC_MATRIX_1_LSB_ADDR = 69
- BNO055_SIC_MATRIX_1_MSB_ADDR = 70
- BNO055_SIC_MATRIX_2_LSB_ADDR = 71
- BNO055_SIC_MATRIX_2_MSB_ADDR = 72
- BNO055_SIC_MATRIX_3_LSB_ADDR = 73
- BNO055_SIC_MATRIX_3_MSB_ADDR = 74
- BNO055_SIC_MATRIX_4_LSB_ADDR = 75
- BNO055_SIC_MATRIX_4_MSB_ADDR = 76
- BNO055_SIC_MATRIX_5_LSB_ADDR = 77
- BNO055_SIC_MATRIX_5_MSB_ADDR = 78
- BNO055_SIC_MATRIX_6_LSB_ADDR = 79
- BNO055_SIC_MATRIX_6_MSB_ADDR = 80
- BNO055_SIC_MATRIX_7_LSB_ADDR = 81
- BNO055_SIC_MATRIX_7_MSB_ADDR = 82
- BNO055_SIC_MATRIX_8_LSB_ADDR = 83
- BNO055_SIC_MATRIX_8_MSB_ADDR = 84
- BNO055_SW_REV_ID_LSB_ADDR = 4
- BNO055_SW_REV_ID_MSB_ADDR = 5
- BNO055_SYS_CLK_STAT_ADDR = 56
- BNO055_SYS_ERR_ADDR = 58
- BNO055_SYS_STAT_ADDR = 57
- BNO055_SYS_TRIGGER_ADDR = 63
- BNO055_TEMP_ADDR = 52
- BNO055_TEMP_SOURCE_ADDR = 64
- BNO055_UNIT_SEL_ADDR = 59
- GYRO_OFFSET_X_LSB_ADDR = 97
- GYRO_OFFSET_X_MSB_ADDR = 98
- GYRO_OFFSET_Y_LSB_ADDR = 99
- GYRO_OFFSET_Y_MSB_ADDR = 100
- GYRO_OFFSET_Z_LSB_ADDR = 101
- GYRO_OFFSET_Z_MSB_ADDR = 102
- MAG_OFFSET_X_LSB_ADDR = 91
- MAG_OFFSET_X_MSB_ADDR = 92
- MAG_OFFSET_Y_LSB_ADDR = 93
- MAG_OFFSET_Y_MSB_ADDR = 94
- MAG_OFFSET_Z_LSB_ADDR = 95
- MAG_OFFSET_Z_MSB_ADDR = 96
- MAG_RADIUS_LSB_ADDR = 105
- MAG_RADIUS_MSB_ADDR = 106
- OPERATION_MODE_ACCGYRO = 5
- OPERATION_MODE_ACCMAG = 4
- OPERATION_MODE_ACCONLY = 1
- OPERATION_MODE_AMG = 7
- OPERATION_MODE_COMPASS = 9
- OPERATION_MODE_CONFIG = 0
- OPERATION_MODE_GYRONLY = 3
- OPERATION_MODE_IMUPLUS = 8
- OPERATION_MODE_M4G = 10
- OPERATION_MODE_MAGGYRO = 6
- OPERATION_MODE_MAGONLY = 2
- OPERATION_MODE_NDOF = 12
- OPERATION_MODE_NDOF_FMC_OFF = 11
- POWER_MODE_LOWPOWER = 1
- POWER_MODE_NORMAL = 0
- POWER_MODE_SUSPEND = 2
- VECTOR_ACCELEROMETER = 8
- VECTOR_EULER = 26
- VECTOR_GRAVITY = 46
- VECTOR_GYROSCOPE = 20
- VECTOR_LINEARACCEL = 40
- VECTOR_MAGNETOMETER = 14
- begin(mode=None)
Starts IMU functions.
- Parameters:
mode (hex, optional) – IMU Mode. Defaults to None.
- Returns:
_description_
- Return type:
_type_
- getAxisRemap()
Return a tuple with the axis remap register values. This will return 6 values with the following meaning:
- X axis remap (a value of AXIS_REMAP_X, AXIS_REMAP_Y, or AXIS_REMAP_Z.
which indicates that the physical X axis of the chip is remapped to a different axis)
Y axis remap (see above)
Z axis remap (see above)
- X axis sign (a value of AXIS_REMAP_POSITIVE or AXIS_REMAP_NEGATIVE
which indicates if the X axis values should be positive/ normal or negative/inverted. The default is positive.)
Y axis sign (see above)
Z axis sign (see above)
Note that by default the axis orientation of the BNO chip looks like the following (taken from section 3.4, page 24 of the datasheet). Notice the dot in the corner that corresponds to the dot on the BNO chip:
Z axis/ X axis____|__/____
Y axis / * | / /| _________ /______|/ //
/___________ //
- getCalibrationData()
Return the sensor’s calibration data and return it as an array of 22 bytes.
Can be saved and then reloaded with the setCalibration function to quickly calibrate from a previously calculated set of calibration data.
- Returns:
22 byte cal data list.
- Return type:
list
- getCalibrationStatus()
Read the calibration status of the sensors and return a 4 tuple with calibration status as follows:
System, 3=fully calibrated, 0=not calibrated
Gyroscope, 3=fully calibrated, 0=not calibrated
Accelerometer, 3=fully calibrated, 0=not calibrated
Magnetometer, 3=fully calibrated, 0=not calibrated
- Returns:
Cal values in respective order as above.
- Return type:
tuple
- getQuat()
return Quaternions
- Returns:
Quaternions
- Return type:
tuple
- getRevInfo()
Returns revision info
- Returns:
accel_rev, mag_rev, gyro_rev, sw_rev, bl_rev
- Return type:
tuple
- getSystemStatus(run_self_test=False)
- Return a tuple with status information. Three values will be returned:
- System status register value with the following meaning:
0 = Idle 1 = System Error 2 = Initializing Peripherals 3 = System Initialization 4 = Executing Self-Test 5 = Sensor fusion algorithm running 6 = System running without fusion algorithms
- Self test result register value with the following meaning:
Bit value: 1 = test passed, 0 = test failed Bit 0 = Accelerometer self test Bit 1 = Magnetometer self test Bit 2 = Gyroscope self test Bit 3 = MCU self test Value of 0x0F = all good!
- System error register value with the following meaning:
0 = No error 1 = Peripheral initialization error 2 = System initialization error 3 = Self test result failed 4 = Register map value out of range 5 = Register map address out of range 6 = Register map write error 7 = BNO low power mode not available for selected operation mode 8 = Accelerometer power mode not available 9 = Fusion algorithm configuration error
10 = Sensor configuration error
If run_self_test is passed in as False then no self test is performed and None will be returned for the self test result. Note that running a self test requires going into config mode which will stop the fusion engine from running.
- Parameters:
run_self_test (bool) – See description.
- Returns:
Contains status information. See description.
- Return type:
tuple
- getTemp()
Returns temperature
- Returns:
Temperature.
- Return type:
hex
- getVector(vectorType)
Returns IMU vector based on requested register
- Parameters:
vectorType (hexidecimal) – Requested register.
- Returns:
Vector, with type according to requested register.
- Return type:
tuple
- readBytes(register, numBytes=1)
Read bytes through I2C
- Parameters:
register (hex) – Register containing desired data
numBytes (int, optional) – Number of requested bytes. Defaults to 1.
- Returns:
Requested bytes.
- Return type:
bytes
- setCalibrationData(data: list[int] = None)
Set the sensor’s calibration data using a list of 22 bytes that represent the sensor offsets and calibration data.
This data should be a value that was previously retrieved with get_calibration (and then perhaps persisted to disk or other location until needed again).
- setExternalCrystalUse(useExternalCrystal=True)
sets external use on or off for timing.
- Parameters:
useExternalCrystal (bool, optional) – True sets to external crystal use. Defaults to True.
- setMode(mode)
sets IMU Mode
- Parameters:
mode (hex) – mode
- set_axis_remap(x, y, z, x_sign=None, y_sign=None, z_sign=None)
- writeBytes(register, byteVals)
Writes bytes in specified register.
- Parameters:
register (hex) – Destination register
byteVals (bytes) – Data to write.
- Returns:
None