WWDC 2015

What's new in Core Motion

Core Moiton API is mostly available in WatchOS2

And the states of watch can track

Apple Watch Accelerometer

Available through CMAccelerometer

Challenges

  • Limited processing time
  • Screen may turn off due to user motion (so no accelerotion data)

Best practices

  • Expect the data only the app is activiate
  • Prepare when the task can be suspended

Use performExpiringActivityWithReason(_:, usingBlock:) when being informed the task is being suspended

Historical Accelerometer

  • collect contiuous data for long durations
  • Can retrieve even the app is not running
  • Using the data for custom data analysis

CMSensorRecorder available in iOS 9

  • init the CMSensorRecorder to start the recording
  • recording at 50Hz
  • data stored up to 3 days

accelerometerDataFrom(_:, to:) -> CMSensorDataList to retrieve the data from a date to a date

Consideration of using

  • as the data set could be very large, the time of running can be long and again use performExpiringActivityWithReason(_:, usingBlock:) to monitor if the task is suspended.
  • consume power

Best practices

  • Record and query minimum duration
  • understand sensor rate requirements
  • Decimate data to reduce processing time ( say if we need past record of user's running, we just retrieve past 1 to 2 hours is more than enough)

Related session : Introducing WatchKit for watchOS 2

Pedometer

Measure

  1. step
  2. distance
  3. floor counting

New in iOS 9

Pace

New property currentPace of CMPedometerData

instantaneous pace in unit of second/meter accompanied with live pedometer updates

Cadence

Wikipedia of Cadence)

Cadence in sports involving running is the total number of 'revolutions per minute' (RPM), or number of full cycles taken within a minute, by the pair of feet, and is used as a measure of athletic performance.

New property cadence of CMPedometerData

Availability in devices

Pressure

Used to measure relative altitude in floor-scale

  • not useful when :
    • Weather changes over long duration (as air pressure changes over time as temp.)
    • Rigid sealed cases

use CMAltimeter of startRelativeAltitudeUpdatesToQueue(_:, withHandler:)

first sample after 2.6s

after than the samples after 1.3s

Using core motion to enhance app experience

considering using core motion to improve UX of the app

say in music app

we detect the user activity and select the pre-defined playlists. Then according to performace of user activities , the app changes the songs for cheering the user up. Finally we consolidate the data and shows these to the user.