HackSpace magazine

Build Your First Walking Robot

By Jenny List. Posted

We take for granted the ability of mammals and other creatures to walk. It’s something that our young minds learn in infancy without understanding what a complex task we have mastered. We are blessed with some of the most intricate and capable actuators imaginable in the form of our arms and legs, but to master them takes a huge array of skills and sensory inputs that we process subconsciously. To try to replicate walking motion in a robot is hard, so it’s little wonder that the majority of mobile robots employ wheels or tracks.

As humans, we are one of relatively few species that walk upright, on two legs. We are inherently unstable and prone to falling over, so our brains monitor our balance continuously and adjust our muscles accordingly to keep us upright. This is a particularly difficult task in terms of robotic programming, so even the fruits of multi-million- pound research programmes such as Honda’s ASIMO or the Boston Dynamics’ biped robots are only just starting to walk comfortably. By comparison, four-legged walking in the way practised by most walking animals is a much more stable process, and a four-legged walking robot is well within the capabilities of most people.

Building the Chassis

We walk by creating a gait using our complex muscles and joints, but there are other motions that can generate movement in a robot. The simplest by far of these use a circular reciprocating motion from a cam or eccentric drive, but there are also robots that use a spring-driven hopping motion. For the purposes of this article, we’ll be looking at a robot that mimics an animal leg, as the capabilities of a microcontroller now put its control within anybody’s reach.

An assembled leg

Our limbs have a range of articulation far greater than is needed for walking, to the extent that fully replicating a human limb makes for an extremely expensive piece of robotics. Happily, the articulation required for each individual task that a human limb can do is only a subset of the whole. So, for a walking leg, the articulation can be reduced to only the axes needed for the job. Hip, knee, and ankle joints can be made to only move in one plane, resulting in a leg that only requires three servos. With a rounded foot design, the need for an ankle can be further removed, leading to a leg with only two servos. This is the design followed by the robot we are making here; it has four legs of two servos each – only eight servos for full walking mobility.

THE MINIKAME, AN INFINITELY VERSATILE ROBOT DESIGN
The Kame series of robots follow a 3D-printed open- source design that has been around for several years now, and which has seen significant refinement and alternative versions of the same basic four-legged robot. Elements from different versions can be combined for custom builds, and a wide array of other controllers substituted for the ESP8266 of the original. A search of the popular Thingiverse 3D model library will turn up a host of different Kame-derived designs. The MiniKame we built is a smaller version originally designed for the HuaDuino, a custom Arduino-based board which required a wait for Hong Kong postage, so we’ve opted to print a modified version of its body designed for the popular (and readily available in the UK) Arduino Nano expansion boards. If you can wait for a HuaDuino to be delivered, that option is a bit more compact. Or if you really know what you are doing, choose another board entirely, such as an ESP8266 one with WiFi – but, for the purposes of this article, we’re sticking with Arduino boards. This is the beauty of open-source: instead of a single take-it-or- leave-it design, there is instead a healthy ecosystem of remixes, meaning that every Kame robot build can be different to suit its owner’s needs.

The different 3D-printed parts for our MiniKame came from Thingiverse, and the instructions came from its Instructables page. You’ll find the resources here.

The thigh servos mounted on the body

The main body of the Kame is a plastic box sized for its controller board, with a lid, and receptacles for the four SG90 servos that form its hip joints. There are two link bars underneath that clip onto the bottom of the body and locate with the lower part of the hip hinge; in our build, it was these and the main body assembly that both came from the Thingiverse repository for the Arduino Nano board. Meanwhile, the legs are the standard MiniKame items: a thigh assembly, and a combined lower leg and foot assembly that fit together with yet another SG90 servo. We printed four of these assemblies. They, and the body, were printed using PLA in two sessions on a HyperCube at MK Makerspace over the course of an evening.

The first step in assembling a MiniKame is to build all four legs. There are the two larger pieces for the thigh and lower leg, plus a small pin that fits under the knee servo and becomes half of the knee hinge. There is a circular hole in the assembly at the bottom of the thigh piece, into which the pin snaps, then the servo can be fitted above it with its shaft pointing in the opposite direction on the same axis as the pin. All MiniKame servo positions have holes ready for the servo fixing screws; your servo should come with the necessary fastenings in its accessory pack.

