Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Example11_DMP_Gravity_Oriented_Accelerometer.ino #73

Open
wants to merge 1 commit into
base: release_candidate
Choose a base branch
from

Conversation

higherstateofawkwardness

As discussed with @PaulZC, this file rotates the raw accelerometer data using the Quat6 quaternion. An intialisation finds "down" and this is stored to allow the sensor to orient so that reported acceleration values are Up/Down, "N/S" and "E/W" in the external world frame.

I've set the sensor scale to 16g; if these values are exceeded then the quaternion loses it's lock. There is a routine that can be enabled to continuously correct the sensor to re-find gravity, but this is disabled by default.

There is a new function in there (findgravity) that I haven't highlighted in the keywords.txt; I also changed the readIMUDMP to returning a value so that this can be used for flow control within the main loop and decide whether to wait or continue to read more values. I wrote this using an openlog artermis but it should be device independent - any issues, please let me know!

Jon

As discussed with @PaulZC, this file rotates the raw accelerometer data using the Quat6 quaternion. An intialisation finds "down" and this is stored to allow the sensor to orient so that reported acceleration values are Up/Down, "N/S" and "E/W" in the external world frame.

I've set the sensor scale to 16g; if these values are exceeded then the quaternion loses it's lock. There is a routine that can be enabled to continuously correct the sensor to re-find gravity, but this is disabled by default.

I wrote this using an openlog artermis but it should be device independent  - any issues, please let me know!

Jon
@PaulZC
Copy link
Contributor

PaulZC commented Jun 13, 2021

Hi Jon,

This is brilliant stuff! Sincere thanks for submitting this.

Your code looks great and I'm delighted it is working well for you. But I'm also slightly puzzled too...:
The critical change I made in v1.2.6 was to ensure that the accel and gyro are not set to low power (cycled) mode:

// The InvenSense Nucleo example initially puts the accel and gyro into low power mode too, but then later updates LP_CONFIG so only the I2C_Master is in Low Power Mode
result = setSampleMode(ICM_20948_Internal_Mst, ICM_20948_Sample_Mode_Cycled); if (result > worstResult) worstResult = result;

And in your example I see you are using low power mode (how it was in v1.2.5):
https://github.com/sparkfun/SparkFun_ICM-20948_ArduinoLibrary/pull/73/files#diff-b49377a1f566bd815d5bbaff6f7aff00da2aadb2e3d6a0b3591d73b5901b3507R441-R442

So I'm utterly confused. (Not for the first time - especially where the DMP is concerned!) I'm guessing that your code actually compensates for the 'drift' we were seeing in v1.2.5? Just to put my mind at rest, could you please try having the accel and gyro not in low power mode? Does that make any difference to how your code behaves?

I am going to merge your example, absolutely no issue there, but maybe you could test this before I do?

Thanks again,
Paul

@higherstateofawkwardness
Copy link
Author

Paul,

Sure, not a problem - I updated the Arduino library to version 1.2.6 but obviously was still using the example 10 from version 1.2.5 as the base file for my tests. I'll try and get a free moment this week to plug it back in and make the changes.

Jon

@higherstateofawkwardness
Copy link
Author

Hey @PaulZC,

Sorry for the delays. I've checked the low power mode and it all seems to work out. I also noticed an error in the acceleration values from going to 16g, and have made a couple of changes that means that the code now seems to work with Quat9 (which should give a more stable heading when the gravity correction is enabled). Is there a way to modify the pull request, or should I start a new one with the modified code?

Jon

@PaulZC
Copy link
Contributor

PaulZC commented Jul 28, 2021

Hi Jon (@higherstateofawkwardness ),

Sincere thanks for this. You can just add your changes to this PR. Please just commit and push the changes to your patch-1 branch and they should appear here ready for merging.

Thanks again,
Paul

@ronaegis
Copy link

@higherstateofawkwardness - Would you be able to push your latest changes onto your 'patch-1' branch?

I would like to use the latest version of this example for my project, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants