Skip to content

MuhammadSeyam/MimicArm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

15 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

MimicArm 🦾

Real-time prosthetic robotic hand controlled by live camera hand tracking.

Move your hand in front of a webcam β€” the robotic hand mirrors it instantly. No buttons. No keyboard. No manual input. Just your hand.


Demo

πŸ“Ή assets/demo.mp4

System Preview

⚠️ This image shows the prosthetic hand model. Real-time motion is demonstrated in the attached video.


How It Works

Webcam  β†’  MediaPipe Hand Tracking  β†’  Python  β†’  Serial (USB)  β†’  Arduino  β†’  5 Servo Motors
  1. A webcam captures your hand at ~30 FPS
  2. MediaPipe detects 21 hand landmarks per frame
  3. Python compares each fingertip position vs its knuckle joint to determine open/closed state
  4. A 5-value array [Thumb, Index, Middle, Ring, Pinky] is built β€” 1 = open, 0 = closed
  5. The array is sent over serial only when state changes β€” no spam, no lag
  6. Arduino receives the values, maps each to a servo pin, and smoothly sweeps to the target angle

Features

  • πŸŽ₯ Fully camera-driven β€” zero manual input
  • ⚑ Low-latency real-time tracking (~30 FPS)
  • πŸ”„ State-change gating β€” serial only fires on actual changes
  • πŸ€– Smooth servo motion β€” non-blocking 4Β°/tick sweep
  • πŸ›‘οΈ Arduino buffer overflow protection β€” frame validation before parsing
  • πŸ–οΈ Left/right hand awareness β€” correct thumb detection for both
  • πŸ–₯️ Live HUD overlay β€” finger states + FPS + serial status
  • πŸ–¨οΈ Full printable 3D model included (forearm, hand, wrist)

Hardware Requirements

Component Details
Arduino Uno or Mega
Servo motors 5Γ— standard hobby servo (e.g. SG90 or MG996R)
Webcam Any USB webcam (720p or higher recommended)
USB cable Arduino to PC
Power supply Separate 5V for servos (don't power from Arduino 5V pin)
3D printed parts See 3d_model/

Servo Pin Mapping

Finger Arduino Pin
Thumb 3
Index 5
Middle 6
Ring 9
Pinky 10

Software Requirements

Python 3.8+

Install dependencies:

pip install -r requirements.txt

Contents of requirements.txt:

opencv-python
mediapipe
pyserial
cvzone

Arduino IDE 1.8+ or Arduino IDE 2.x

Library required: Servo (built-in, no install needed)


Getting Started

1. Flash the Arduino

  1. Open arduino/prosthetic_hand_controller.ino in Arduino IDE
  2. Select your board (Tools β†’ Board β†’ Arduino Uno/Mega)
  3. Select your port (Tools β†’ Port β†’ COMx on Windows, /dev/ttyUSBx on Linux/Mac)
  4. Click Upload

2. Configure the Python script

Open python/real_time_hand_tracking.py and set your serial port at the top:

SERIAL_PORT = "COM3"   # Windows example
# SERIAL_PORT = "/dev/ttyUSB0"   # Linux/Mac example

The script will also attempt to auto-detect your Arduino by its USB descriptor β€” so this is only needed as a fallback.

3. Run

python python/real_time_hand_tracking.py

A window will open showing your webcam feed with a live HUD. Move your hand β€” the robotic hand will mirror it in real time.

Press Q to quit. All fingers will close safely on exit.


Serial Protocol

Python sends a single line over serial whenever finger state changes:

T,I,M,R,P\n

Example:

1,1,0,0,1
Value Meaning Servo angle
1 Finger open 0Β°
0 Finger closed 180Β°

Baud rate: 115200


3D Model

All printable parts are in 3d_model/prosthetic_hand/ organized into three subfolders.

forearm/

File Part
RobCableBackV3.stl Forearm cable channel β€” rear
RobCableFrontV3.stl Forearm cable channel β€” front
RobRingV3.stl Forearm ring guide
RobServoBedV6.stl Servo mounting bed (holds all 5 servos)
servo-pulleyX5.stl Servo pulley Γ— 5
TensionerRightV1.stl Cable tensioner

hand/

File Part
thumb5.stl Thumb finger
Index3.stl Index finger
Majeure3.stl Middle finger
ringfinger3.stl Ring finger
Auriculaire3.stl Pinky finger
robpart2V4.stl – robpart5V4.stl Palm assembly parts
robcap3V2.stl Palm cap
topsurfaceUP6.stl Top surface plate
WristlargeV4.stl Wrist connector β€” large
WristsmallV4.stl Wrist connector β€” small

wrist/

File Part
CableHolderWristV5.stl Wrist cable holder
RotaWrist1V4.stl Rotating wrist joint β€” part 1
RotaWrist2V3.stl Rotating wrist joint β€” part 2

Recommended Print Settings

Setting Value
Material PLA or PETG
Layer height 0.2 mm
Infill 30–40%
Supports Required for finger parts
Perimeters 3+ for structural parts

Project Structure

MimicArm/
β”‚
β”œβ”€β”€ README.md
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ LICENSE
β”‚
β”œβ”€β”€ arduino/
β”‚   └── prosthetic_hand_controller.ino   # Arduino servo controller
β”‚
β”œβ”€β”€ python/
β”‚   └── real_time_hand_tracking.py       # CV hand tracking + serial
β”‚
β”œβ”€β”€ 3d_model/
β”‚   └── prosthetic_hand/
β”‚       β”œβ”€β”€ forearm/                     # Servo bed, cable channels, pulleys
β”‚       β”œβ”€β”€ hand/                        # Fingers, palm, wrist connectors
β”‚       └── wrist/                       # Rotating wrist joint
β”‚
└── assets/
    β”œβ”€β”€ images/
    └── demo.mp4

Troubleshooting

Servos move in the wrong direction

Each servo's ANGLE_OPEN / ANGLE_CLOSED can be inverted per-finger in the Arduino file. Find the INVERT array at the top and set true for any finger that moves backwards:

const bool INVERT[5] = {false, false, false, false, false};
//                       Thumb  Index  Mid   Ring  Pinky

Serial port not found

  • Windows: Check Device Manager β†’ Ports (COMx)
  • Linux/Mac: Run ls /dev/tty* before and after plugging in Arduino
  • Make sure no other program (e.g. Arduino IDE Serial Monitor) has the port open

Hand not detected

  • Ensure good lighting β€” MediaPipe struggles in dark or backlit conditions
  • Keep your hand fully within the camera frame
  • Try adjusting min_detection_confidence in the Python script (default: 0.75)

Lag or frame drops

  • Close other applications using the webcam
  • Reduce FRAME_W / FRAME_H in the Python script to 640, 480
  • Ensure Arduino is on a direct USB port, not a hub

License

This project is licensed under the terms in LICENSE.


Acknowledgements

About

A computer vision-based system that detects hand gestures using a webcam and controls a 3D-printed prosthetic hand via Arduino and servo motors for real-time human-robot interaction.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors