The deals dealer
The deals dealer

Reputation: 1016

How can i handle distance through accelerometer?

My object starts from zero. When the time goes..It covers some distance, so how can I measure this?

Upvotes: 1

Views: 278

Answers (3)

IanM
IanM

Reputation: 217

You can figure this out, but it won't be that accurate, mainly due to sample rate and the inaccuracy of the accelerometer.

First figure out direction and force of the movement. If the user moves the iphone at +0.1G along the X axis and 0G along the Y and Z axis, then our force is +0.1G on the X axis. 1G is 9.8m/s, so the phone has move 0.9m if it has been traveling for 1 second.

Upvotes: 0

DigitalRoss
DigitalRoss

Reputation: 146053

Oh, it's simple. All you have to do is implement an Inertial Measurement Unit and then an Inertial Navigation System. It's going to be hard to do without rotation sensors, it would probably require a Kalman Filter for accuracy, and typically it is done with ring laser gyros or fiber optic gyros, which are "solid state" devices that work by measuring relativistic effects and sell for rather higher prices than the silicon micromachined sensors in the iPhone, but you might get it to work.

Or, you could just use the GPS.

Upvotes: 1

Nate
Nate

Reputation: 30636

Other than just being alerted that the device did move, the accelerometer will not be much use. You will not get a reading of "device moved 10cm" or something similar, as far as I know you'll just get a value for how much acceleration occurred.

If you need to track your device's movement in the physical world you'll need to use the Location APIs.

Upvotes: 0

Related Questions