pyupm_bno055 module

class pyupm_bno055.BNO055(bus=0, addr=40)[source]

Bases: object

API for the BNO055 Absolute Orientation 9DOF Fusion Hub.

ID: bno055

Name: Intelligent 9-axis Absolute Orientation Sensor

Category: accelerometer compass

Manufacturer: bosch adafruit

Connection: i2c gpio

Link:https://www.adafruit.com/products/2472 The BNO055 is a System in Package (SiP), integrating a triaxial 14-bit accelerometer, a triaxial 16-bit gyroscope with a range of +/- 2000 degrees per second, a triaxial geomagnetic sensor and a 32-bit cortex M0+ microcontroller running Bosch Sensortec sensor fusion software, in a single package.

This sensor handles the hard problem of combining various sensor information into a reliable measurement of sensor orientation (refered to as ‘sensor fusion’). The onboard MCU runs this software and can provide fusion output in the form of Euler Angles, Quaternions, Linear Acceleration, and Gravity Vectors in 3 axes.

The focus on this driver has been on supporting the fusion components. Less support is available for use of this device as a generic accelerometer, gyroscope and magnetometer, however enough infrastructure is available to add any missing functionality.

This device requires calibration in order to operate accurately. Methods are provided to retrieve calibration data (once calibrated) to be stored somewhere else, like in a file. A method is provided to load this data as well. Calibration data is lost on a power cycle. See one of the examples for a description of how to calibrate the device, but in essence:

There is a calibration status register available ( getCalibrationStatus()) that returns the calibration status of the accelerometer (ACC), magnetometer (MAG), gyroscope (GYR), and overall system (SYS). Each of these values range from 0 (uncalibrated) to 3 (fully calibrated). Calibration involves certain motions to get all 4 values at 3. The motions are as follows (though see the datasheet for more information):

GYR: Simply let the sensor sit flat for a few seconds.

ACC: Move the sensor in various positions. Start flat, then rotate slowly by 45 degrees, hold for a few seconds, then continue rotating another 45 degrees and hold, etc. 6 or more movements of this type may be required. You can move through any axis you desire, but make sure that the device is lying at least once perpendicular to the x, y, and z axis.

MAG: Move slowly in a figure 8 pattern in the air, until the calibration values reaches 3.

SYS: This will usually reach 3 when the other items have also reached 3. If not, continue slowly moving the device though various axes until it does.

C++ includes: bno055.hpp

getACCID()[source]

uint8_t getACCID()

Return the accelerometer chip ID.

The chip ID.

std::runtime_error: on failure.

getAccelerometer(*args)[source]

vector< float > getAccelerometer()

Return current uncompensated accelerometer (non-fusion) data in the form of a floating point vector. By default the returned values are in meters per-second squared (m/s^2). update() must have been called prior to calling this method.

A floating point vector containing x, y, and z in that order.

getBootLoaderID()[source]

uint8_t getBootLoaderID()

Return the bootloader ID.

The bootloader ID.

std::runtime_error: on failure.

getCalibrationStatus(*args)[source]

vector< int > getCalibrationStatus()

Read the calibration status registers and return them as an integer vector. The values range from 0 (uncalibrated) to 3 (fully calibrated).

An integer vector containing the values in the order: mag, acc, gyr, and sys.

std::runtime_error: on failure.

getChipID()[source]

uint8_t getChipID()

Return the chip ID.

The chip ID (BNO055_CHIPID).

std::runtime_error: on failure.

getEulerAngles(*args)[source]

vector< float > getEulerAngles()

Return current orientation fusion data in the form of Euler Angles as a floating point vector. By default, the returned values are in degrees. update() must have been called prior to calling this method.

A floating point vector containing heading, roll, and pitch, in that order.

getGYRID()[source]

uint8_t getGYRID()

Return the gyroscope chip ID.

The chip ID.

std::runtime_error: on failure.

getGravityVectors(*args)[source]

vector< float > getGravityVectors()

Return current orientation fusion data in the form of a Gravity Vector per-axis as a floating point vector. update() must have been called prior to calling this method.

A floating point vector containing x, y, and z in that order.

getGyroscope(*args)[source]