The servo arms fit into the insets in the 3D-printed parts

There are two distinct mirror-image sets of leg prints; in each case, the spindle of the servo must face outwards away from the end of the robot when it is fitted. In all cases, the lower leg piece has an inset in the shape of a servo arm on the side of the knee which locates with the servo shaft, and a plain hole on the side locating with the pin.

Once the pin and servo are fitted to the thigh piece, the lower leg can be fitted. Slide the pin into its knee joint hole, and then gently ease the other side of the knee over the servo shaft. Don’t fit the servo arms yet – we need the servos to be able to move freely for the calibration step which we’ll perform later.

The body is little more than a plastic box with mountings for four servos that form the hip joints, which should be easy enough to fit and screw into place. Match up the legs to the body corners, such that each corner has a leg whose knee servo shaft faces outwards. With the link bar held underneath across the robot, such that its pin is in the same axis as the servo shaft, fit the leg in the same way as the knee joint by locating the lower point of the hinge on the pin and easing the upper point onto the servo shaft. Again, don’t yet fit the servo arms. Fit all four legs, and route all the servo wires to come together in the centre of the body. That’s it: you now have recognisably built a MiniKame robot, albeit one with floppy legs, because the servo arms are not yet installed.

Making It Move

The next hardware task is to fit the control board and hook up the servos. We used an Arduino Nano clone and an expansion board with an added Bluetooth-to-serial board because that’s the most basic MiniKame configuration, but there are versions of suitable software for multiple other controllers. Wiring is straightforward, with the Nano expansion board providing numbered headers for servos that should be connected as follows:

• D2 to front right hip servo
• D3 to front right knee servo
• D4 to back right hip servo
• D5 to back right knee servo
• D6 to back left hip servo
• D7 to back left knee servo
• D8 to front left hip servo
• D9 to front left knee servo

The Bluetooth module is then wired in with four socket-to-socket jumpers: two to 5 V and GND pins, and the serial TX on the Nano board to the RX on the module, and the RX to the TX.

There’s one further component that we’ve not yet mentioned: the power supply. There are a huge number of possible ways to power any Arduino project, almost all of which could give a MiniKame the necessary juice. We tried two methods: our robot was able to function from a mobile phone booster pack over a USB cable, or from a pack of AA batteries via the Arduino power jack. Other options you could consider might be a LiPo battery with a suitable regulator board, or even a long cable from an external power supply. It’s worth bearing in mind, though, that the robot may not like too much weight; our MiniKame found the weight of eight AA batteries to be a bit much.

The Nano and its shield fit neatly into the body. The Bluetooth module is in the background

Software
We are almost ready to install the software on our MiniKame, but there is one final step before we can proceed. It involves another piece of software, which sets up the Bluetooth module. This can be found on the Instructables page, but is also shown below. You’ll need to use the Arduino IDE to load it onto your Arduino Nano and, ensuring that the Bluetooth module is connected, you should then reset the Arduino without USB connected and let it run.

void setup()
{ Serial.begin(9600); //change to fit your ble initial baud_rate
Serial.println(“AT+UUID0xDFB0\r”); // uuid delay(50);
Serial.println(“AT+CHAR0xDFB1\r”); // characteristic delay(50);
Serial.println(“AT+BAUD8\r”); // set baud rate to 115200}
void loop()
{}

The stock software for a MiniKame comes in two halves: an Arduino sketch for the robot itself, and an app for your phone. The result is a simple remote-controlled robot which is fun enough to play with, but the real fun comes in the accessible nature of Arduino coding. You can choose to use it as a novelty robot toy, or you can get inside its mind and hack the software.

Installing the final Arduino sketch is as simple as downloading its repository from GitHub, unzipping the archive, and compiling it to the Arduino itself using the Arduino IDE. Meanwhile, there is more than one suitable app for a Kame in the Play Store and the Apple App Store, which can be installed on your device of choice. Pair with the Bluetooth module and you should be ready to proceed.

If all went well, you should now have a MiniKame robot with floppy legs, but with all software and wiring in place. The final step is one of calibration, the act of setting all the servos to a known position before fitting the servo arms. This is simple enough: fit a jumper wire between the Arduino Nano’s D12 line and its 3.3-volt pin (made easy by the relevant pins being exposed on our Nano expansion board), and power up the robot. You will hear the servos move into their calibrated positions, then you can power down the robot, remove the jumper from D12, and install the servo arms.

Position the robot flat with its legs outstretched at 45 degrees to the body, and carefully snap in a single-sided servo arm into each inset. There should then be just enough room to slide a single-sided servo arm into the inset, and click it onto the servo shaft before screwing it into place. If you’re lucky, you should now have a working MiniKame. Enjoy it!

On the move

What Went Wrong

In this article, we have discussed the building of a toy robot by an engineer with years of experience in creating some extremely complex devices and systems. We’ve seen quite a few MiniKame builds over the years – it’s a popular choice because it works. Despite the descriptions above sounding easy, however, this build turned out to be a difficult one fraught with problems and setbacks. It’s important to own your mistakes and shortcomings, and it’s also important, if you don’t have huge experience, to understand that things go wrong for professional engineers too. Thus we’ll run through some of the issues, so that with luck you can avoid them yourselves.

In theory, 3D printing is a press-and-go affair, like using a photocopier. In practice, a lot of care and patience is required, along with some failed prints. Our first set of MiniKame legs didn’t have enough support material and were somewhat droopy, so we increased the support and tried again. The result was a perfect print, but the extra support proved very difficult to remove. Thus our feet have a messy remainder of chiselled-off support material on their underside. It’s best to own up to these things.

Always read the instructions. We fitted the servo arms, then had to remove them again for the calibration step.

The servo arms can break if too much force is applied. We broke a couple, and had to cut one side off a double-sided arm to make a replacement.

Our Bluetooth module was extremely difficult to pair with our phone. It would appear in the list of devices, then disappear as if by magic when we tried to connect. A lot of time was expended getting it to eventually connect.

We have to admit it, our MiniKame has been temperamental. All the components appear to be fully working, yet sometimes they refuse to work together. A thought was that a power supply might be to blame, but they continue to have problems even when a bench power supply is used. If there is a lesson to be learned here, it is to always buy good-quality components if you want a robot that walks all of the time rather than some of the time, and be prepared to mistrust a cheap Chinese Arduino clone that has been sitting on your bench for a year or so.


Walking Mechanics

To successfully make a robot walk, we have to understand something of the mechanics of walking, both the structure of a leg and the coordinated movements of its joints. One of the best sources for this comes from an unexpected source: not zoologists or roboticists, but animators. A cartoon character walking across the screen has to look like a cat, a dog, or an anthropomorphic standing-up mouse, and one of the key features it must possess to do this comes in walking in a convincing way. Thus animators make an extensive study of walking motion, so if you’re interested in walking, a very good place to start is a web search on phrases such as ‘animation walking tutorial’. You may not need to produce the natural motion that the animators require, but a grasp of the sequence of movement of a four-legged animal’s legs is important in the understanding of how your robot can move without becoming unstable.

The Parts We Used In Our Build

The parts used in this robot build are all completely standard and should be available from the usual maker sources. If you opt for a board such as the HuaDuino, it may have to be ordered from overseas, but that is beyond the scope here.

The body and leg components were 3D-printed in PLA. You may find that some commercial 3D-print services can sell you them ready-made, but they are easy enough to print yourself. Your local hackerspace will have a 3D printer – go and join up if you are not already a member.

The legs use eight standard SG90 servos that can be bought from multiple suppliers. Ours came from Amazon, but could just as easily have come from HobbyKing, or any other model parts shop. They should include all screws and servo arms.

The Arduino Nano and Arduino Nano Shield V3 boards are standard commodity items that should only cost a few pounds. Ours were Chinese clones rather than the genuine Arduino boards. Again, they are available from a huge variety of suppliers; ours were already on the bench. We suggest buying quality if you can.

The Bluetooth HC-05 module is yet again a standard component available from many suppliers. Ours came from Amazon.

Finally, the jumper cables are the rainbow ribbon cable variety with single DuPont sockets at each end. All the usual suppliers sell them; the chances are you already have some, but if you don’t, you’ll find them useful far beyond a MiniKame.

From HackSpace magazine store

Subscribe