You're reading from BeagleBone Robotic Projects
We've covered creating robots using a wheeled/track base. In this chapter, you will be introduced to some of the basics of servo motors and using the BeagleBone Black to control the speed and direction of your legged platform. Here is an image of a finished project:
Even though you've learned to make your robot mobile by adding wheels or tracks, this mobile platform will only work well on smooth, flat surfaces. Often, you'll want your robot to work in environments where it is not smooth or flat; perhaps, you'll even want your robot to go upstairs or over curbs. In this chapter, you'll learn how to attach your board, both mechanically and electrically, to a platform with legs, so your projects can be mobile in many more environments. Robots that can walk: what could be more amazing than that?
Now that you have a legged platform and a servo motor controller, you are ready to make your project walk!
Before you begin, you'll need some background on servo motors. Servo motors are somewhat similar to DC motors; however, there is an important difference. While DC motors are generally designed to move in a continuous way—rotating 360 degrees at a given speed—servos are generally designed to move within a limited set of angles. In other words, in the DC motor world, you generally want your motors to spin with continuous rotation speed that you control. In the servo world, you want your motor to move to a specific position that you control.
Now that you can control your servos using basic commands, let's control them using a program.
So, you know that you can talk to your servo motor controller and set your servos. In this section, you'll create a Python SW program that will let you talk to your servos a bit more intuitively. You'll issue commands that tell a servo to go to a specific angle, and it will go to that angle. You can then add a set of such commands to allow your legged mobile robot to lean left, lean right, or even take a step forward.
Let's start with a simple program that will make your legged mobile robot's servos go to 90 degrees. This should be somewhere close to the middle of the 180 degrees you can set. However, the center, maximum, and minimum values can vary from servo to servo, so you may need to calibrate these values. To keep things simple, we will not cover that here. The following is the code:
The explanation...
Now that your robot can move, wouldn't it be neat to have it obey your commands?
You should now have a mobile platform that you can program to move in any number of ways. Unfortunately, you still have your LAN cable connected, so the platform isn't completely mobile. And once you have begun the program, you can't alter the behavior of your program. In this section, you will use the principles from Chapter 3, Providing Speech Input and Output, to issue voice commands to initiate movement.
You'll need to modify your voice recognition program, so it will run your Python program when it gets a voice command. If you feel rusty on how this works, review Chapter 3, Providing Speech Input and Output. You are going to make a simple modification to the continuous.c
program in /home/ubuntu/pocketsphinx-0.8/src/programs
. To do this, type cd /home/ubuntu/ pocketsphinx-0.8/src/programs
and then type emacs...
You've now built a two-legged robot, and you can easily expand this to robots with even more legs. Here is an image of the mechanical structure of a four-legged robot that has eight DOF, which is fairly easy to create using many of the parts you have used to create your two-legged robot. This is my personal favorite because it doesn't fall over and break the electronics:
You'll need eight servos, and lots of battery. If you look on eBay, you can often find kits for sale for four-legged robots with twelve DOF, but again realize that the battery will need to be much bigger. For these kinds of applications, we often use remote control (RC) batteries. These are nice, as they are rechargeable, but make sure you either purchase one that is 5 to 6 volts, or include a way to regulate the voltage. Here is a picture of this kind of battery, available at most hobby stores:
If you use this type of battery, don't forget a charger. The hobby store can help with choosing an appropriate match...