Hi,
I have Nicla Sense ME which contains BHI260AP & BMM150. I am curious about the algorithms to be used to generate Quaternion and euler angle.
Also what are the units for accelerometer, gyroscope, and magnetometer data?
Solved! Go to Solution.
Hello hkayan,
Do you mean the RAW data unit output by the sensor or the unit output by the driving interface?
Hi Robin,
I mean the unit output by driving interface. I am adding an example code of how I generate my data.
#include "Arduino.h"
#include "Arduino_BHY2.h"
#include "Nicla_System.h"
SensorQuaternion rotation(SENSOR_ID_RV);
SensorOrientation euler(SENSOR_ID_ORI);
float heading = 0;
float pitch = 0;
float roll = 0;
void setup()
{
Serial.begin(115200);
while(!Serial);
BHY2.begin();
rotation.begin();
euler.begin();
//rotation.configure(50, 20); does not work
}
void loop()
{
// Update function should be continuously polled
BHY2.update();
float qX = rotation.x();
float qY = rotation.y();
float qZ = rotation.z();
float qW = rotation.w();
heading = euler.heading();
pitch = euler.pitch();
roll = euler.roll();
}
Hello hkayan,
The unit of pitch, roll and heading is in degree.
Thanks Robin. How about the accelerometer, gyroscope and magnetometer on below example? I never seen accelerometer generating data value as 3000.
#include "Arduino.h"
#include "Arduino_BHY2.h"
#include "Nicla_System.h"
SensorXYZ accelerometer(SENSOR_ID_ACC);
SensorXYZ gyro(SENSOR_ID_GYRO);
SensorXYZ mag(SENSOR_ID_MAG);
short accX = accelerometer.x();
short accY = accelerometer.y();
short accZ = accelerometer.z();
short gyroX = gyro.x();
short gyroY = gyro.y();
short gyroZ = gyro.z();
short magX = mag.x();
short magY = mag.y();
short magZ = mag.z();