Values from 9 axis IMU usig RTIMUlib minus gravity?


I am using RTIMUlib to obtain values from a 9 axis IMU (MPU-9150). I am getting the ‘default’ data to be displayed OK (accel, gyro, Mag & Fusion). However I would like the accelerometer values to be displayed minus the gravity element. I have read on this forum that RTIMUlib should be able to provide that data but I cannot figure out how to get it. Please can anybody help?

Many thanks,


The code is posted somewhere in this long thread:

The errors in the measurements (at least with consumer grade IMUs) are usually large enough that the operation is a waste of time and effort.

Many thanks for your reply. My project is to have an object (containing the IMU) in a static position. I then want to launch the object into projectile motion and measure the negative acceleration (x, y & z axis) at a fixed time after the object is launched (best analogy would be to imagine a ball being kicked). The time after the object as launched will ideally be within the first second of projectile motion but the object could rotate during that time. I do not need to track the objects position over time. I just want a single, instantaneous value of the negative acceleration in all three axes. Do you think this sort of application would provide accurate readings given the timescales involved and considering the measurement errors you refer to in your aforementioned thread?

Many Thanks,


Probably not.

After launching, a ball in the air will be subject to two forces: gravity and air resistance. Since the accelerometer is (presumably) fixed inside the ball and is equally accelerated by gravity, it will in principle measure [u]only[/u] the acceleration due to air resistance on the ball.

Is that what you mean by negative acceleration?

By negative acceleration I mean the deceleration as a result of the air resistance. To use the kicking a ball analogy, my understanding is that once the ball has been kicked it will immediately start decelerating in all three axis due to air resistance and gravity in the opposite direction to the velocity of the ball. My objective is try to measure this deceleration as soon after the ball is kicked as possible. If this is not possible with an accelerometer due to the errors in measurement as a result of the attitude estimation error, is there perhaps a better sensor for this purpose I could use?

One other question - you state that "column 1 (acceleration) is high by a factor of 100 and column 3 (position) is high by a factor of 2." Does that mean that that in the case of 2 degree angle error, column 1 should read 0.00342m/s/s and column 3 should read 17.1m?

Many Thanks,


you state that "column 1 (acceleration) is high by a factor of 100 and column 3 (position) is high by a factor of 2."

I notified the owner of the site, and the table has since been corrected.

The best way to measure air resistance on a ball is to put it in a calibrated wind tunnel and measure the actual force on the ball as a function of wind speed. I'll bet that this has been done many times, so try some library research.

You could also try putting a ball at the end of a flexible rod with a strain gauge to measure force, put it out a car window, and drive at different speeds on a wind still day.

Air resistance is not a simple function of speed.

Many Thanks for clarifying the table. I have read that sensor fusion using magnetometer data can reduce the position error after 60s to around 5 meters. Considering that the time frame I am interested in is around 6s then that amount of error would be perfectly acceptable for my application. I assume the fusion of magnetometer data reduces the angle error? If I can get down to around 1-2 meters error after 6s that would be OK. Is this a realistic goal?

Unfortunately, I need an on-board solution for my project so any other external measurement solution will not work.

Many Thanks,


I assume the fusion of magnetometer data reduces the angle error?

No, the magnetometer supplies the reference information for the yaw angle.

Without the magnetometer, the yaw angle usually drifts so rapidly it is essentially useless.