开发者

logic to count steps while walking using accelerometer feature in iphone

开发者 https://www.devze.com 2022-12-16 06:20 出处:网络
How can I use the accelerometer开发者_如何转开发 feature in the iPhone to calculate distances while walking?You can\'t use the accelerometer to determine distance.

How can I use the accelerometer开发者_如何转开发 feature in the iPhone to calculate distances while walking?


You can't use the accelerometer to determine distance.

If I'm at rest, the accelerometer detects only acceleration due to gravity. This obviously set the walking distance to 0.

But if I'm walking at constant velocity, and start your app while walking, my acceleration is also zero, thus the accelerometer detects only acceleration due to gravity again. The situation is same as above, and the walking distance is 0, which is incorrect.

Not to mention the difficulty in dealing with changes of acceleration due to the orientation of the device.

You need Core Location to compute anything related to distance. You can use the accelerometer to implement a pedometer but that only counts steps, not distance.


It would probably make more sense to use Core Location for this.

In fact, a sample app to calculate walking distance and speed is created in chapter 24 "iPhone Location API" of iPhone SDK Development by Bill Dudney and Chris Adamson.

0

精彩评论

暂无评论...
验证码 换一张
取 消