In this post, I want to share about "Kakashi: The Copycat Robot"—a fun side project I built a few years ago. The name is inspired by the famous character from Naruto, Kakashi Hatake, also known as the Copycat Ninja.
The goal of this robot was to mimic Kakashi's ability to copy movements—though, of course, in a more limited way. Check it out for yourself!
Here are the things I used to build this:
- Aurdino UNO board.
- Max7219 8x8 LED
- 3D printed Pan and Tilt brackets (2x)
- 4 servo motors
- Bread board and jumper wires.
- The Sharinghan
- Pan and Tilt motion
- Controller - Serial bus
- Tracking algorithm
The Sharinghan
- VCC - connect to 5V
- GND - connect to ground
- DIN - data in ports.h
- CS - chip select ports.h
- CLK - clock ports.h
Pan and Tilt
Controller - Serial Bus
Tracking Algorithm
In this section, I'll explain how I mapped my real-world movements to control the robot's actions. There were three main requirements:
Hand Tracking: The system needed to track my hand movements and map them to four angles, corresponding to the servo motors in the pan and tilt setup.
Scale Invariance: It had to be scale-invariant, meaning I could start from any position and move freely, with the robot replicating the same actions regardless of where I started.
Smooth Movements: The movements had to be smooth, taking into account the bandwidth limitations of the serial bus and the movement speed of the servo motors while being fault tolerant.
Once I have the hand landmarks, I extract three key pieces of information from each hand:
- Center of the Hand (landmark 0)
- Palm Height (difference between landmarks 5 and 0) — used to scale the coordinates.
- Average Position of Finger Tips (landmarks 4, 8, 12, 16, 20) — since not all fingers might always be visible.
A servo motor can move between 0 and 180 degrees. I set the motors to point forward at 0 degrees, and whenever the program starts, the motors reset to this position. The tracking data from the first frame (td₀) serves as the reference point.
For each subsequent frame, we calculate the distance along the x and y axes relative to the reference frame. This distance is scaled based on palm height to maintain scale invariance. After scaling, the distance is normalized between 0 and 1, with a range of -3 to +3, and then converted into a corresponding angle between 0 and 180 degrees.
Here is the code that does this:
No comments:
Post a Comment