vector< float > getGyroscope()

Return current uncompensated gyroscope (non-fusion) data in the form of a floating point vector. By default the returned values are in meters per-second squared (m/s^2). update() must have been called prior to calling this method.

A floating point vector containing x, y, and z in that order.

getInterruptEnable()[source]

uint8_t getInterruptEnable()

Return the interrupt enables register. This is a bitmask of the BNO055_INT_STA_BITS_T bits.

a bitmask of BNO055_INT_STA_BITS_T bits currently set in the enable register.

std::runtime_error: on failure.

getInterruptMask()[source]

uint8_t getInterruptMask()

Return the interrupt mask register. This is a bitmask of the BNO055_INT_STA_BITS_T bits. The interrupt mask is used to mask off enabled interrupts from generating a hardware interrupt. The interrupt status register can still be used to detect masked interrupts if they are enabled.

a bitmask of BNO055_INT_STA_BITS_T bits currently set in the interrupt mask register.

std::runtime_error: on failure.

getInterruptStatus()[source]

uint8_t getInterruptStatus()

Return the interrupt status register. This is a bitmask of the BNO055_INT_STA_BITS_T bits.

a bitmask of BNO055_INT_STA_BITS_T bits.

std::runtime_error: on failure.

getLinearAcceleration(*args)[source]

vector< float > getLinearAcceleration()

Return current orientation fusion data in the form of Linear Acceleration, as a floating point vector. update() must have been called prior to calling this method.

A floating point vector containing x, y, and z in that order.

getMAGID()[source]

uint8_t getMAGID()

Return the magnetometer chip ID.

The chip ID.

std::runtime_error: on failure.

getMagnetometer(*args)[source]

vector< float > getMagnetometer()

Return current uncompensated magnetometer (non-fusion) data in the form of a floating point vector. The returned values are in micro- teslas (uT). update() must have been called prior to calling this method.

A floating point vector containing x, y, and z in that order.

getQuaternions(*args)[source]

vector< float > getQuaternions()

Return current orientation fusion data in the form of Quaternions, as a floating point vector. update() must have been called prior to calling this method.

A floating point vector containing w, x, y, and z in that order.

getSWRevID()[source]

uint16_t getSWRevID()

Return the fusion firmware revison.

The firmware revison.

std::runtime_error: on failure.

getSystemError()[source]

BNO055_SYS_ERR_T getSystemError()

Return the value of the system error register. This mathod can be used to determine a variety of system related error conditions.

One of the BNO055_SYS_ERR_T values.

std::runtime_error: on failure.

getSystemStatus()[source]

BNO055_SYS_STATUS_T getSystemStatus()

Return the value of the system status register. This method can be used to determine the overall status of the device.

One of the BNO055_SYS_STATUS_T values.

std::runtime_error: on failure.

getTemperature(fahrenheit=False)[source]

float getTemperature(bool fahrenheit=false)

Return the current measured temperature. Note, this is not ambient temperature - this is the temperature of the selected source on the chip. update() must have been called prior to calling this method.

fahrenheit: true to return data in Fahrenheit, false for Celicus. Celsius is the default.

The temperature in degrees Celsius or Fahrenheit.

installISR(gpio, level, isr, arg)[source]

void installISR(int gpio, mraa_gpio_edge_t level, void(*isr)(void *), void *arg)

install an interrupt handler.

gpio: gpio pin to use as interrupt pin

level: the interrupt trigger level (one of mraa_gpio_edge_t values). Make sure that you have configured the interrupt pin properly for whatever level you choose.

isr: the interrupt handler, accepting a void * argument

arg: the argument to pass the the interrupt handler

std::runtime_error: on failure.

isFullyCalibrated()[source]

bool isFullyCalibrated()

Read the calibration status registers and return true or false, indicating whether all of the calibration parameters are fully calibrated.

True if all 4 calibration parameters are fully calibrated, else false.

readCalibrationData()[source]

std::vector< uint8_t > readCalibrationData()

Read the calibration data and return it as a string. This data can then be saved for later reuse by writeCalibrationData() to restore calibration data after a reset. The sensor must be fully calibrated before calibration data can be read.

