changed measuring datatype to quanternions and convert them to radials and degrees

This commit is contained in:
2024-05-08 15:12:49 +02:00
parent c7951c3d9f
commit 2c51596996
3 changed files with 28 additions and 15 deletions

View File

@@ -18,7 +18,7 @@ void SensorManager::sensorSetup() {
Wire.setClock(400000); //Increase I2C data rate to 400kHz
myIMU.calibrateAll(); //Turn on cal for Accel, Gyro, and Mag
myIMU.enableGameRotationVector(100);
myIMU.enableGyroIntegratedRotationVector(100);
myIMU.enableMagnetometer(100); //Send data update every 100ms
myIMU.saveCalibration(); //Saves the current dynamic calibration data (DCD) to memory
myIMU.requestCalibrationStatus(); //Sends command to get the latest calibration status
@@ -32,19 +32,21 @@ void SensorManager::sensorSetup() {
SensorManager::Rotation SensorManager::readLoop() {
if (myIMU.dataAvailable() == true) {
float x = myIMU.getMagX();
float y = myIMU.getMagY();
float z = myIMU.getMagZ();
float i = myIMU.getQuatI();
float j = myIMU.getQuatJ();
float k = myIMU.getQuatK();
float w = myIMU.getQuatReal();
Rotation rotation = { x, y, z };
Rotation rotation = { i, j, k, w };
return rotation;
}
else {
float x = myIMU.getMagX();
float y = myIMU.getMagY();
float z = myIMU.getMagZ();
float i = myIMU.getQuatI();
float j = myIMU.getQuatJ();
float k = myIMU.getQuatK();
float w = myIMU.getQuatReal();
Rotation rotation = { x, y, z };
Rotation rotation = { i, j, k, w };
return rotation;
}
}