The inital example is using LSM6DS_LIS3MDL breakout but some lines ate the begining show that LSM9DS0 and LSM9DS1 can also be used:
Code: Select all
// uncomment one combo 9-DoF!
//#include "LSM6DS_LIS3MDL.h" // can adjust to LSM6DS33, LSM6DS3U, LSM6DSOX...
#include "LSM9DS.h" // LSM9DS1 or LSM9DS0
//#include "NXP_FXOS_FXAS.h" // NXP 9-DoF breakout
// pick your filter! slower == better quality output
//Adafruit_NXPSensorFusion filter; // slowest
//Adafruit_Madgwick filter; // faster than NXP
Adafruit_Mahony filter; // fastest/smalleset
The problem is that the rotation angles are calculated wrongly: the object rotates in 3D but after stoping in real life it rotates in the other direction in the 3D program.
From the datasheet of LSM9DS0 and LSM9DS1 which should be similar, I found a huge difference in how the axis of the 3 sensors are aligned. What I found is that the X and Y axis of accelerometer and gyroscope have to be inversed in the filter calculations as follows:
Code: Select all
// default (original code)
//filter.update(gx, gy, gz, accel.acceleration.x, accel.acceleration.y, accel.acceleration.z, mag.magnetic.x, mag.magnetic.y, mag.magnetic.z);
// just accelerometer and gyro
filter.update(gy, -gx, gz, -accel.acceleration.y, accel.acceleration.x, accel.acceleration.z, 0, 0, 0);
The problem remains with the magnetometer axis for which I can't figure how to rotate them the match the filter algorithm.
Can anyone at least try the AHRS library with the LSM9DS1 sensor. Or even with LSM9DS0 and confirm that it works.
Thank you.