I am trying to obtain Quaternion values from a BNO055 connected to ESP32-PoE board by Olimex.
Code
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BNO055.h>
#include <utility/imumaths.h>
Adafruit_BNO055 bno = Adafruit_BNO055(55);
void setup() {
// put your setup code here, to run once:
Wire.begin(13, 16, 400000);
Serial.begin(115200);
if (!bno.begin()) {
Serial.println("No BNO055 Detected!");
while(1);
}
delay(100);
bno.setMode(Adafruit_BNO055::OPERATION_MODE_NDOF_FMC_OFF);
bno.setExtCrystalUse(true);
}
void loop() {
// put your main code here, to run repeatedly:
imu::Quaternion quat = bno.getQuat();
imu::Vector<3> euler = quat.toEuler();
Serial.print("W: ");
Serial.print(quat.w());
Serial.print(F(" "));
Serial.print("x: ");
Serial.print(quat.x());
Serial.print(F(" "));
Serial.print("y: ");
Serial.print(quat.y());
Serial.print(F(" "));
Serial.print("z: ");
Serial.print(quat.z());
Serial.print(F(" "));
Serial.print("X: ");
Serial.print((float)euler.x());
Serial.print(F(" "));
Serial.print("Y: ");
Serial.print((float)euler.y());
Serial.print(F(" "));
Serial.print("Z: ");
Serial.print(float(euler.z()));
Serial.print(F(" "));
Serial.println("");
delay(200);
}
output
W: 0.00 x: 0.00 y: 0.00 z: 0.00 X: 0.00 Y: nan Z: 0.00
W: 0.00 x: 0.00 y: 0.00 z: 0.00 X: 0.00 Y: nan Z: 0.00
W: 0.00 x: 0.00 y: 0.00 z: 0.00 X: 0.00 Y: nan Z: 0.00
W: 0.00 x: 0.00 y: 0.00 z: 0.00 X: 0.00 Y: nan Z: 0.00
W: 0.00 x: 0.00 y: 0.00 z: 0.00 X: 0.00 Y: nan Z: 0.00
W: 0.00 x: 0.00 y: 0.00 z: 0.00 X: 0.00 Y: nan Z: 0.00
W: 0.00 x: 0.00 y: 0.00 z: 0.00 X: 0.00 Y: nan Z: 0.00
W: 0.00 x: 0.00 y: 0.00 z: 0.00 X: 0.00 Y: nan Z: 0.00
W: 0.00 x: 0.00 y: 0.00 z: 0.00 X: 0.00 Y: nan Z: 0.00
W: 0.00 x: 0.00 y: 0.00 z: 0.00 X: 0.00 Y: nan Z: 0.00
The sensor seems to be working since I tried a simple script and the values are avaiable.
Is there some specific setting missing during setup()
in order to obtain Quaternions.
Purpose
For Absolute orientation, the Quaternion values need to be converted to Euler .