AI-powered basketball coaching system with gimbal tracking, computer vision shot analysis, and real-time feedback.
Built by Rishith Chennupati
CoachBuddy is an open-source basketball training system that uses a phone mounted on an Arduino-controlled gimbal to track a player's movements, analyze shooting form using computer vision, and provide real-time coaching feedback through an iOS app.
- Mount your phone on the gimbal stand at the court
- Track — The gimbal follows your movement using servo motors and position detection
- Analyze — Python CV pipeline detects shot attempts, tracks body pose, and analyzes form
- Feedback — The iOS app shows real-time metrics, shot accuracy, and coaching suggestions
┌─────────────────┐ WiFi/BLE ┌──────────────────┐
│ iOS App │◄────────────────►│ Arduino Gimbal │
│ (SwiftUI) │ │ (Servo Control) │
│ │ └──────────────────┘
│ - Live View │ │
│ - Shot Metrics │ Mounted Phone
│ - Form Score │ Camera Feed
│ - History │ │
└────────┬─────────┘ ▼
│ ┌──────────────────┐
│ WebSocket │ Python CV Server │
└──────────────────────────►│ │
│ - MediaPipe Pose│
│ - Shot Detection│
│ - Form Analysis │
│ - Angle Scoring │
└──────────────────┘
Arduino-powered 2-axis gimbal that tracks the player and keeps the camera centered. Uses servo motors controlled via PCA9685 with smooth PID-based tracking.
Python pipeline using MediaPipe Pose for real-time body tracking. Analyzes shooting form by measuring joint angles at key phases: set point, release, and follow-through. Detects shot attempts and tracks ball trajectory.
SwiftUI app that displays the live camera feed, overlays shot metrics, provides coaching feedback, and tracks training history over time.
| Component | Purpose | Est. Cost |
|---|---|---|
| Arduino Uno R4 WiFi | Gimbal controller | ~$30 |
| PCA9685 PWM Driver | Servo control | ~$8 |
| 2x MG996R Servos | Pan/tilt gimbal | ~$20 |
| Phone mount bracket | Camera mounting | ~$10 |
| 6V 5A Power Supply | Servo power | ~$12 |
| 3D-printed gimbal frame | Structure | ~$8 |
Total: ~$88
pip install -r requirements.txt- Xcode 16+
- iOS 18+
- Swift 6
- Arduino IDE
- Libraries: WiFiS3, Adafruit_PWMServoDriver, Wire
# Open firmware/gimbal-controller/gimbal-controller.ino in Arduino IDE
# Create credentials.h with your WiFi SSID/password
# Upload to Arduinocd cv
python server.py --port 8765open ios-app/CoachBuddy.xcodeproj
# Build and run on your iPhone
# Enter the CV server IP address in Settings| Metric | What It Measures |
|---|---|
| Elbow Angle | Alignment at set point (ideal: 85-95°) |
| Release Angle | Wrist angle at ball release (ideal: 45-55°) |
| Follow-Through | Arm extension after release (ideal: >160°) |
| Knee Bend | Lower body engagement (ideal: 100-120°) |
| Balance Score | Shoulder-hip alignment during shot |
| Arc Consistency | Shot trajectory repeatability |
CoachBuddy/
├── firmware/
│ ├── gimbal-controller/ # Arduino gimbal control + PID tracking
│ └── sensor-hub/ # IMU sensor data collection
├── cv/
│ ├── server.py # WebSocket CV server
│ ├── analysis/
│ │ ├── shot_detector.py # Detect shot attempts from pose data
│ │ ├── form_analyzer.py # Score shooting form angles
│ │ └── trajectory.py # Ball trajectory tracking
│ ├── models/
│ │ └── shot_classifier.py # ML shot type classification
│ └── utils/
│ ├── pose.py # MediaPipe pose utilities
│ ├── angles.py # Joint angle calculations
│ └── drawing.py # Visualization overlays
├── ios-app/
│ └── CoachBuddy/
│ ├── Views/ # SwiftUI views
│ ├── ViewModels/ # MVVM view models
│ ├── Models/ # Data models
│ ├── Services/ # WebSocket, networking
│ └── Components/ # Reusable UI components
├── tests/
│ └── cv/ # Python CV tests
├── docs/ # Documentation
└── scripts/ # Utility scripts
MIT License — see LICENSE
Built with MediaPipe, OpenCV, Arduino, and SwiftUI. Inspired by wanting to make basketball coaching accessible to everyone.