0

Can the iphone detect its movement in terms of distance?

Would one be able to use a built in function on an iphone to determine the distance the phone has moved so that the speed of movement can be calculated?

Basically my question is

can an iphone detect its position and distance moved without using the gps?

thanks

some_id
  • 29,466
  • 62
  • 182
  • 304

3 Answers3

6

You probably could with some clever math. Basically, integrate over the accelerometer data.

For all the details, see http://www.freescale.com/files/sensors/doc/app_note/AN3397.pdf

overscore
  • 513
  • 4
  • 15
  • 1
    (1) Although [Wiimote](http://en.wikipedia.org/wiki/Wiimote#Sensing) has an accelerator, it uses optical sensor to find its position. (2) The method in your slide works only if the iPhone does not *rotate*. Fortunately the latest model has a gyroscope so that effect can be included. – kennytm Jan 12 '11 at 14:15
  • 1
    Thanks for the correction, removed the bit about the Wiimote. See this thread for more discussion about the same topic: http://stackoverflow.com/questions/4449565/getting-displacement-from-accelerometer-data-with-core-motion – overscore Jan 12 '11 at 14:17
  • Thanks. It doesnt really get into detail and it seems a tough task. – some_id Jan 12 '11 at 15:03
0

No, the only sensor that the device has that can calculate "distance" is via the Location API, which will make use of the GPS. Accelerometer and gyros (in iPhone 4) can give precise measurements of changes in orientation, but not distance travelled.

MarkPowell
  • 16,482
  • 7
  • 61
  • 77
  • small is a relative term. The way your question was phrased, I thought you were talking about traveling some distance (i.e. walking down the street, driving a car, etc.). If that is the case, you won't be able to do anything via the accelerometer. However, if you are trying to determine the speed at which the user is swinging their arm then @overscore's solution should help you. – MarkPowell Jan 12 '11 at 14:14
0

Not easily, there are a couple of ways you can do this but they have severe limitations and you'll have to write all the code yourself.

One way is to use the accelerometer and try and calculate the distance from the forces on the phone, this is never going to be very reliable.

Another way is to use wifi, essentially looking at the signal strength to determine distance from the router (I think this is only possible using private APIs and requires several routers to be at all accurate). Or listen from a router to find out how far away the iPhone is.

James P
  • 4,786
  • 2
  • 35
  • 52