Plans how a robotic hand moves across a piano keyboard to play a song.

For each note in a song, a robotic hand could sit in many positions. Some make the next notes easy to reach. Others lead to stretches or long jumps. The program compares these options across the whole song and picks the sequence of hand positions with the least strain and movement.
The dashboard steps through each song note by note. It shows the positions the program considered, the one it chose and why, and plays the music.
A hand covers about one octave, the robot has a top speed, and every note must be reachable when it is played. The best position for one note can make the next few notes hard to reach, so the program plans the whole song at once instead of one note at a time.
Comparing every possible plan directly is not practical. The program uses the Viterbi algorithm, a standard method for finding the lowest-cost path through a sequence of choices. It finds the best plan in under a second.
How this works explains the method without code.
| Section | Shows |
|---|---|
| Song and hardware mode | Choose one of 61 songs. Right-hand-only mode simulates a failed left hand. |
| Path summary | Totals for the chosen plan: distance moved, repositions and awkward reaches. |
| Piano roll | Notes reaching the keyboard in time with the music, with sound. |
| Decision map | Every possible hand position at every note. The orange line is the chosen plan. Click a position to see its costs. |
The songs include six familiar pieces (Hot Cross Buns, Happy Birthday, Twinkle Twinkle Little Star, Mary Had a Little Lamb, the Star-Spangled Banner and Fuyu no Hanashi) and 55 short exercises: scales, leaps, arpeggios and black-key passages.
Requires Python 3.
dashboard folder:
cd ~/Downloads/piano-hand-trellis-main/dashboard
python3 -m http.server 8000
Press Ctrl + C in the terminal to stop the server.
| Path | Contents |
|---|---|
dashboard/ |
The interactive dashboard. |
ALGORITHM.md |
How the program decides, without code. |
findOptimalHandPos.py |
The program. Reads sheet music and plans the hand’s movements. |
inputs/ |
Sheet music for the six main songs. |
outputs/ |
Every song’s notes in the format the program reads. |
output_rh_only/ |
Example results for right-hand-only mode. |
docs/ |
The screenshot and the developer guide. |
See the developer guide for setup, commands, options and how to rebuild the dashboard data.