Dhananjay Patil
Dhananjay Patil

Reputation: 452

How to calculate speed using accelerometer in ios

I want to implement a functionality to calculate the speed of moving object, but I don't want to use GPS(CLLocationManager).

Any suggestions on other ways to calculate speed?

Upvotes: 0

Views: 1925

Answers (1)

Caleb
Caleb

Reputation: 124997

I want to implement a functionality to calculate speed of moving object, but I don't want to using GPS(CLLocation).

An object traveling at constant velocity doesn't experience any forces for the accelerometer to measure, so the accelerometer alone isn't enough to determine velocity -- you can only measure changes in velocity. If you know the initial velocity, like if the user tells you that the phone is at a standstill, then you can monitor acceleration and use that to determine velocity. That's likely to be quite error-prone, however, and the error will accumulate over time so that your velocity measurement will become less and less accurate.

There might be other ways to measure speed, like taking several photos with the camera and trying to determine speed from the changes in the images. Or you could measure average speed between two known points by observing the time between leaving one known wifi SSID and reaching another. But the right way to determine velocity is really to use the Location Manager.

Upvotes: 2

Related Questions