Arduino/Genuino 101 CurieIMU Orientation Visualiser: Yaw Does Not Return to Zero

Hello,
loaded up the Arduino code and ran the Processing code. Impressed!
What I was perplexed by was after moving the Arduino through X,Y and Z rotations and translations, and then returning the Arduino back to its original position on my desk (I have pencil lines as a datum), I see a yaw error, i.e. the Processing screen shows the image skewed from the original position.
I have done some deeper examination just in the Arduino environment using the Serial Monitor and Serial Plotter with some modified code. The ax, ay, az, gx, gy and gz values return approx back to their original values before the Arduino board is rotated/translated, as do the pitch and roll values. However, the yaw value does not. Furthermore, the roll and pitch values return to zero but not at the same rate, i.e. the roll value steps down in a fixed cadence whilst the pitch value steps down at a fixed but longer cadence. The yaw value will also change at a cadence longer than the pitch, but not always trending to zero. Once both have reached their zero values, the yaw value does not change and shows the error. See attached image. In the image you will see that the yaw, roll and pitch values are all zero per board/IMU calibration. Then you will see the disturbance when I move the board. The board is then placed in its original position. You can observe the roll and pitch trending towards zero at different cadences, and the yaw increasing at a different cadence. Once the roll and pitch are both zero, the yaw never changes. This data was captured using PuTTY, with the corresponding output file data dropped into Excel. I have tried this on two 101 boards and both exhibit the same issue.
So, a) is anyone else seeing the error in the Processing image, b) anyone got any idea as to why the error occurs?

Yes. I see the same problem.

I see this problem too.

Hi guy's,

A short explanation. A gyro measures angular speeds, so you have to integrate those speeds to get a position, but even then you don't have a start value. An accelerometer uses earth gravity as a reference. So that is used to give the gyro an initial value and corrects a gyroscopic drift (because with an integration you'll add small errors on top of each other). But for yaw there's no change in gravity. So you'll always have drift. To compensate the yaw drift you could add a compass (therefore you also have 9dof imu's). If you have a GPS and sufficient speed (for a drone) you could use that to calculate a direction, but that won't work if you don't move.

Hope that helps. To know more about this look for filters to combine accelerometer, gyro and compass values like Kalman, Complementary and/or Made wicked filter. The last one is included in the library for the 101.

Hope that helps.

Regards, David

Hi David, thanks for the explanation. Looks like I have some reading to do :-) If you have any good links to appropriate materials on this topic I would be grateful if you could share please. I will also post what I find too. Best, Ellers

Hi Ellers,

I would suggest that you try and get through Madgwick's paper, think the link is on the CurieIMU page, if not just do a search for Madgwick filter and you will get to it.

One of the things that Madgwick incorporates into his algorithms are a kind of PID. Most implementations start with a standard set of values for Kp and Ki but in my experience you have to tune these values. I can not find the Madgwick AHRs library - I am assuming you are using the recommended library so I can not help you with the tuning right now.

I would also check out the Freeimu-updates wiki on GitHub. There is a discussion there on tuning the algorithm. I am the author of those updates so I put what I knew there.

Hope this helps.

Mike

PS. Based on the lib (https://github.com/arduino-libraries/MadgwickAHRS) just found the link they implemented only one version his filter - the betadef term in the cpp file is currently set to 0.1f the value that I am currently using is 2.5f. There is no guarantee that this value will work for you but this shows the differences. Also, just a quick scan not sure if they incorporated some recommended fixes to the algorithm - will have to take a deeper look.

Hi Ellers

Here is a link to a YouTube video I just uploaded using my visualizer version, the freeimu library and the Arduino 101 CurieIMU.

https://youtu.be/UU7mThRHBEs

Cheers and good luck. Mike

Hi merlin,

Can you please share the code you used for testing 101 using FreeImu lib

Hi Merlin,

I have the same problem. Drifting. I've watched your video on youtube and downloaded the library. What example should I use from the library ?

Thanks

Hi Roblars

Load the Curie_IMU_CurieFreeIMU_serial_ARM_CPU.ino file. You will need to do a calibration of the accelerometer and magnetometer using the FreeIMU_GUI which is written in Python. Save the calibration file to the FreeIMU library directory and you should be good to go.

The library is a generic library that supports a myriad of other IMUs so you will need to uncomment the CurieIMU and make sure all other boards are commented in the FreeIMU.h file.

If you go to the Wiki on the FreeIMU and go to the appropriate section you will find all the information you need.

Mike

Hey Merlin,

I actually don't need the calibration in python, I just need to get the jaw roll and pitch angles from the serial monitor. So I can link these values to max msp. Hoping these will be "drift less"

I tried to compile the sketch but it says

‘class FreeIMU’ has no member named ‘magn’

what does it mean ?

Magnetometer I believe.

Merlin513: Hi Roblars

Load the Curie_IMU_CurieFreeIMU_serial_ARM_CPU.ino file. You will need to do a calibration of the accelerometer and magnetometer using the FreeIMU_GUI which is written in Python. Save the calibration file to the FreeIMU library directory and you should be good to go.

The library is a generic library that supports a myriad of other IMUs so you will need to uncomment the CurieIMU and make sure all other boards are commented in the FreeIMU.h file.

If you go to the Wiki on the FreeIMU and go to the appropriate section you will find all the information you need.

Mike

Are you sure it works also for Arduino 101? Because i read all the documentation, but i understood that FreeIMU is for FreeIMU board, how can i set it for Arduino 101? Because i could upload the ino code on Arduino(i think that is the CurieIMU Unique), but then in the Python code haven't I to setup/change anything?