Tracking position using an IMU is extremely difficult to achieve. This is because the an IMU is only able to provide a direct measurement of acceleration (from the accelerometer) and the position must be derived from this through ‘double integration’; the accelerometer is first integrated to yield a velocity and then again to yield the position. This dead reckoning process means that even the smallest measurement errors result in an exponentially increasing error in the position.
However, it is possible to use an IMU to track position if constraints of a specific application can be exploited. In a previous post I showed how an IMU attached to a foot can be used to track the wearer as they walk around a building. This is made possible by zeroing velocity errors each time the foot is detected as stationary during each stride. An alternative scenario were position tracking may be possible is when the subject is engaged in cyclic motion; when the mean velocity and position are zero over a short period of time. For example, this might represent the motion of a buoy bobbing up and down in the ocean or the chewing motion of a jaw which I demonstrated in a previous video. Earlier this year, a student contacted me asking if I could help him solve this problem for tracking the motion of a camera so we put together some code in MATLAB lab and he recorded the recorded the video below as I explained what we were doing.
In the video we use the x-IMU to log test data via USB and then process the logged data using MALAB. Only the gyroscope and accelerometer measurements were used. The sensor data was first processed through an AHRS algorithm to calculate the orientation of the x-IMU relative to the Earth so that the corresponding direction of gravity could be subtracted from the accelerometer measurements. The resultant measurement of acceleration was then integrated to yield a velocity and the velocity high-pass filtered to remove any drift. This was then integrated again to yield a position which was also high-pass filtered to remove drift. The resultant position tracking seen in the video is able to track the cyclic motion of the x-IMU but slowly ‘pulls’ the x-IMU back to the origin when it is stationary.
The original source code and example data used to create this video is available on GitHub.