RSDMotionRecorder

@available(iOS 10.0, *)
public class RSDMotionRecorder : RSDSampleRecorder

RSDMotionRecorder is a subclass of RSDSampleRecorder that implements recording core motion sensor data.

You will need to add the privacy permission for motion sensors to the application Info.plist file. As of this writing (syoung 02/09/2018), the required key is:

  • Privacy - Motion Usage Description

  • Note

    This recorder is only available on iOS devices. CoreMotion is not supported by other platforms.

    Seealso

    RSDMotionRecorderType, RSDMotionRecorderConfiguration, and RSDMotionRecord.

    • The currently-running instance, if any. You should confirm that this is nil (on the main queue) before starting a passive recorder instance.

      Declaration

      Swift

      public static var current: RSDMotionRecorder?
    • The most recent device motion sample. This property is updated on the motion queue. This is an @objc dynamic property so that listeners can be set up using KVO to observe changes to this property.

      Declaration

      Swift

      @objc
      dynamic public private(set) var currentDeviceMotion: CMDeviceMotion? {
        get
        }
    • The most recent accelerometer data sample. This property is updated on the motion queue. This is an @objc dynamic property so that listeners can be set up using KVO to observe changes to this property.

      Declaration

      Swift

      @objc
      dynamic public private(set) var currentAccelerometerData: CMAccelerometerData? {
        get
        }
    • The most recent gyro data sample. This property is updated on the motion queue. This is an @objc dynamic property so that listeners can be set up using KVO to observe changes to this property.

      Declaration

      Swift

      @objc
      dynamic public private(set) var currentGyroData: CMGyroData? {
        get
        }
    • The most recent magnetometer data sample. This property is updated on the motion queue. This is an @objc dynamic property so that listeners can be set up using KVO to observe changes to this property.

      Declaration

      Swift

      @objc
      dynamic public private(set) var currentMagnetometerData: CMMagnetometerData? {
        get
        }
    • The motion sensor configuration for this recorder.

      Declaration

      Swift

      public var motionConfiguration: RSDMotionRecorderConfiguration? { get }
    • The recorder types to use for this recording. This will be set to the recorderTypes from the coreMotionConfiguration. If that value is nil, then the defaults are [.accelerometer, .gyro] because all other non-compass measurements can be calculated from the accelerometer and gyro.

      Declaration

      Swift

      lazy public var recorderTypes: Set<RSDMotionRecorderType> { get set }
    • The sampling frequency of the motion sensors. This will be set to the frequency from the coreMotionConfiguration. If that value is nil, then the default sampling rate is 100 samples per second.

      Declaration

      Swift

      lazy public var frequency: Double { get set }
    • For best results, only use a single motion manager to handle all motion sensor data.

      Declaration

      Swift

      public private(set) var motionManager: CMMotionManager? {
        get
        }
    • Override to implement requesting permission to access the participant’s motion sensors.

      Declaration

      Swift

      override public func requestPermissions(on viewController: UIViewController, _ completion: @escaping RSDAsyncActionCompletionHandler)
    • Override to start the motion sensor updates.

      Declaration

      Swift

      override public func startRecorder(_ completion: @escaping ((RSDAsyncActionStatus, Error?) -> Void))
    • Override to stop updating the motion sensors.

      Declaration

      Swift

      override public func stopRecorder(_ completion: @escaping ((RSDAsyncActionStatus) -> Void))
    • Returns the string encoding format to use for this file. Default is nil. If this is nil then the file will be formatted using JSON encoding.

      Declaration

      Swift

      override public func stringEncodingFormat() -> RSDStringSeparatedEncodingFormat?