Hello,
I'm using a 6DOF IMU and working to mitigate gyro drift using a "zero velocity filter". I'm using an ESP32 micro and an ST ISM330dhcx IMU. The idea is to reset the gryo integration to zero when the device is "not moving". I'm attempting to judge if it's moving by calculating the RMS error of the XYZ accelerometers. You might disagree with this approach and I'm all ears on that subject, but here's my question... (if you suggest use Quaternions, try Kalman, try Mahoney etc I've read 10,000 examples and will do that eventually, trying step by step to build my knowledge with a complementary filter first)
I'm using the micros() function to take a look at the current sample and the previous sample from each of the accel XYZ and compute the root mean square variance of the change across that pair of samples. This appears to be about 0.3 degrees at rest, which somewhat makes sense. But I discovered that the variance sits in this range a lot, which I was not expecting, even when I'm moving it around quite a bit! I think what's happening is that for the speed of rotation from my hands, which will be typical for the project, the accel is outputting the same values multiple times, and sequential samples mostly don't change therefore the gryo is resetting over and over, and basically not working to correct drift. If I print the variance to the serial plotter, I can see spikes in the readout that seem to occur every 10 samples or so, with the values hovering under 0.3 degrees between those spikes. (I know the plotter will actually impact the measured intervals, but FYI)
So far in this project I haven't had to consider the output data rate for the accel, nor have I needed to micros() time window and only read/compare every n microseconds. There is a lot of flexibility here and I'm not sure how to logic my way through what should be the best configuration. With all of my atan/sqrt/pow computations and whatnot, the time between samples is about 2500 microseconds, as printed to serial. The accel output data rate is currently set to 6667Hz, which would be an output every 150 micros. I'm not sure where that leaves me because they are just not aligned - I would think that if I slow the data rate way down I might get more samples read but what's the point of running this fancy IMU at 26Hz, besides I've tried it and it's worse - the accel sits in that deadband even more and just resets to 0 continuously. I've tried every combo of data rate, accel low pass filter, and even a few micros() time windows, but nothing is improving the situation.
Not really sure what to do next, hence the lengthy post.
Any guidance / pointers appreciated!
Thanks