Skip to content

feat: add bilateral left/right arm tracking for bicep curls#526

Open
Shikhar-404exe wants to merge 16 commits into
Somil450:mainfrom
Shikhar-404exe:feat/bicep-curl-left-right
Open

feat: add bilateral left/right arm tracking for bicep curls#526
Shikhar-404exe wants to merge 16 commits into
Somil450:mainfrom
Shikhar-404exe:feat/bicep-curl-left-right

Conversation

@Shikhar-404exe

Copy link
Copy Markdown
Contributor

Summary #43

Adds independent left and right arm tracking for bicep curls. Previously the engine picked the "best visible side" and tracked only that arm. Now both arms are tracked independently — each arm counts reps when it completes a full curl cycle, and total reps = left + right.

Changes

Angle Computation (3 files)

  • angleUtils.ts — Compute elbowLeft, elbowRight, shoulderLeft, shoulderRight from MediaPipe landmarks
  • poseWorker.ts — Same bilateral angles in the web worker
  • gpuAngleUtils.ts — Expand WGSL shader from 9→11 floats, add GPU-side elbowLeft/elbowRight

Config

  • exercises.ts — Add bilateral?: boolean and bilateralJoints?: { left, right } to ExerciseConfig. Set bilateral: true on bicepCurl.

Engine

  • exerciseEngine.ts — Core change:
    • EngineState gains 10 new optional fields: leftHistory, rightHistory, leftStage, rightStage, leftDownAngleReached, rightDownAngleReached, leftStageStartTime, rightStageStartTime, leftRepCount, rightRepCount
    • process() detects config.bilateral and runs two independent state machines (one per arm)
    • Each arm transitions up→down→up with its own smoothed angle, history buffer, cooldown, and down-duration tracking
    • reps = leftRepCount + rightRepCount
    • Undefined stages auto-initialize from current angle after calibration
    • Fix: removed duplicate properties in the return object (pre-existing)

Feedback

  • feedbackEngine.ts — BicepCurl rules check leftStage/rightStage and shoulderLeft/shoulderRight instead of single-side only

Tests (3 new)

Test Validates
Left-arm-only rep Left arm completes curl while right stays extended; only leftRepCount increments
Bilateral simultaneous reps Both arms complete curl in same frame; reps = 2
Fresh initialization leftStage/rightStage initialize from angle when undefined

Verification

  • 161/161 tests pass (12 test files)

Files Changed

src/config/exercises.ts                      
src/engine/feedbackEngine.ts                 
src/services/__tests__/exerciseEngine.test.ts 
src/services/angleUtils.ts                   
src/services/exerciseEngine.ts                
src/services/gpuAngleUtils.ts                
src/workers/poseWorker.ts                     

- Compute elbowLeft/elbowRight and shoulderLeft/shoulderRight angles in
  angleUtils, poseWorker, and GPU shader (WGSL)
- Add bilateral config flag to ExerciseConfig and bicepCurl definition
- Track independent stage machines per arm in ExerciseEngine with
  separate history, downAngleReached, cooldown, and rep counting
- Auto-initialize per-arm stages from current angle when undefined
- Update feedbackEngine bicepCurl rules to check both arms
- Add 3 tests: left-arm-only rep, bilateral simultaneous reps,
  fresh initialization from scratch
- Fix duplicate return properties in exerciseEngine (pre-existing)
@vercel

vercel Bot commented May 28, 2026

Copy link
Copy Markdown

@Shikhar-404exe is attempting to deploy a commit to the somiljain2024-4175's projects Team on Vercel.

A member of the Team first needs to authorize it.

- Replay3DModel.tsx: restore from c746efc to fix parse error caused by
  unmerged stress vector shader (PR Somil450#455) that re-broke types and shaders
- WorkoutScreen.tsx: move useWorkoutWebSocket() from callback to component
  body (react-hooks/rules-of-hooks), add missing CameraErrorBoundary import

Reduces CI lint errors from 3 to 0 (64 warnings remain, all pre-existing).
@Somil450

Copy link
Copy Markdown
Owner

@Shikhar-404exe Thank you for the contribution.

This introduces a significant change to the rep-counting logic by moving from single-arm tracking to independent left/right arm tracking. Before I proceed further, could you please provide a short demo video showing:

  • Left-arm-only curls counting correctly
  • Right-arm-only curls counting correctly
  • Simultaneous bilateral curls counting as two reps
  • Existing bicep curl functionality continuing to work as expected

Also, please resolve the current merge conflicts with the latest main branch so the changes can be reviewed and tested properly.

@Somil450 Somil450 self-requested a review May 29, 2026 11:58
@Somil450 Somil450 added gssoc-26 Marks GSSoC issues gssoc:approved Officially reviewed and approved GSSoC contribution ready for scoring mentor:Somil450 Reviewed and mentored by Somil450 for GSSoC contribution tracking. level:intermediate Moderate complexity requiring good understanding of project structure and implementation. type:feature Adds a new feature or functionality to the project. labels May 29, 2026
…tion, and layout

- Add per-arm last-rep-time cooldowns so each arm counts independently
- Fix totalReps increment (2 when both arms rep same frame)
- Add per-arm rep display in real-time floating panel and summary
- Remove combined rep count for bilateral exercises
- Disable STOP gesture for bilateral (curling arms looks like crossed arms)
- Fix duration showing 00:00 by computing from ref instead of state
- Camera: reuse stream across screens, fix play race condition
- Layout: z-index fixes, flex wrapper, soft camera stop
Resolved conflicts in:
- Replay3DModel.tsx (accepted upstream version)
- WelcomeScreen.tsx (merged data-theme + structure)
- WorkoutScreen.tsx (merged imports, states, error handling)
- exerciseEngine.ts (merged bilateral tracking + plank spline)
…orkoutScreen, exerciseEngine, workoutSyncService
@Shikhar-404exe

Shikhar-404exe commented May 29, 2026

Copy link
Copy Markdown
Contributor Author

@Shikhar-404exe

Copy link
Copy Markdown
Contributor Author

any update on when this'll be merged ? i have linked the demo video of running this feature locally in my earlier comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc:approved Officially reviewed and approved GSSoC contribution ready for scoring gssoc-26 Marks GSSoC issues level:intermediate Moderate complexity requiring good understanding of project structure and implementation. mentor:Somil450 Reviewed and mentored by Somil450 for GSSoC contribution tracking. type:feature Adds a new feature or functionality to the project.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants