- Home /
Get absolute acceleration data from accelerometer/gyroscope but neglect rotational acceleration
So I want to be able to get data where if I move my phone from point A to point B I would get the acceleration (absolute acceleration). Obviously the answer would be to either use the accelerometer and subtract gravity or to use the gyroscopes useracceleration method. However these readings also give me rotational acceleration, the data I want to ignore. Here are three ways I tried to accomplish this. I am using boo to script this. However I am just as fluent in javascript so I can accept answers in that code. I also can understand c# so you can answer in any language you are comfortable with and I should be fine.
rawGravity = Input.gyro.gravity
rawAcceleration = Input.acceleration
gravity = Vector3(rawGravity.x, rawGravity.z, rawGravity.y)
acceleration = Vector3(rawAcceleration.x, rawAcceleration.z, rawAcceleration.y)
linearAccel = acceleration - gravity
Or you can do this
rawUserAcceleration = Input.gyro.userAcceleration
userAcceleration = Vector3(rawUserAcceleration.x, rawAcceleration.z, rawAcceleration.y)
Or if you don't want to use the gyroscope and only use the accelerometer you can do this. (Initially pass in (0,0,0) for gravity so It can run in the first frame).
rawAcceleration = Input.acceleration
acceleration = Vector3(rawAcceleration.x, rawAcceleration.z, rawAcceleration.y)
gravity = 0.9*gravity + 0.1*acceleration
linearAccel = acceleration - gravity
All of these give about the same readings. But when I rotate the device, I get huge acceleration readings from these methods when I want to ignore acceleration due to rotation. Basicly if I am rotating my phone, I should get the values (0,0,0). The only way I've think could work would be by taking those values and subtracting gyro.rotationRate from them. Since rotationRate is basically rotational acceleration. However when I do this, the data must not match up correctly and I don't get any better readings.
Did you ever figure this out? Sorry for not providing an answer but I'm also struggling with this