Introduction: Mobile Robotics With Scratch: Build an Arduino-based Insect-like Walker and Program It With Scratch
Let's scurry around? This is an Arduino-based, easy to build version of the insect-like walker made with coat-hanger wire and originally designed by Jerome Demers (see also this instructable) and Gareth Branwyn. It comes in two versions:
- a standalone, Arduino-only version, powered by a common old-fashioned Arduino sketch, and
- a remote-controlled version, dynamically programmed using the MIT-developed Scratch visual programming language.
We developed it for people who have found this popular robot design cute but would like to build it without having to solder an analog bi-core circuit.
It was called Kleerhangerbeest, which is Dutch for "coat-hanger animal", in honor of the Strandbeests, wind-driven beach robots of the Dutch maker Theo Jansen. The Scratch-based version was further developed to allow even preteen kids to program it effortlessly. It has the additional advantage that, by controlling the robot using the Scratch visual programming environment on a PC or Raspberry Pi, it is possible to develop multi-threaded Arduino programming and to change the program on the run, without the need to recompile and reload a firmware-based program. This simple-to-build approach, together with the Scratch-based programming, makes it especially interesting for teaching robotics to kids, allowing kids to dynamically experiment with different gait modes and explore robot behavior using an easy to programming tool that allows to see the results of a program change immediately.
We redesigned the traditional coat-hanger walker as a still very simple bi-motor walker robot that employs an Arduino and two hobby servos. It provides a much more controllable gait than the original bi-core-based model, but is almost as inexpensive and much easier to build. This project is structurally very similar to Phillip Torrone's Servo-based 4-legged Walker.
How can a four-legged robot with two rigid sets of legs rotating against each other walk?
The graphic above illustrates the movement principle of four-legged walkers with two rigid leg sets. It does not seem to be a very intuitive solution, but, in fact, it is a very simple mechanism. It's not necessarily the most efficient, since some leg dragging will occur, but it works surprisingly well for its simplicity. The idea is that, when in movement, the robot has always three legs on the ground and one raised. The ground-touching contra-lateral front/hind leg pair will give traction in the desired direction, whereas the third ground-touching leg will be dragged along, performing a movement against the motion direction of the robot. Since the robot's weight should be distributed mainly on the two traction legs, the drag won't be so much as to impede forward motion.
Robot designs can be made to have either one of the front or one of the hind legs being raised on each motion cycle. To achieve this, the axes of the leg sets have to be at an angle of approximately 25-30º. The effect is also easier to achieve if both leg sets are of different sizes. We started with a variant of Jerome Demers' design (short wire: 14 cm, long wire: 21 cm) and bent the wires until we achieved the desired effect.
This simple leg design has a huge advantage over articulated leg designs like that of the strandbeests of Theo Jansen, were there are only few very precise angle and size relationships between leg parts that work well. Deviate from these, and the leg will be unusable. With rotating rigid leg sets, there are lots of different designs that work and you can be creative and don't have to keep angles and sizes within precise boundaries. During our design and test phase, we determined experimentally that it is better if you don't start moving both leg pairs simultaneously, but start with the front legs first. With previous designs employing only one analog bi-core circuit this wasn't possible. Using an Arduino and two servos, it is very simple to achieve. Our Processing and Scratch codes given below reflect this design decision. An interesting animation of this gait can be seen in Andrew Miller's 2-Motor Walker Tutorial.
Level: Intermediate. You should know something about:
- Scratch/Arduino communication using s2a_fm (see tutorials below)
- Using Bluetooth on Linux
Preconditions: Intermediate knowledge about Scratch and Arduino interaction via Bluetooth. Read the following Tutorials to know how to integrate Scratch, Arduino and Bluetooth:
- How to Install the Scratch/Arduino Communication
- How to Configure your Bluetooth Module for the Communication between Scratch and Arduino
- Mobile Robotics with Scratch: Preparing your Linux PC, Arduino and Scratch to communicate wireless via Bluetooth
- Metal building toy with big screws. We used vintage Meccano parts from eBay, but there are many different options available, such as Modelix.
- 2 Small MDF plates (rigid plastic from an old box will also do)
- 12 nylon cable ties (15cm) for the fixation of the components on the structure
- Coat hanger wire
- Hot glue for the "feet"
- Arduino Uno or Freaduino. We have built our Animal with a Freaduino. But it would also be no problem to use another Arduino-compatible board such as an Uno or a Nano, for example.
- Protoboard: The Freaduino does not need any protoboard for this project.If you are using an Arduino Uno, you'll need a ProtoShield with a 128-hole protoboard installed (Sparkfun sells a complete kit, but you'll find kits also on eBay and DX). If you're using an Arduino Nano, you'll need a Protoboard with 400 holes (look here to see how to position the Nano on the board).
- 2 small hobby servos (TowerPro SG90 is sufficient)
- HC-05 or HC-06 Bluetoth module (the simpler, the better - look at our tutorials on Scratch and Bluetooth).
- Wires for prototyping
- 9V Battery and battery clip.
You'll need a Scratch version that has extensible blocks and that implements the new Scratch HTTP communication standard in order to communicate with s2a_fm and the Arduino. The following Scratch versions/dialects will do:
- Berkeley SNAP! - http:/snap.berkeley.edu
- MIT Scratch 2.0 Offline Editor
- MIT Scratch 2.0 Online (on the PC only)
We suggest that you work on Linux. The automation and communication parts are much easier on this platform. If you want to use MIT Scratch 2.0 Offline and are experiencing difficulties in installing it, look at our Tutorial: How to Install MIT Scratch 2 Offline Editor on Linux.
Step-by-step guide on how to build the robot walker:
Meet the Computing at School Initiative
As part of our Computing at School (http://www.computacaonaescola.ufsc.br) initiative, we run family workshops either as part of school programs or independently (see the last of the images above). The workshops are aimed at children (6-14 years) accompanied by a parent (or any kind of adult family member or friend). During the workshop participants learn how to implement a little project in Scratch. We choose projects where learning how to program involves simple motion and looks commands as well as events, conditionals, and loops using also sensing commands and operators. While teaching to program, we also present basic computing concepts such as an understanding of algorithmic problem-solving (problem statement, implementation and testing cycle), collaboration in form of pair programming as well as the understanding that a computer program is a set of step-by-step instructions to be acted out.
We also develop instructional units for teaching computing school programs. Currently we are developing an interdisciplinary Scratch game programming 12-hours unit for elementary schools and a 24-hours unit on physical computing with SCRATCH and a low-budget Arduino kit for middle schools.
C. Gresse von Wangenheim, A. von Wangenheim. Teaching Game Programming in Family Workshops. IEEE Computer Magazine, 47(8), August 2014. Also available at [ResearchGate].
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.