A vector of uint8_t’s representing the calibration data. This vector will always be exactly BNO055_CALIBRATION_DATA_SIZE in size.

std::runtime_error: if an error occurs.

resetInterruptStatus()[source]

void resetInterruptStatus()

Reset all interrupt status bits and interrupt output.

std::runtime_error: on failure.

resetSystem()[source]

void resetSystem()

Reboot the sensor. This is equivalent to a power on reset. All calibration data will be lost, and the device must be recalibrated.

std::runtime_error: on failure.

setAccelerationConfig(range, bw, pwr)[source]

void setAccelerationConfig(BNO055_ACC_RANGE_T range, BNO055_ACC_BW_T bw, BNO055_ACC_PWR_MODE_T pwr)

Set the bandwidth, range, and power modes of the accelerometer. In fusion modes, these values will be ignored.

range: One of the BNO055_ACC_RANGE_T values.

bw: One of the BNO055_ACC_BW_T values.

pwr: One of the BNO055_ACC_PWR_MODE_T values.

std::runtime_error: on failure.

setAccelerometerUnits(mg=False)[source]

void setAccelerometerUnits(bool mg=false)

Set the unit of measurement for the accelerometer related sensor values. The choices are mg (milligravities) or meters per-second squared (m/s^2). The default is m/s^2.

mg: true for mg, false for m/s^2.

std::runtime_error: on failure.

setClockExternal(extClock)[source]

void setClockExternal(bool extClock)

Enable or disables the use of the external clock. The Adafruit device does contain an external clock which might be more stable. By default, the internal clock is used.

extClock: true to use external clock, false otherwise.

std::runtime_error: on failure.

setEulerUnits(radians=False)[source]

void setEulerUnits(bool radians=false)

Set the unit of measurement for the Euler Angle related sensor values. The choices are degrees and radians. The default is degrees.

radians: true for radians, false for degrees.

std::runtime_error: on failure.

setGyroscopeConfig(range, bw, pwr)[source]

void setGyroscopeConfig(BNO055_GYR_RANGE_T range, BNO055_GYR_BW_T bw, BNO055_GYR_POWER_MODE_T pwr)

Set the range, bandwidth and power modes of the gyroscope. In fusion modes, these values will be ignored.

range: One of the BNO055_GYR_RANGE_T values.

bw: One of the BNO055_GYR_BW_T values.

pwr: One of the BNO055_GYR_POWER_MODE_T values.

std::runtime_error: on failure.

setGyroscopeUnits(radians=False)[source]

void setGyroscopeUnits(bool radians=false)

Set the unit of measurement for the gyroscope related sensor values. The choices are degrees and radians. The default is degrees.

radians: true for radians, false for degrees.

std::runtime_error: on failure.

setInterruptEnable(enables)[source]

void setInterruptEnable(uint8_t enables)

Set the interrupt enable register. This is composed of a bitmask of the BNO055_INT_STA_BITS_T bits.

enables: a bitmask of BNO055_INT_STA_BITS_T bits to enable

std::runtime_error: on failure.

setInterruptMask(mask)[source]

void setInterruptMask(uint8_t mask)

Set the interrupt mask register. This is a bitmask of the BNO055_INT_STA_BITS_T bits. The interrupt mask is used to mask off enabled interrupts from generating a hardware interrupt. The interrupt status register can still be used to detect masked interrupts if they are enabled.

mask: A bitmask of BNO055_INT_STA_BITS_T bits to set in the interrupt mask register.

std::runtime_error: on failure.

setMagnetometerConfig(odr, opr, pwr)[source]

void setMagnetometerConfig(BNO055_MAG_ODR_T odr, BNO055_MAG_OPR_T opr, BNO055_MAG_POWER_T pwr)

Set the output data rate, operating mode and power mode of the magnetometer. In fusion modes, these values will be ignored.

odr: One of the BNO055_MAG_ODR_T values.

opr: One of the BNO055_MAG_OPR_T values.

pwr: One of the BNO055_MAG_POWER_T values.

std::runtime_error: on failure.

setOperationMode(mode)[source]

void setOperationMode(BNO055_OPERATION_MODES_T mode)

