CoreMotionStandardActivityInterpreter

open class CoreMotionStandardActivityInterpreter: CoreMotionActivityInterpreter

Standard implementation of a core motion activity preprocessor and interpreter.

See preprocess(activities:) and interpret(activities:) for details on the logic performed.

  • Preprocesses raw motion activities before they are dumped to SQLite. See the Motion Tracking talk from WWDC14 for a detailed look at how this stuff works: https://developer.apple.com/videos/play/wwdc2014/612/

    1. all unknown activities are discarded
    2. adjacent activities with same type(s), ignoring their confidence, are joined together and the highest confidence is retained; this means that activities that had unknown activities interspersed are joined together and also span the time of the unknown period
    3. adjacent automotive activities are joined even if they have additional types (typically stationary); highest confidence is retained and their types are union-ed

    Declaration

    Swift

    open func preprocess(activities: [CMMotionActivity]) -> [CoreMotionActivity]

    Parameters

    activities

    The activities to preprocess

    Return Value

    Preprocessed and packaged motion activities

  • Our implementation of the core motion activity interpreter. It runs these interpretation rules:

    • automotive < 5 minutes: stationary
    • cycling < 2 minutes: running if prev/next is running, walking if prev/next is walking, stationary otherwise
    • walking < 1 minute, stationary prev and next, low confidence: stationary
    • stationary > 3 hours: sleeping
    • IDEA: stationary < 1 minute, running or walking before and after: standing

    Declaration

    Swift

    open func interpret(activities: [InterpretedCoreMotionActivity]) -> [InterpretedCoreMotionActivity]

    Parameters

    activities

    The activities to interpret

    Return Value

    An array of interpreted activities