-
Notifications
You must be signed in to change notification settings - Fork 79
How to read calibration value of DMP? #50
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
Comments
Hi Mehmet (@mfide ), I had a chat with InvenSense about this. They say that it is possible / advisable to store the DMP bias values and restore them after power cycling. The bias values are here. You can read and write them using the For reading, this should work but is untested:
You will need to reverse the byte order (big-endian to little-endian) if you want to convert gyroBiasX into a int32_t. Please let me know if this is successful. |
Thank you Paul for your effort. When I try to read them like you suggest, gyro bias are changing which is good but the rest of the values I read them as zero.
Is this the case for you as well ? |
Hi Mehmet, |
Hi Mehmet, |
Hi Mehmet (@mfide ), Please try version 1.2.6 of the library. I have made one important change which was preventing the DMP from operating correctly. I hope this solves your issue. But please re-open this issue if you are still unable to read the bias data, and I will do what I can to help. Best wishes, |
Hi Paul, Thank you for the great effort. Today I just tested v1.2.7. Mehmet. |
Hi Bongas (@Bongasman ), Todd and colleagues, Unfortunately I don't have an answer for you. The DMP is (almost) a complete black box and there are still many things we do not understand about it. I believe it should be possible to read, save and restore the DMP's internal 'calibration' data, and there are methods in the library to let you read and write the DMP registers, but we we have no information or guidance on which register values are the correct ones to save. If you do manage to solve this issue, please do send us an example. Myself and many other users will be very thankful. Best wishes, |
Thank you @PaulZC, If we find something helpful, we will let you know. Nevertheless you did a great job on your library thus far. I just wish InvenSense could do a library or example to address this issue. |
@PaulZC Thanks Paul, for all your help. I have no problem "bugging" or working my way through the company invensens to try and find some answers. I'm the business/tech person on the team but if you can provide me some basic information, then I can start trying to find those answers from them.
Or, put another way, if you can write up something short that I can work with, I'll do the work communicating with invensense to try and get that information. You and others have done alot , so if I can help by pestering them for help, I'd be glad to pitch in that way. Thanks, |
Hi Todd (@toddmurphy ), From the DMP Page: " So, with apologies, I cannot send you the documentation... The methods you need are: SparkFun_ICM-20948_ArduinoLibrary/src/ICM_20948.h Lines 210 to 211 in d5ae1eb
I believe the most important registers are the biases: SparkFun_ICM-20948_ArduinoLibrary/src/util/ICM_20948_DMP.h Lines 94 to 105 in d5ae1eb
but that's just a hunch. There's nothing in the documentation which specifies which registers should be saved and restored... Good luck! |
@PaulZC cc: @Bongasman Thanks....yes, i remember reading those values in your code. So,let me get this straight... Invensens provided the bias methods for GYRO, ACC, COMPASS, but, they didn't provide the registers or location actually save and restore the data (WTF). So, to confirm what we need Invensens to provide the community, is "register" values/locations to save and restor: If you can confirm that, I will reach out to Invensens to see if they can help or if they can engage an internal engineer to dig into the DMP code or provide an update of anykind. Cheers, |
Hi Todd (@toddmurphy ), We know how to read and write the DMP registers. And we know the location of the named ones - some were in the InvenSense App Note, some we had to extract from their demo code... The questions we need answers to are:
Best wishes, |
@PaulZC Thanks for the prompt reply and for the information I need. I'm on it and going to try and work my way through contacting them in hopes to get the answers we need. Give me a few days to start some outreach. |
@PaulZC i'm communicating with an invensense firmware support person (connected by an executive member) and his first question and can you let me know, and I'm assuming you have this implemented? Paul if you can provide me and email, I can bring you in on the email chain? Can you first let me know if you’re using the latest ICM-20948 driver on our website? (“DK-20948 SmartMotion eMD 1.1.0”)? |
Hi Todd, The library includes two copies of the DMP firmware. The default is the one mentioned.
Best wishes, |
Hey @PaulZC I'm not a programmer at all but was just doing some research and comparing your code to the Device driver files specially the Magenetometer Registers for DMP reading and noticed potentially a key one missing or you may have renamed it i'm not sure but would this register mean anything to you for Reading to the DMP. I search all of your files in your library and didn't come across this Compass Register for reading the DMP. |
Hi Todd, I don't think this is an issue... InvenSense have called the AK09916 register at location 0x3 "REG_AK09916_DMP_READ". I.e. the DMP starts reading the mag registers at location 0x3. In our code, it is called "AK09916_REG_RSV2" - also at location 0x3 (as defined by the enum). "RSV2" is the name used in the AK09916 datasheet. Here's where we configure the peripheral with that address:
So, yes, we've just used a different name for the same register. The registers following 0x3 are not actually named or defined in the AK09916 datasheet whatsoever... Hence the references to "secret sauce".... Welcome to the weird and wonderful world of the DMP! |
SparkFun_ICM-20948_ArduinoLibrary/src/ICM_20948.cpp Lines 1167 to 1171 in d5ae1eb
|
@PaulZC cc @Bongasman Paul, I've been playing email tag with their support, which I know you probably did as well and maybe a phone call. Here's the latest feedback provided from their support. In addition, they also email me the "App Note" document you reference. Does this response from Invensense help in anyway?
I'm taking a guess that they are referring to these values in the red rectangle. I'm not a programmer so i'm not sure if these are Registers BUT did you try to read and write to these values? If so, what happened? Cheers, |
Hi Todd, Please re-read this entire thread - starting at the beginning. I honestly can't remember if I personally tried writing the bias values back at several different points in the DMP start-up sequence. I suspect I must have done, but it is many months and many, many projects ago... Best wishes, |
Hi @toddmurphy @Bongasman , Were you able to make any progress with saving / restoring the biases? Please let us know... Thanks! Best wishes, Tagging @valery-ngwa as he was asking the same question as you guys... |
Hey @PaulZC Hey @PaulZC Sorry for the delay getting back to you. Yes, we've been corresponding back and forth with Invensense Support and they've been helpful and if we need more detailed help they have consulted with their software engineers. I was waiting to see how @Bongasman and @valery-ngwa made out this week as they've been working together testing out some of the answers Invensense sent us late last week. But, it seems Valery is having some potential confusion or help as to why he emailed you directly. I'll post the screenshots of the email chat (names from Invensense taken out) and I'm probably sharing things you likely already know, but, these conversations with Invensense is what helped Valery and Bongas. The only thing that we may have got clarification on was when to save the biases data, which i highlight in red rectangle. It seems that Valery and Bongas are kind of spinning around your issue links #50 and #60 Here's the order of emails reply with relevant sections.. @PaulZC does any of this information help? As for Valery and Bongas, Invensense told us to grab code from the drivers to read and write and bring that code into your library. So, i'm pretty sure that helps bring context to Valery email directly to you. Feel that we're getting close in concept how to solve this but from a code implementation, still unsure. |
Hi @toddmurphy & @valery-ngwa, Todd: the information from InvenSense helps a little, but not a lot. One key question you still need an answer to is:
However, while I'm writing this, I'm looking back at both our code and the bus traffic we captured from the InvenSense example (in DMP.md). I'm wondering now if I'm enabling the DMP at the correct point... The sequence, from the bus traffic, is (approximately, skipping some steps):
Looking at our library and Example10, the sequence would be (approximately, skipping some steps):
Humm... I'm wondering now if I'm enabling the DMP too late? Perhaps I should be enabling it before setting the gains etc.? That still leaves the question about when in this sequence the biases should be restored... Before or after the DMP is enabled? I really don't have time to dig into this any further right now. Can Bongas and Valery experiment with this? Valery: to answer the question in your email, yes, your DMP read and write code looks correct. There are plenty of DMP-write examples in Example10. The syntax for your DMP-read looks correct too. Example10 overwrites I hope this helps! |
I haven't looked at the InvenSense Application Note this way before... Maybe the intent all along was to:
|
Thanks very much Paul. I am grateful for your quick replies. We will
experiment as you said and see what it will give. Thanks very much sir
…On Tue, Oct 25, 2022 at 10:00 AM Paul ***@***.***> wrote:
I haven't looked at the InvenSense Application Note this way before...
Maybe the intent all along was to:
- Perform the HW Setup - up to and including setting the compass mount
matrix and scale
- *Enable the DMP*
- Configure any required Advanced Hardware Features - including:
- Accel Cal Rate
- Accel Alpha Var
- Accel A Var
- Compass Time Buffer
- Gyro Scale Factor (Gain)
- Accel-only gain
- *The biases*
—
Reply to this email directly, view it on GitHub
<#50 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AENN4ELULNR2TWZTKRJMFD3WE6ORDANCNFSM4ZU3IY4A>
.
You are receiving this because you were mentioned.Message ID:
***@***.***
com>
|
Hey @PaulZC cc: @valery-ngwa Great breakdown Paul. In combination with what Invensense has said to do and you're most recent breakdown, I put together a flow or visual of an example to help illustrate and maybe simplify the process. In the flow, I provided and an example similar to a research project that we are working how I think the calibration flow "might" work. Like I said, I'm not a firmware developer and only understand this at high level for code, but, I parsed out your second reply which I think makes really good sense of when to: Enable the DMP and then Load the Biases. It's how Invensense seems told us how we should do it and based on my flow it seems logical to do it this way. Again, I have no idea how many of those steps are required in the code steps you listed, but, if we can strip out anything we don't need, then the flow attached "could" work. |
Hi Todd (@toddmurphy ), Nice project - and nice diagram. That all looks OK to me. Let me know how Valery gets on with changing the point at which the DMP is enabled. It could be a magic wand... Best wishes, |
@PaulZC cc: @valery-ngwa Glad to hear it came across as clear and what our goal is. I have a question to help me follow along.
Thanks, |
@PaulZC cc: @valery-ngwa Paul, Do you have these same functions in your code to read and write the ACC and MAG biases to DMP?
|
Hi Todd, We've discussed this previously: #50 (comment) @valery-ngwa sent me some code (via email) he had written to read and write the biases. To my eyes, it looks OK. If he changes the point at which the DMP is enabled and afterwards is able to read non-zero biases, then you're definitely heading in the right direction. Please let us know how it goes. Best wishes, |
Hey @PaulZC cc: @valery-ngwa Just thought I'd get your feedback or see if you came across this or a solution as to why the ACC bias isn't reading or writing for both your library and the Invensense library. @valery-ngwa has done a lot of testing on both libraries (see screenshots) and also tested various combinations of when to enable the DMP and the screenshots show the results.
Thanks |
Hi Todd, All I can say is that Mehmet - who opened this issue originally - had the same experience as you. He was seeing non-changing values in the Accel biases: #50 (comment) Perhaps the non-zero values Valery has seen are just the random contents of the DMP memory? The fact that they are not changing is - I believe - the critical issue here. @valery-ngwa : did you try moving the IMU while observing the biases? Does the value change after you place the IMU in all six orientations? Another test you could try: change the Accel biases to a completely different value using Best wishes, |
Hi Todd (@toddmurphy ) and Valery (@valery-ngwa ), Another user sent us a pull request containing methods to read and write the DMP biases. That prompted me to write a quick example to test them. As far as I can tell, the biases are being saved and restored correctly. Please see the release notes for more details: https://github.com/sparkfun/SparkFun_ICM-20948_ArduinoLibrary/releases/tag/v1.2.10 I certainly see non-zero biases for all three sensors: Restoring the biases after starting the DMP does appear to work well, but you do need to wait for about ten seconds for the values to stabilize. To test:
Please note that the ESP32 EEPROM does not get overwritten when you upload new firmware - unless you enable the "Erase All Flash" option. I hope this helps, |
@PaulZC wow, where did this come from out of the blue? I pinged Invensense three times last week and staying on them for updates. My contact and support person told me that the software team was looking at this issue. I tasked them to provide working code and example based on their library and/or your library. I thought this update might've come from an internal invensesense engineer but thanks @ThreadOfFate for the contribution (huge high five) Either way, this is very good news seeing that from their code the example works. @valery-ngwa will test today or tomorrow and let us know his results. Either way, once i hear back from invensense internal software results on their findings, I will share immediately. |
Yeah I worked on this when we expanded the SlimeVR project to support the ICM20948 for IMU based motion tracking. Anyway it was somewhat forgotten about when I took a break from the project, until I came back and realized we should probably share our changes with the main Sparkfun repo. |
@ThreadOfFate @PaulZC cc: @valery-ngwa Just letting you know that Valery was successful getting the biases to save and load. I'll include both screenshots |
@ThreadOfFate I watched a few vids on you tube and was wondering how you're dealing with the dead reckoning or eliminate most of the drift so characters or people running around don't go flying off into space :) I was wondering if you had any code you're comfortable sharing, algorithms you used, something like in this short video https://youtu.be/WpJhFl35M_8 we'd like to test a few options and looks like you have this issue solved with the icm-20948. I also notice you're using the RJ45 connectors or usb patch cable locking mechanisms to daisy chain the cables. If you you're looking to reduce your connector sizes to much smaller, i'd be happy to show you how we have super small cables and how the cables won't pull out. Might help you in your design options :) |
@toddmurphy Our project is open source, and our devs are pretty active on the Discord if you want to ask anything. RJ45, JST and USB are fairly common methods our community uses for chaining imus, our community would love to hear of more options, we have quite a few people who like to tinker with the base design as you would imagine. |
Hi @PaulZC @ThreadOfFate from: @valery-ngwa cc: @Bongasman This is Valery. We could use your help again, much appreciated. I encountered the following again. The moment I thought all is well and going smoothly, I got stuck somewhere again. I have been on this for the past 4 days trying to figure it out but it turned out that I have no choice than to get back to you two for a little help. These are my worries:
But when I tried to serial print any two or all of the sensors’ data, I got funny data printed. I am using this code in the loop function
Thanks, |
Did you check Header2 to see if the accuracy data is actually being returned? Otherwise you could be reading zombie data... SparkFun_ICM-20948_ArduinoLibrary/src/util/ICM_20948_DMP.h Lines 484 to 486 in 486fdbf
I think you will need to do something like:
|
HI @PaulZC cc: @valery-ngwa @Bongasman I just edited/updated code. When i run it, i got the first set of data from all the sensors. After rotating sensor slowly around all three axes and held stationary in for a few seconds all six orientation. It displayed another set of values with accuracy of 3 as shown in the screenshot of the serial print. I keep receiving only two data from each sensor. I am confused. I do not receive the garbage data as before. but no matter how much I move the IMU devices, no other data is displayed? Thanks, Any thoughts on next steps? Are we missing any functions we need to include and call here (ex: AGMT functions like i seen in other posts)? |
The way you were checking Likewise, you can only read the Accel_Accuracy if You need to split your code so you check both header and header2 and then extract the data only if the header tells you it is there. I guess you're only seeing data twice, because the Accel_Accuracy is only being output twice. I think your issue is that you need to |
HI @PaulZC cc: @valery-ngwa @Bongasman Essentially, we're stuck now and need to have this working to get over the hump so we can test our prototype. We've referenced invensense, Threat's code to see if we can figure it out but not luck. QUESTION: Are you able to try the suggestions you made to see if you can get working on your end and update the library? Or, are you the same errors that we're getting? We'd greatly appreciate it if you could test this really quick and let us know your findings? Thanks, |
Hi Todd (@toddmurphy ), I’ve said it before: “Welcome to the weird and wonderful world of the DMP!” I really do not have time to investigate this for you. I’ve spent far too many weeks trying to understand the DMP. It’s really not a great user-experience. And, with the 20948 essentially being end-of-life, I really can’t justify throwing more time at it. We have, I fear, reached the end of the road. Good luck with your project - I hope it is successful, |
Hi @PaulZC , Well said, totally agree. We've been discussing moving to their newer models and updated firmware...same for us, we've exhausted our time with DMP and might be worthwhile to move to their new Apex firmware. We've wasted so much time with DMP too. They seem to have a bunch of examples code and projects out of the box and the Apex architecture looks much easier to use. Have you looked at their new Apex firm and development kits? I've been corresponding regularly with an INvensense engineer and he suggested this test dev kit https://www.mouser.ca/new/tdk/tdk-invensense-smartsense/#Bullet-3 What's your suggestion should we move to a totally different IMU company? The calibration is super important for us so if you have any suggestions and well supported libraries for us to look at, please provide some names or links, much appreciated. Again, thanks for all your help we can't thank you enough. |
Hi Todd (@toddmurphy ), I have no experience with the ICM-426xx parts so I can't really guide you there. But they do look interesting and I do see fusion, quarternion and euler angles mentioned in the 42688 software guide: The Bosch BNO sensors and the ones by Hillcrest Labs (now CEVA) are good and well worth looking at. There were supply chain issues recently but those may have been resolved. If you do want to throw more time at the 20948, the critical piece of code to look at is here. Each time a new sensor is enabled, this code adds it and updates the DATA_OUT_CTL1, DATA_OUT_CTL2, DATA_RDY_STATUS and MOTION_EVENT_CTL registers. It's a cumulative thing, sensors add on top of sensors. You can 'remove' a sensor by setting Anyway, good luck, and have a great Christmas. |
How can I read calibration value of DMP and set it back later? Is there an interface for this in the library?
The text was updated successfully, but these errors were encountered: