Marty the Poser - (Scratch)
This ScratchX program allows Marty to be dynamically posed.
Servos can be individually adjusted using the variable sliders or by mousing over the arrow buttons.
Poses can be stored in numbered slots (i.e. like keyframes) and played back interactively.
This will allow you to experiment with positions and sequences for dances / walk cycles etc.
WARNING - posing Marty dynamically can cause unexpected falling over (part of the fun)- so be careful and don't pose Marty near any cliff edges!
- "space" - resets Marty
- q - store current pose in pose 01
- w - store current pose in pose 02
- e - store current pose in pose 03
- r - store current pose in pose 04
- t - store current pose in pose 05
- y - store current pose in pose 06
- u - store current pose in pose 07
- 1 - playback pose 01
- 2 - playback pose 02
- 3 - playback pose 03
- 4 - playback pose 04
- 5 - playback pose 05
- 6 - playback pose 06
- 7 - playback pose 07
- 0 - interrupt playback and zero all servos
- i - invert current pose (limbs only, servo rotations will be inverted e.g. 40 to -40)
- m - mirror current pose (limbs only, servo rotations will be swapped left / right across Marty - e.g. left arm swapped with right arm)
- k - invert and mirror current pose
For best performance run this in Turbo Mode (select from the "Edit" drop down in the ScratchX menu).
I've also found it useful to use full screen for the stage when running the program. Enable / disable full screen by clicking on the blue box icon at the top left of the scratch stage. (this makes dragging sliders easier and reduces the risk of inadvertently dragging sprites / variables around)
Marty will flash and beep if (s)he detects sudden acceleration.
The code is commented which hopefully will help explain what is going on.
The Marty sprite deals with updating the servos and other Marty stuff.
The Gobo sprite deals with manipulating the pose data (there is lots of repetition because Scratch requires that lists (arrays) are addressed explicitly i.e. consequently lots of duplicated code for the pose01 - pose07 lists
The Arrow sprites are for mouse-over fine control of the servo positions.
The poses sprite is simply used for defining preset poses.
This alternative version of the ScratchX program stores all of the pose data in one long list and uses an index to jump to the right place in the list.
The alternative code is more maintainable and compact but perhaps more tricky to understand. (The original version with poses in different lists is more accessible as a teaching example).
Generating a simple walk cycle from a preset pose -
When the program starts it sets up a predefined pose in slot 1. (accessed by pressing 1).
This pose has Marty's weight on the right leg with hips slightly spread and legs twisted.
By manipulating this pose we can make Marty walk.
- 1) press m
- 2) press k
- 3) press m
- 4) press k
(to mirror the preset pose - which should cause Marty's left leg to slide forwards)
(to invert & mirror the current pose - which should cause Marty's weight to shift to the left)
(to mirror the current pose - which should cause Marty's right leg to slide forwards)
(to invert & mirror the current pose - which should cause Marty's weight to shift back to the right)
This completes a cycle and Marty is now back in the initial preset pose.
If your Marty is correctly calibrated and behaving(!) (s)he should have stepped forward twice on a path curving to the left.
Note that because this walk cycle relies on sliding Marty's feet without lifting them, the exact behaviour of your Marty will depend on how much friction there is between Marty's feet and the floor. In the video my desk is just slippy enough!