Bosch Sensortec BNO055 embedded-hal driver
What is this?
This is a embedded-hal driver for Bosch's inertial measurement unit (IMU) BNO055.
It is device-agnostic and uses I2c
and Delay
embedded-hal traits for its operation.
Uses and re-exports nalgebra's Quaternion for quaternion reading and Rotation3 for Euler angles.
Usage
-
Add dependency to
Cargo.toml
: -
Instantiate and init the device:
// ... declare and configure your I2c and Delay implementations ... // Init BNO055 IMU let imu = new; imu.init?; // Enable 9-degrees-of-freedom sensor fusion mode with fast magnetometer calibration imu.set_mode?; Ok
-
Read orientation data: quaternion or euler angles (roll, pitch, yaw/heading)
let quat = imu.quaternion?; // or: let euler = imu.euler_angles?;
Setup details
Remapping axes to correspond your mounting
BNO055 allows to change default axes to meet chip orientation with actual physical device orientation, thus providing possibility to place BNO055 chip on PCB as suitable for designer and to match chip's axes to and physical axes in software later.
use ;
// ...
// Build remap configuration example with X and Y axes swapped:
let remap = builder
.swap_x_with
.build
.expect;
bno055.set_axis_remap?;
Please note that AxisRemap
(and the chip itself) builder doesn't allow invalid state to be constructed,
that is, when one axis is swapped with multiple of others.
For example, swapping axis X
with both Y
and Z
at the same time is not allowed:
.swap_x_with
.swap_x_with
.build
.unwrap; // <- panics, .build() returned Err
builder
Using external 32k crystal
For better performance, it is advised to connect and use external 32k quartz crystal.
User could enable or disable it by calling set_external_crystal
:
bno055
.set_external_crystal
.expect;
Status
What is done and tested and what is not yet:
- Sensor initialization
- Device mode setup
- Device status readout
- Calibration status readout
- External crystal selection
- Axis remap
- Axis sign change
- Calibration data readout
- Calibration data setup
- Orientation data readout
- Quaternions
- Euler angles
- Raw accelerometer data readout
- Raw gyroscope data readout
- Raw magnetometer data readout