kriswiner / LSM9DS1

ST's new smaller, lower-power 9-axis motion sensor
42 stars 28 forks source link

Adafruit NXP Library for LSM9DS1 #19

Open mason-stafford opened 3 years ago

mason-stafford commented 3 years ago

Hi to all.

First of all, I want to appreciate @kriswiner for making this code, that's a huge one, it makes using the sensor so easy and understandable for me. Thanks again. Currently I'm trying to use the adafruit NXP Library for LSM9DS1, but unfortunately it's not working correctly. I'm having some yaw drift problem with it.

I'm gonna be grateful for any help.

Regards, Mason

kriswiner commented 3 years ago

Need a bit more info to understand what problems you are having.

On Sun, Oct 10, 2021 at 10:28 PM Mason.S @.***> wrote:

Hi to all.

First of all, I want to appreciate @kriswiner https://github.com/kriswiner for making this code, that's a huge one, it makes using the sensor so easy and understandable for me. Thanks again. Currently I'm trying to use the adafruit NXP Library for LSM9DS1, but unfortunately it's not working correctly. I'm having some yaw drift problem with it.

I'm gonna be grateful for any help.

Regards, Mason

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/kriswiner/LSM9DS1/issues/19, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTDLKUS3HQ4OWXNOBLVAH3UGJYZRANCNFSM5FXL6C4A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

mason-stafford commented 3 years ago

@kriswiner Thanks for responding, I'm using your LSM9DS1 code for my Arduino Nano 33 BLE Sense for obtaining raw calibrated IMU data, and passing it to Adafruit NXP Library which uses the Kalman Filter algorithm to estimate the orientation. I'm using the following settings for my sensors:

uint8_t Gscale = GFS_2000DPS; // gyro full scale uint8_t Godr = GODR_119Hz; // gyro data sample rate uint8_t Gbw = GBW_low; // gyro data bandwidth uint8_t Ascale = AFS_2G; // accel full scale uint8_t Aodr = AODR_119Hz; // accel data sample rate uint8_t Abw = ABW_408Hz; // accel data bandwidth uint8_t Mscale = MFS_4G; // mag full scale uint8_t Modr = MODR_80Hz; // mag data sample rate uint8_t Mmode = MMode_UltraHighPerformance; // magnetometer operation mode

and running the Kalman filter on 100Hz, Everything is fine but when I'm leaving the sensor on the desk, it takes some time to corrects the yaw direction. When the sensor is staying steel on the desk the quaternion data will change and take some time to get stable. When I'm passing the quaternion data to a python visualization environment, change of the quaternion data will only effect on yaw direction.

I hope I have achieved what I mean.

kriswiner commented 3 years ago

First of all I have no experience using a Kalman filter.

Generally, most problems obtaining accurate absolute orientation estimation with IMUs is due to inadequate calibration of the sensors. How do you verify proper calibration.

Then we usually use different rates. Typically we use 200 - 800 Hz for the accel and gyro with low pass filters at ~1/5 of the sample rate. Then we try to keep the fusion filter rate at 10x of the gyro sample rate. This is because filters like Madgwick and Mahoney are iterative. So we want to iterate 5 - 10x for every fresh gyro data sample. Kalman filters might be different.

So I would recommend to start you step up the gyro and accel sample rates to at least 200 Hz but 400 Hz would be better and see if the response improves.

The latency could also be in the data transmission to the Adafruit library, or use of the library itself, and here iI cannot help you.

On Sun, Oct 10, 2021 at 10:52 PM Mason.S @.***> wrote:

@kriswiner https://github.com/kriswiner Thanks for responding, I'm using you LSM9DS1 for my Arduino Nano 33 BLE Sense for obtaining raw calibrated IMU data, and passing it to Adafruit NXP Library which uses the Kalman Filter algorithm to estimate the orientation. I'm using the following settings for my sensors:

