No takers? C'mon guys! Why is this so hardddddd
Two words: kalman filter
I looked into the Kalman filter and what I found (or at least, the way it was being used in this instance) was to take a large percentage of the read from the gyroscope and add that to a small reading from the accelerometer (plus a certain percentage of the final result from the last read) and use that to determine an object's position. But it required that the object be constantly moving/rotating, like in a self-righting robot. It's always about to tip over so the gyro constantly has changing input. This solution won't do me any good if a vehicle is on a slope, but isn't rotating in any way. 95% of the 0° reading from the gyro plus 5% of the 5° reading from the accelerometer is going to read as almost 0°. (I posted a link of an example of someone using the Kalman filter for his self-righting robot in my first post on the thread.)
To be fair, I don't 100% understand the calculations going on in the Kalman filter, but this is how the Complementary filter works and several sources listed it as a "good enough" replacement for a Kalman filter. So while Kalman may be more accurate, the basic function at the end of the day should be the same as the Complementary.
(I'm actually using a Complementary filter when I display altitude from the barometer to get a smooth reading instead of the raw jumps of +/- 3 feet when sitting at rest.)
Unless my interpretation is completely wrong, in which case please point that out and tell me the secret of how I can get this to work for my project.