Quaternion from IMU and Euler angle

Hi,

I have understood that the onboard IMU of the Artemis Module could deliver and record directly the Euler angles from quaternion angles. I just tried to upload the IMU DMP Quat6 but the Arduino OLE tells me there is a trouble with a declaration (see attached picture).

So is it possible to get a help on that and on the way to record Euler angles. I must say that I still need to record GNSS data (10 Hz for the moment as discussed in an other topic).

Regards

Christian

Hello Christian,

You have the Pro nRF52840 Mini board selected. You need to select the SparkFun Apollo3 \ RedBoard Artemis ATP.

That code example was written for version 2.1.0 of Apollo3, but it should work perfectly with v2.2.1 (the latest version).

Best wishes,

Paul

Screenshot 2022-04-25 084231.png

Hi, Paul

I make slow but real progress as I am OK to compil the examples quat9 or 6.

But it is required to edit the ICM_20948_C.h to enable the use of the DMP.

I have found the file and the line but I am not easy on the process after that : where to change and copy the new file ?

Christian

Hello Christian,

It sounds as if you are quite new to changing and compiling Arduino code? There are many easier examples you could work through to build your experience. Modifying and re-building the full OpenLog Artemis code is a large and quite complex project.

You can find more information about the DMP here:

https://github.com/sparkfun/SparkFun_IC … ain/DMP.md

But, to answer your question, you need to modify and save (overwrite) the ICM_20948_C.h. Do not change its name. Do not change its location. The compiler will use the updated file when you re-compile the code.

Best wishes,

Paul

Hi Paul,

I tried to use Example6 and 7 quat9 and quat6 orientation after trying to modify the 20948_C.h file.

But I found that your proposed procedure to modify this file was not obvious for me as it is required to ask for a pull request in place of saving the change … I tried that till the point in the attached image …

Assuming that the modified files could have arrived somewhere in my directory (???), I tried to upload the Example7 and 6.

I got an appearance of upload success but with no initialization of the Artemis according to the com7 view (see the second image)

Please don’t forget that my need is to get orientation angles together with GPS data ???

Regards

Christian

tentative modif ICM 20948 firmware suite.png

Hello Christian,

Please use the OLA BETA binary. Open the main menu, then the IMU menu. There is an option to enable the DMP. Once enabled, you will be able to log Quat6 or Quat9 data simultaneously with your GNSS data.

Best wishes,

Paul

Hi ,Paul

Thank you for your answer.

The good news is that simultaneous attitude and GNSS data recording is possible

But, for the moment, sorry as I have not found something with name “OLA BETA binary”

Assuming that enabling the DMP option could also be done with the Terminal connection, I tried to configure it in accordance with the attached image.

Then, I uploaded the “Example7 … Quat6…” but it also ended with incorrect initialization !

Christian

OLA Configuration.png

Hello Christian,

The “OLA BETA binary” is the Beta firmware I created for you to let you log the GNSS data at 25Hz:

https://github.com/sparkfun/OpenLog_Art … 3_BETA.bin

https://en.wikipedia.org/wiki/Software_ … cycle#Beta

The IMU menu is the same as for the standard OpenLog Artemis. Using the Beta firmware, you will be able to log the GNSS data and the IMU quaternion data at 25Hz.

You can not use Examples 6 and 7 from the ICM20948 library directly on OpenLog Artemis. Extra code is required to configure the board correctly (enable power for the IMU, enable the POCI pull-up). If you want to experiment, please use the dedicated “IMU_DMP_Quat6” and “IMU_DMP_Quat9” examples from here:

https://github.com/sparkfun/OpenLog_Art … 20Sketches

Best wishes,

Paul

Thank you so much Paul,

In fact the Beta version works perfectly and gives the quaternion Q6 data. (see attached)

However, I see that It gives Q data but does not give Euler angles.

Those angles seems to be normal output of “Example7_DMP_Quat6_EulerAngles firmware” (see attached).

So my question is about the possibility and the difficulty to add this conversion in your Beta version ?

Regards

Christian

Hello Christian,

I regret you will need to convert the quaternions to Euler angles manually, on the logged data. You will be able to do it in a spreadsheet like Excel. The logged data is in Comma Separated Value format which Excel will understand. Or you could use the Python CSV library.

Please be aware:

https://github.com/sparkfun/SparkFun_IC … /issues/74

https://github.com/sparkfun/SparkFun_IC … /issues/77

https://github.com/sparkfun/SparkFun_IC … -863134578

Good luck with your project!

Best wishes,

Paul

OK Paul for a post conversion.

Another solution would be to change my configuration toward a “Sparkfun 9DoF ImU” (20948), which seems to produce Euler angles, connected with the NEO-M9N to a basic Qwiic OpenLog.

But I think that this would require firmware works …

Christian

Having battled with the same issues, here’s a link to a Python script to help convert Openlog (v2.2) IMU (Q6) data to Euler roll, pitch, yaw values:

[EulerValues gist

Will update as I add support for GPS data.](eulerAnglesOpenlog.py · GitHub)

What exactly is the meaning of Quat6 and Quat9?

How does Quat9 differ from Quat6?

Hello @decamun,

Quat6 is the orientation in Quaternions based on 6 Degrees of Freedom: accelerometer X, Y and Z; gyro X, Y and Z.

Quat9 includes the magnetometer X, Y and Z. Quat9 can provide the orientation relative to magnetic north.

Best wishes,

Paul

Thanks a ton! One other quick question:

Am I correct in assuming that the Quaternion numbers provided are Q1, Q2, Q3, such that Q0 would be sqrt(1 - (Q1^2 + Q2^2 + Q3^2)) with the full quaternion as [Q0, Q1, Q2, Q3]?

Correct:

https://github.com/sparkfun/SparkFun_IC … #L205-L215

And here’s where it is implemented in the OLA firmware:

https://github.com/sparkfun/OpenLog_Art … #L163-L170