uint8_t Gscale = GFS_2000DPS; // gyro full scale uint8_t Godr = GODR_119Hz; // gyro data sample rate uint8_t Gbw = GBW_low; // gyro data bandwidth uint8_t Ascale = AFS_2G; // accel full scale uint8_t Aodr = AODR_119Hz; // accel data sample rate uint8_t Abw = ABW_408Hz; // accel data bandwidth uint8_t Mscale = MFS_4G; // mag full scale uint8_t Modr = MODR_80Hz; // mag data sample rate uint8_t Mmode = MMode_UltraHighPerformance; // magnetometer operation mode

and running the Kalman filter on 100Hz, Everything is fine but when I'm leaving the sensor on the desk, it takes some time to corrects the yaw direction. When the sensor is staying steel on the desk the quaternion data will change and take some time to get stable. When I'm passing the quaternion data to a python visualization environment, change of the quaternion data will only effect on yaw direction.

I hope I have achieved what I mean.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/kriswiner/LSM9DS1/issues/19#issuecomment-939701885, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTDLKXPN2LR7X3CAXJMVQ3UGJ3RFANCNFSM5FXL6C4A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

mason-stafford commented 3 years ago

As I said I'm using your LSM9DS1 Library for my Arduino Nano BLE Sense, and your IMU calibration method too. How should make sure the calibration is done correctly? I have already tested the different sample rates, doesn't make any difference.

Regards

kriswiner commented 3 years ago

When sensor is flat and motionless accel should show 0, 0, 1 g to 1% and gyro should show 0, 0, 0 dps to 1%. Mag should agree with local fields expected for your location. Mz = -Mz when the sensor flipped upside down, etc the obvious things...

On Mon, Oct 11, 2021 at 10:10 PM Mason.S @.***> wrote:

As I said I'm using your LSM9DS1 Library for my Arduino Nano BLE Sense, and your IMU calibration method too. How should make sure the calibration is done correctly? I have already tested the different sample rates, doesn't make any difference.

Regards

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/kriswiner/LSM9DS1/issues/19#issuecomment-940667960, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTDLKUXTYHMJNNU5NEEBN3UGO7OHANCNFSM5FXL6C4A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

mason-stafford commented 3 years ago

I didn't think at all the solution might be easy at all. After calibrating the sensors, mag and accel is OK but unfortunately gyro won't give zero values. I did calibration with your code and Femme Verbeek's code. non gives zeros. any suggestions?

Regards

kriswiner commented 3 years ago

LSM6DSM

On Mon, Oct 11, 2021 at 10:59 PM Mason.S @.***> wrote:

I didn't think at all the solution might be easy at all. After calibrating the sensors, mag and accel is OK but unfortunately gyro won't give zero values. I did calibration with your code and Femme Verbeek's code. non gives zeros. any suggestions?

Regards

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/kriswiner/LSM9DS1/issues/19#issuecomment-940689575, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTDLKSMWB2O3KP64WHZQL3UGPFENANCNFSM5FXL6C4A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

mason-stafford commented 3 years ago

Hi again, @kriswiner I'm still working on this issue, after making sure the calibration has done properly, I realized it's all related to Kalman Covariance Variables and it should be personalized for any specific sensor. It was just an update, I'm gonna share the exact settings.

Regards,

Mason

kriswiner commented 3 years ago

Sorry I can't help you there...you could try the Madgwick fusion filter just as a sanity check.

On Tue, Oct 19, 2021 at 1:21 AM Mason.S @.***> wrote:

Hi again, @kriswiner https://github.com/kriswiner I'm steel working on this issue, after making sure the calibration has done properly, I realized it's all related to Kalman Covariance Variables and it should be personalized for any specific sensor. It was just an update, I'm gonna share the exact settings.

Regards,

Mason

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/kriswiner/LSM9DS1/issues/19#issuecomment-946475888, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTDLKUS6HYYHUNHOTRPYDTUHUTA3ANCNFSM5FXL6C4A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.