14

I first started thinking I could use CoreLocation to track speed in order to determine movement. This didn't work as I don't want to run the battery dry and at lower settings the speed and location readings are far from accurate. I then moved on to using the accelerometer to track movement like this: http://blogs.oreilly.com/iphone/2008/06/iphone-as-pedometer.html

This works surprisingly well but it's not as good as I'd like. The big problem occurs when you're holding the phone staring at it while walking. In this scenario the above linked code doesn't work. If it's in your pocket or on your arm it's a great tracker of movement.

So, with all that being said, are there any techniques out there for a pseudo pedometer using the iOS Accelerometer (not M7) that would be accessible to a non math wiz?

2
  • Just thinking out loud... An accelerometer measures acceleration, right? So it wouldn't be able to tell if the user is stationary or moving at a constant speed Feb 15, 2014 at 22:42
  • 1
    Could you describe the field of application of significant movements. It is not clear, why CoreLocation doesn't match requirements.
    – vokilam
    Feb 17, 2014 at 11:06

6 Answers 6

0

Well, people tend to hold their phone still when they're walking. It can't be perfect, no pedometer can. You'll have to settle for it not updating when they hold the device, which if they're walking, they shouldn't be doing much of anyway. You could try and find the average pace, and whilst the wake-lock is off (I.E they're looking at the screen) then increase the count based on average pace?

0

If using only accelerometer, you can't track movement distance, since accelerometer can only detect accelerating, which can't be accurate when a guy is walking.

Maybe you can use accelerometer as a step counter, count the step the user walks, and using low accuracy GPS(or a short time high accuracy GPS) to detect the average step distance, combine this two data, you can roughly measure distance the user traveled while using little battery.

When you detect that the user is traveling fast, he can't be walking, then you can use low accuracy GPS only.

2
  • "If using only accelerometer, you can't track movement distance" isn't exactly true. If you know the user's initial velocity then keep checking the user's acceleration, you could by approximation "integrate" acceleration from start to the current time to get velocity then integrate that again to get distance. And it would probably kill the battery and/or not work very well.
    – sudo
    Mar 20, 2014 at 20:28
  • @9000 your method is right, thank you for reminding me.
    – CarmeloS
    Apr 29, 2014 at 11:39
0

I recommend you to watch 2013 WWDC session 307 related to CoreLocation.

https://developer.apple.com/wwdc/videos/

They were talking about things that are similar to your task by using deffered updates.

Especially they were covering such things as low-power state.

Short overview:

  • Set activity type to CLActivityTypeFitness
  • Call startUpdatingLocations
  • Use - (void)allowDeferredLocationUpdatesUntilTraveled:(CLLocationDistance)distance timeout:(NSTimeInterval)timeout; method to manage travelled distance. As I understand it simply wakes the phone after specified conditions were met so GPS chip can pass gathered locations directly to CoreLocation and it will notify your application with new locations and you will process and analyze them using some calculations to display how much distance user travelled, etc.
0

Using the accelerometer alone allows merely for educated guesses at best, when it comes to the purpose of navigation.

That's because there's only two ways to interpret the accelerometer data, both of which are flawed:

  • Inertial Navigation
  • Pedometer

Inertial Navigation would allow to track the position in all three spatial dimensions, but the sensors used in todays smartphones are just not accurate enough - the error would become too large after just seconds, making the data useless.

Pedometers, which you are looking for, do precisely one thing: Counting steps. Combining the pace, step count and step length allows to make assumptions about speed and distance. To be able to recognize steps and calculate the pace, you'll use the accelerometer to detect the impacts the phone experiences, as it rests inside the runners pocket. Holding the phone in your hand however prevents detecting those impacts - hence the pedometer has no chance whatsoever to do its job.

The best you can do is to improve overall accuracy, for example by allowing the user to calibrate the pedometer. One way to do this is to let him walk a known distance several times at varying speeds and record the elapsed time and number of steps for each run. These measurements will allow you to calculate the step length and even to make adjustments for different paces - and its just very basic maths.

0

refer to CMMotionManager which is providing the ways to fetch the X,Y and Z co-ordinates while your device is accelerating:

https://developer.apple.com/library/ios/documentation/coremotion/reference/cmmotionmanager_class/Reference/Reference.html

0

The article you link to is no longer available at that URL so it might not be clear to me exactly what you're trying to do. However, if you're looking for step counts like a pedometer would use, you should consider using iOS higher-level API for that.

There's currently (since iOS 8) a CMPedometer class as part of Core Motion. Depending on the version the data available is not just step counting but also distance, pace, and cadence too. The cadence is available since iOS 9 and event update feature is since iOS 10 for example.

Like most of the Core Motion classes, you call startEventUpdates with a handler and your handler gets called with periodic updates of data as it happens. You can also use startUpdates with a start date and look at cumulative past data.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.