# Finding Relatively Accurate Velocity Using an IMU

I am currently working on a project where I am trying to accurately find velocity in a handheld device using an IMU for about 30 seconds. I have been having major issues doing this because of large amounts of drift from poor calculations due to inaccurate sensor readings. I have tried tuning offsets for my sensor and using other sensor fusion libraries to find my linear acceleration.

At this point I don't know if I am doing something wrong, going about the process wrong, or if my sensors are just to inaccurate to accomplish this.

I am hoping if anyone may have recommendations on how to accomplish this from the ground up. I currently have two 9DOF IMUS listed below. The first one I tried to use the predefined linear acceleration function to find velocity in ndof mode, using bosch calibration steps. The second i spent hours tuning the offsets on to get linear acceleration and it came out much worse than the first sensor. For the second I can include code but I used the madgwick from the Adafruit_AHRS library for the sensor fusion for sake of time.

Any help is appreciated.

2. https://www.adafruit.com/product/3463 (FXOS8700 + FXAS21002 second board)

Integration of acceleration to derive velocity is a difficult task. This is the first step in dead reckoning. Consider some of the following options to improve accuracy:

1. Some IMUs can be adjusted to increase sample speed. If the acceleration is sudden, more samples my improve the accuracy of the calculated velocity.
2. Try aligning just 1 of the axes of the IMU chip in the direction of acceleration. Do this to simplify the problem. Depending on the Arduino you are using, the processor may not have the power to perform the trig functions necessary for anything except acceleration only along 1 of the IMU's axes.
3. Take care of loosing significant digits. If using integers, try multiplying everything up. For example instead of 1 equaling 1 meter multiply the value up such that 1000 equals 1.000 meters. Now integer math can be used to calculate down to the mm.
• I do have it at the highest rate I can sample. Also unfortunately for my current project the imu is in a handheld device and therefore cannot be aligned in a easier fashion. Dec 3, 2020 at 5:30
• Hand held? Then you need get data from all 3 accelerometers. And do the math to add up the contribution of each to find the overall acceleration vector. Then integrate that vector over time in to a velocity vector. Maybe you can do this if you are clever on an Arduino Uno. But it my be worth looking at the specific processor used on different Arduinos and picking the fastest most powerful one. I think you should really start simple and then try to add complexity. Hand held is really really hard. A car would be easier as one can assume the car is always up right. Dec 3, 2020 at 6:25
• I actually have been doing the vector math. I believe the main issue is because of bad readings from the accelerometer or bad orientation algorithm, I am not able to subtract the gravity vector out without large error Dec 3, 2020 at 13:32
• This is 1 of several reasons I think it best to start simple and add complexity 1 step at a time. Thinking, maybe it's time for a trick. Warning, this will likely not work well over longer periods of time. But for 30 seconds, why not try subtracting the long term average from the reading. So at rest the device eventually zeros out. The long term average will not be able to respond to sudden acceleration so such acceleration will be seen by the velocity calculation code. Dec 3, 2020 at 14:44
• Okay thank you I'll give this a shot and let you know how it goes Dec 3, 2020 at 18:49