Hi to community,
First of all I want to appreciate Adafurit for such incredible products and libraries, and a special thanks for Adafruit AHRS Kalman library, implementing the original NXP library is a nightmare. I have been working with IMUs for a long time, and I used Adafruit BNO055 and Adafruit LSM9DS1 and lots of other sensor boards in my previous projects. I think the BNO sensor is a masterpiece but as you know you don't have access to source code nor matrices, so there is no possibility to manipulate the output. Having manipulation limitations on BNO I decided to use LSM9DS1, Now that I'm using it with the Adafruit AHRS library, the results are outstanding. Comparing BNO and LSM9DS1 outputs, LSM is a little bit shaky and unstable, so I decided to make some adjustments in library definitions, for example various noise constants and filter frequency, I also tried different ODR and FS setting on sensor but it had no noticeable effect. So I decided to ask to community,
What exact setting should be set for sensor?
Which frequency should I run the filter?
What should I do rather than above ones to get perfect and smooth output like BNO?
I will be happy for any advice from another perspectives too.
And your more than welcome to ask relative questions.
Best Regards,
Mason
Adafruit LSMD9S1 with Smooth Kalman AHRS
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- mikeysklar
- Posts: 13936
- Joined: Mon Aug 01, 2016 8:10 pm
Re: Adafruit LSMD9S1 with Smooth Kalman AHRS
Mason,
I don't have specific settings to suggest, but have you seen the guide we produced "Comparing Gyroscope Datasheets". I thought that would be helpful to set expectations and does provide a few hints.
https://learn.adafruit.com/comparing-gy ... datasheets
I don't have specific settings to suggest, but have you seen the guide we produced "Comparing Gyroscope Datasheets". I thought that would be helpful to set expectations and does provide a few hints.
https://learn.adafruit.com/comparing-gy ... datasheets
- sj_remington
- Posts: 997
- Joined: Mon Jul 27, 2020 4:51 pm
Re: Adafruit LSMD9S1 with Smooth Kalman AHRS
What is the best reference/source of information on the Freescale/NXP Kalman filter code in the Adafruit AHRS library? I'm looking for this, mentioned in your tutorial:
https://www.nxp.com/docs/en/data-sheet/XSFLK_DS.pdf
https://www.nxp.com/docs/en/application-note/AN5018.pdf
Also, could not find this forum: https://community.nxp.com/community/sen ... nsorfusion
Edit: Found the user guide for version 7.2 of the Freescale/NXP library here, and it does contain info on the tunable parameters: https://www.nxp.com/design/sensor-devel ... CSNSTLBOXX
I found these documents, but if there is something more current or detailed, please let me know. Neither document linked below seems to contain any information on the tunable filter parameters in the code, nor do they describe the system model assumed by the filter.Full documentation including user manual and fusion data sheet
https://www.nxp.com/docs/en/data-sheet/XSFLK_DS.pdf
https://www.nxp.com/docs/en/application-note/AN5018.pdf
Also, could not find this forum: https://community.nxp.com/community/sen ... nsorfusion
Edit: Found the user guide for version 7.2 of the Freescale/NXP library here, and it does contain info on the tunable parameters: https://www.nxp.com/design/sensor-devel ... CSNSTLBOXX
- Mason_Safavi
- Posts: 7
- Joined: Mon Aug 02, 2021 3:52 am
Re: Adafruit LSMD9S1 with Smooth Kalman AHRS
Hi, and thanks for responding and guiding,
I read all the documents and I found some recommended settings: 200Hz for ACC and MAG , 400Hz for GYRO and 40Hz for Sensor Fusion.
I tested it but results are shaky and have some delay.
Is there anyway contacting with experts in this field?
@mikeysklar
@sj_remington
I read all the documents and I found some recommended settings: 200Hz for ACC and MAG , 400Hz for GYRO and 40Hz for Sensor Fusion.
I tested it but results are shaky and have some delay.
Is there anyway contacting with experts in this field?
@mikeysklar
@sj_remington
- jps2000
- Posts: 811
- Joined: Fri Jun 02, 2017 4:12 pm
Re: Adafruit LSMD9S1 with Smooth Kalman AHRS
Suggested reading:
https://www.mdpi.com/1424-8220/15/8/19302
A code you find here:
https://github.com/ccny-ros-pkg/imu_too ... ary_filter
However, I have not tried that because I am using BNO080 / 85 and found that device and its embedded filter outperforms all others.
some details you find here in the forum or elsewhere
https://github.com/jps2000/BNO080
https://www.mdpi.com/1424-8220/15/8/19302
A code you find here:
https://github.com/ccny-ros-pkg/imu_too ... ary_filter
However, I have not tried that because I am using BNO080 / 85 and found that device and its embedded filter outperforms all others.
some details you find here in the forum or elsewhere
https://github.com/jps2000/BNO080
- sj_remington
- Posts: 997
- Joined: Mon Jul 27, 2020 4:51 pm
Re: Adafruit LSMD9S1 with Smooth Kalman AHRS
Sounds like you need to increase the filter gain, or adjust the sensor data scale factors. Make sure that the sensor axis assignments are correct, and form a right handed coordinate system.I tested it but results are shaky and have some delay.
You did not provide enough information to say more, except that if you are simply replacing one sensor type with another, the choice of data scale factors becomes obvious when comparing the sensor data sheets. And of course, the choices of axial assignments must be completely consistent.
The Madgwick and Mahony fusion filters are much faster, and work about as well as the Kalman filter with consumer grade sensors. If you want to try the Mahony filter for the LSM9DS1, here is one implementation: https://github.com/jremington/LSM9DS1-AHRS.
It was written for the Arduino Uno or similar and requires at least the rate gyro and the magnetometer to be carefully calibrated, as describe in the Readme.
- Mason_Safavi
- Posts: 7
- Joined: Mon Aug 02, 2021 3:52 am
Re: Adafruit LSMD9S1 with Smooth Kalman AHRS
Hi again @mikeysklar @sj_remington,
Thanks again for responding,
I read all of the stuff you referred and I made some progress the only problem I have is when I rotate the sensor really fast and leave the sensor on desk immediately, it takes some time to get back to real stat again.
I will be grateful for any help.
Regards
Thanks again for responding,
I read all of the stuff you referred and I made some progress the only problem I have is when I rotate the sensor really fast and leave the sensor on desk immediately, it takes some time to get back to real stat again.
I will be grateful for any help.
Regards
- sj_remington
- Posts: 997
- Joined: Mon Jul 27, 2020 4:51 pm
Re: Adafruit LSMD9S1 with Smooth Kalman AHRS
Sounds like the gyro scale factor or or assumed direction of positive rotation is wrong.
- Mason_Safavi
- Posts: 7
- Joined: Mon Aug 02, 2021 3:52 am
Re: Adafruit LSMD9S1 with Smooth Kalman AHRS
@sj_remington, thanks again for mentioning that, I tried to use another conventions but the results are the same.
Also there is interesting thing about sensor conventions happening for me, When I'm using NED convention, the results in python visualization is upside down but when I'm using NWU its okay. I couldn't find the reason yet.
Here is how am I feeding data to filter:
NED:
NWU:
and I think it's right.
In this gif as you can see when I'm pitching two times with normal speed everything is good, but at third time after pitching I'm dropping the sensor on the desk and as you can see it takes some time to get back to exact stat.
Thanks again
Also there is interesting thing about sensor conventions happening for me, When I'm using NED convention, the results in python visualization is upside down but when I'm using NWU its okay. I couldn't find the reason yet.
Here is how am I feeding data to filter:
NED:
Code: Select all
filter.update(gx, gy, -gz,
ax, ay, -az,
-mx, my, -mz);
Code: Select all
filter.update(gx, -gy, gz,
ax, -ay, az,
-mx, -my, mz);
In this gif as you can see when I'm pitching two times with normal speed everything is good, but at third time after pitching I'm dropping the sensor on the desk and as you can see it takes some time to get back to exact stat.
Thanks again
- Attachments
-
- BUG.gif (733.53 KiB) Viewed 615 times
- Mason_Safavi
- Posts: 7
- Joined: Mon Aug 02, 2021 3:52 am
Re: Adafruit LSMD9S1 with Smooth Kalman AHRS
Okay an update,
I started to use M/s2 instead of Gravity unit. So I don't have any delay.
But I do have a new problem which is annoying. I'm having some yaw drift problem which I don't know where it is coming from.
Maybe it's related to these covariance variables.
I will be grateful for any help.
I started to use M/s2 instead of Gravity unit. So I don't have any delay.
But I do have a new problem which is annoying. I'm having some yaw drift problem which I don't know where it is coming from.
Maybe it's related to these covariance variables.
I will be grateful for any help.
- Attachments
-
- 1633613986-695454-image.png (363.21 KiB) Viewed 588 times
- Mason_Safavi
- Posts: 7
- Joined: Mon Aug 02, 2021 3:52 am
Re: Adafruit LSMD9S1 with Smooth Kalman AHRS
I don't why but no one is interested to help solving this issue.
- sj_remington
- Posts: 997
- Joined: Mon Jul 27, 2020 4:51 pm
Re: Adafruit LSMD9S1 with Smooth Kalman AHRS
I am not convinced that either of these is correct:
https://github.com/jremington/LSM9DS1-AHRS
As you can see, all that is required is to flip the signs of AX and GX, after subtracting offsets and scaling. People have been confused by this diagram in the LSM9DS1 data sheet, because they fail to notice that the orientation mark on the chip is not the same for the magnetometer axes, compared to the accel/gyro axes
NWU is correctly implemented as a right handed system, using the LSM9DS1 in this Mahony filter code. It works very well:Here is how am I feeding data to filter:
NED:
filter.update(gx, gy, -gz,
ax, ay, -az,
-mx, my, -mz);
NWU:
filter.update(gx, -gy, gz,
ax, -ay, az,
-mx, -my, mz);
https://github.com/jremington/LSM9DS1-AHRS
As you can see, all that is required is to flip the signs of AX and GX, after subtracting offsets and scaling. People have been confused by this diagram in the LSM9DS1 data sheet, because they fail to notice that the orientation mark on the chip is not the same for the magnetometer axes, compared to the accel/gyro axes
- Mason_Safavi
- Posts: 7
- Joined: Mon Aug 02, 2021 3:52 am
Re: Adafruit LSMD9S1 with Smooth Kalman AHRS
First of all, thanks again for your attention, it means a lot to me.
So basically what you're saying is using this data order to feed the sensor fusion algorithm instead of previous ones:
-gx, gy, gz,
-ax, ay, az,
mx, my, mz
After using this order it looks ok but I'm having some problem with yaw. After playing with filter values it's kind of better but it's not perfect yet. It takes a second to get to the right yaw direction.
Do you have any suggestions?
Thanks again
So basically what you're saying is using this data order to feed the sensor fusion algorithm instead of previous ones:
-gx, gy, gz,
-ax, ay, az,
mx, my, mz
After using this order it looks ok but I'm having some problem with yaw. After playing with filter values it's kind of better but it's not perfect yet. It takes a second to get to the right yaw direction.
Do you have any suggestions?
Thanks again
- sj_remington
- Posts: 997
- Joined: Mon Jul 27, 2020 4:51 pm
Re: Adafruit LSMD9S1 with Smooth Kalman AHRS
Great! You are on the right track.After using this order it looks ok
If the magnetometer is properly calibrated, and yaw is correct after the filter settles down (all the way around the compass circle), then the "slow settling" problem is most likely due to improper selection of either the gyro weight or the gyro scale factor, versus the accelerometer and magnetometer.
Please be positive and constructive with your questions and comments.