Skip to the content.

RepMotion

A Swift library for detecting repetitive motion patterns using Apple Watch accelerometer and gyroscope data. Count exercise reps, measure workout intensity, and auto-calibrate detection parameters – all in real time.

Features

Quick Start

Add RepMotion to your Package.swift:

dependencies: [
    .package(url: "https://github.com/thefern/RepMotion.git", from: "0.1.0")
]

Add the libraries you need:

.target(
    name: "YourApp",
    dependencies: [
        "RepMotionCore",
        "RepMotionDetection",
        "RepMotionCapture"
    ]
)

Minimal Example

import Combine
import RepMotionCore
import RepMotionDetection
import RepMotionCapture

let capture = MotionCaptureService(sampleRate: 50)
let detector = RepDetectionService()
var cancellables = Set<AnyCancellable>()
var repCount = 0

capture.samplePublisher
    .sink { detector.processBatch($0) }
    .store(in: &cancellables)

detector.repPublisher
    .sink { event in
        repCount += 1
        print("Rep \(repCount) — confidence: \(event.confidence)")
    }
    .store(in: &cancellables)

capture.start()

That’s it. Ten lines to count reps from live sensor data.

Platform Support

Platform Minimum Version
iOS 17.0
watchOS 10.0
macOS 14.0

Modules

RepMotion ships as three independent libraries so you can import only what you need.

Module Purpose Dependencies
RepMotionCore Data types: MotionSample, RepEvent, RepCalibration, etc. None
RepMotionDetection Detection engine, calibration, power and distance estimation RepMotionCore
RepMotionCapture Live sensor capture via CoreMotion and fixture replay RepMotionCore

Interactive Demo

Try the Signal Explorer – adjust detection parameters with sliders and watch the pipeline process a simulated exercise session in real time. See how alpha, threshold, refractory period, axis, and polarity affect rep detection.

Documentation

License

MIT. See LICENSE.