-
Notifications
You must be signed in to change notification settings - Fork 14
Description
Hi,
I love this lib but I'm having trouble using it with a nano 33 ble sense rev 2.
I don't manage to have any result better than manually integrating gyroscope. Maybe I'm using it wrong ?
I need something quite reactive so I'm using
ahrs.setFusionAlgorithm(SensorFusion::COMPLEMENTARY);
ahrs.setAlpha(0.98);
I'd be happy with the accelerometer data for the pitch and roll but I'd like the heading to correct itself over time.
But the heading/yaw data is close to random, even changing direction over time (going from left to right increase then decrease the heading value)
Here is my init :
`#include <ReefwingAHRS.h>
ReefwingAHRS ahrs;
SensorData data;
`
Here is my setup :
` ahrs.begin();
ahrs.setFusionAlgorithm(SensorFusion::COMPLEMENTARY);
ahrs.setAlpha(0.95);
ahrs.setDeclination(2.5); // Paris, France
if (IMU.begin() && ahrs.getBoardType() == BoardType::NANO33BLE_SENSE_R2) {
Serial.println("BMI270 & BMM150 IMUs Detected.");
}
else {
Serial.println("BMI270 & BMM150 IMUs Not Detected.");
while(1);
}
Serial.print("Detected Board - ");
Serial.println(ahrs.getBoardTypeString());
`
And my loop :
`
float roll, pitch, yaw, heading;
static int CC_1, CC_2, CC_3;
if (IMU.gyroscopeAvailable()) { IMU.readGyroscope(data.gx, data.gy, data.gz); }
if (IMU.accelerationAvailable()) { IMU.readAcceleration(data.ax, data.ay, data.az); }
if (IMU.magneticFieldAvailable()) { IMU.readMagneticField(data.mx, data.my, data.mz); }
ahrs.setData(data);
ahrs.update();
if ( millis() - lastPrint > 60 ) {
yaw = (ahrs.angles.yaw - 180) / 180 ;
roll = ahrs.angles.roll / 180 ;
pitch = ahrs.angles.pitch / 180;
}
}
`
I'm then sending the data as midi to control a moving light.
Please telle me I'm doing something wrong ?