// 01 The Problem: Why Gym Logging Fails
Traditional gym tracker apps fail at the most critical moment: in the middle of a heavy squat set. When an athlete holds dumbbells or has a barbell across their traps, their hands are occupied, sweaty, and calloused. Having to manually tap an iPhone or Android screen after every single rep or set destroys workout rhythm and focus.
The Objective: Create an intelligent mobile tracker that detects squats autonomously whether the smartphone is held in the user's hand or resting inside their shorts pocket, and automatically detects when a set is finished to trigger the rest countdown timer.
The app must require zero user touches during the workout. The lifter taps "Start Session", slips the phone into their pocket, completes 4 sets of squats, and the app logs every rep, set transition, and rest duration automatically.
// 02 The Sensor Pipeline & Signal Processing
Mobile accelerometers report raw 3-axis values: (ax, ay, az) sampled at roughly 50Hz (every 20ms). These raw values are plagued by high-frequency muscle vibrations, gravity vectors, and phone rotation.
Step 1: Orientation-Invariant Vector Magnitude
Because a phone can rotate or sit at any random angle in a pocket, analyzing a single axis (e.g. ay) leads to fatal errors. Instead, KineSquat calculates the continuous Euclidean magnitude:
• At rest: a_mag ≈ 9.81 m/s² (1g earth gravity baseline).
• Eccentric Descent: a_mag drops below 1g (freefall acceleration component: ~6.8 – 8.2 m/s²).
• Bottom Turnaround: decelerative inflection point.
• Concentric Ascent: a_mag spikes upward (thrust component: ~11.5 – 13.8 m/s²).
Step 2: Low-Pass Smoothing & Morphological Validation
Raw sensor noise can easily trigger multiple threshold crossings within milliseconds. To prevent jitter:
- Exponential Moving Average (EMA):
s(t) = α · a_mag(t) + (1 - α) · s(t-1)withα = 0.22to smooth high-frequency spikes without introducing perceptual phase lag. - Kinematic Time Window: A human squat cannot realistically occur in under 0.8 seconds (which indicates a jump or bump) and rarely exceeds 3.5 seconds. Rejections discard any anomalies outside this window.
- Valley-to-Peak Detection: A rep is registered only if a verified valley (< 8.0 m/s²) is followed by a verified peak (> 11.8 m/s²) within 400ms–1800ms.
// 03 The Autonomous Break-Detection State Machine
How do you know when a set is finished without the lifter pressing a button?
KineSquat implements a finite state machine that observes variance and cadence over a rolling temporal buffer. When an athlete finishes their 10th rep and racks the bar or stands still, the acceleration magnitude variance collapses back to baseline:
When 10 seconds elapse with zero rep valleys and low sensor variance, the system formally commits the set to local storage and initiates an audio chime and haptic feedback countdown for the rest interval.
// 04 Architectural Decisions: Why Provider over GetX?
While I used GetX at HelloStores for rapid reactive views, for KineSquat I explicitly chose Provider. Here is the technical breakdown:
Strict separation between UI widgets and reactive business logic via ChangeNotifier. Sensor event streams are cleanly tied to widget lifecycle disposal, preventing memory leaks when navigating away.
GetX's global locator pattern makes testing sensor mock streams difficult because state can persist outside the widget tree. Provider makes the sensor dependency explicitly injectable.
// 05 What Failed, and How It Was Resolved
Initial builds assumed the phone would sit upright in a pocket and tracked the Y-axis. The moment the user squatted, the femur tilted horizontally, turning the Y-axis perpendicular to gravity and causing 100% false negatives.
Resolution: Switched to orientation-invariant 3D magnitude √(x² + y² + z²) which is completely agnostic to phone orientation.
Walking between sets triggered false reps under aggressive thresholds.
Resolution: Cross-referenced the hardware pedometer stream. If pedometer step cadence is detected, rep counter transitions into a suspended walk state and prevents false incrementation.
// 06 Results, Features & Future Work
- Accuracy: Achieved >94% rep detection accuracy across front-pocket and handheld configurations in real testing.
- Features: Squat variation guide, weighted squat input for progressive overload, pedometer step counter, CSV session export.
- Future Work: Integrate Google ML Kit / TensorFlow Lite pose landmark tracking for camera-based depth angle validation (assessing whether hip crease breaks parallel).