Set the operating mode for the device. This places the device into a config mode, one of 7 non-fusion modes, or one of 5 fusion modes. All stored sensor data is cleared when switching modes. The device must be in config mode for most configuration operations. See the datasheet for details.

mode: One of the BNO055_OPERATION_MODES_T values.

std::runtime_error: on failure.

setTemperatureSource(src)[source]

void setTemperatureSource(BNO055_TEMP_SOURCES_T src)

Select the temperature source. This can be the accelerometer or the gyroscope. By default, the accelerometer temperature is used as the source.

src: One of the BNO055_TEMP_SOURCES_T values.

std::runtime_error: on failure.

uninstallISR()[source]

void uninstallISR()

uninstall a previously installed interrupt handler

update()[source]

void update()

Update the internal stored values from sensor data.

std::runtime_error: on failure.

writeCalibrationData(calibrationData)[source]

void writeCalibrationData(std::vector< uint8_t > calibrationData)

Write previously saved calibration data to the calibration registers.

calibrationData: A vector of uint8_t (bytes) representing calibration data as returned by readCalibrationData(). It’s length must always be exactly BNO055_CALIBRATION_DATA_SIZE.

std::length_error: if the vector size is not equal to BNO055_CALIBRATION_DATA_SIZE.

class pyupm_bno055.SwigPyIterator(*args, **kwargs)[source]

Bases: object

advance(n)[source]
copy()[source]
decr(n=1)[source]
distance(x)[source]
equal(x)[source]
incr(n=1)[source]
next()[source]
previous()[source]
value()[source]
class pyupm_bno055.byteVector(*args)[source]

Bases: object

append(x)[source]
assign(n, x)[source]
back()[source]
begin()[source]
capacity()[source]
clear()[source]
empty()[source]
end()[source]
erase(*args)[source]
front()[source]
get_allocator()[source]
insert(*args)[source]
iterator()[source]
pop()[source]
pop_back()[source]
push_back(x)[source]
rbegin()[source]
rend()[source]
reserve(n)[source]
resize(*args)[source]
size()[source]
swap(v)[source]
class pyupm_bno055.doubleVector(*args)[source]

Bases: object

append(x)[source]
assign(n, x)[source]
back()[source]
begin()[source]
capacity()[source]
clear()[source]
empty()[source]
end()[source]
erase(*args)[source]
front()[source]
get_allocator()[source]
insert(*args)[source]
iterator()[source]
pop()[source]
pop_back()[source]
push_back(x)[source]
rbegin()[source]
rend()[source]
reserve(n)[source]
resize(*args)[source]
size()[source]
swap(v)[source]
class pyupm_bno055.floatVector(*args)[source]

Bases: object

append(x)[source]
assign(n, x)[source]
back()[source]
begin()[source]
capacity()[source]
clear()[source]
empty()[source]
end()[source]
erase(*args)[source]
front()[source]
get_allocator()[source]
insert(*args)[source]
iterator()[source]
pop()[source]
pop_back()[source]
push_back(x)[source]
rbegin()[source]
rend()[source]
reserve(n)[source]
resize(*args)[source]
size()[source]
swap(v)[source]
class pyupm_bno055.int16Vector(*args)[source]

Bases: object

append(x)[source]
assign(n, x)[source]
back()[source]
begin()[source]
capacity()[source]
clear()[source]
empty()[source]
end()[source]
erase(*args)[source]
front()[source]
get_allocator()[source]
insert(*args)[source]
iterator()[source]
pop()[source]
pop_back()[source]
push_back(x)[source]
rbegin()[source]
rend()[source]
reserve(n)[source]
resize(*args)[source]
size()[source]
swap(v)[source]
class pyupm_bno055.intVector(*args)[source]

Bases: object

append(x)[source]
assign(n, x)[source]
back()[source]
begin()[source]
capacity()[source]
clear()[source]
empty()[source]
end()[source]
erase(*args)[source]
front()[source]
get_allocator()[source]
insert(*args)[source]
iterator()[source]
pop()[source]
pop_back()[source]
push_back(x)[source]
rbegin()[source]
rend()[source]
reserve(n)[source]
resize(*args)[source]
size()[source]
swap(v)[source]