Linear acceleration Mobile

I am getting slightly confused with linear acceleration. I am trying to create an AR application and need to track the linear movement of a mobile device, I have tried converting the linear force into force on the axis over time but nothing I try seems to work. It seems that the linear acceleration within unity (with gravity removed) is still recording rotation, is this correct?

Here is a little segment of the code:

//Work out the velocity of X on the users acceleration
    fl_Vx += (v3_PrevAccel.x + Input.gyro.userAcceleration.x) / 2.0f * Time.deltaTime; 
    fl_Vx = fl_Vx * Time.deltaTime; 

This is just for getting the X axis it is later added to the gameobject via a translate, although it has been added as a transform.position as well but to no avail either way.

I have searched around a bit before putting this code together.

I am aware that any solution will not be perfect but if I could just have a hand sorting something out, even if there are some inaccuracies, it would be truly appreciated.

1 Answer

1

What you are describing, integrating motion using only the gyro, is very difficult. If you want something to search for try the term ‘dead reckoning’ which describes what you are trying to do.

The reason why this will be very inaccurate is because by converting force into velocity, and then velocity into position you are integrating twice, and any inaccuracies will be magnified.

It’s a very complex topic but this is a good talk on it, Sensor Fusion / Google Tech Talks:


This is a related topic:

And you might also want to check out http://www.vuforia.com/ , which is a popular augmented reality SDK.

Also, I don’t think that anything in the question is specific to Unity, so you could try searching or asking on StackExchange.