Reader small image

You're reading from  Mastering Beaglebone Robotics

Product typeBook
Published inDec 2014
Reading LevelBeginner
Publisher
ISBN-139781783988907
Edition1st Edition
Languages
Concepts
Right arrow
Author (1)
Richard Grimmett
Richard Grimmett
author image
Richard Grimmett

Richard Grimmett has more fun that should be allowed working on robotics projects while teaching Computer Science and Electrical Engineering at Brigham Young University Idaho. He has a Bachelors and Masters degree in Electrical Engineering and a PhD in Leadership Studies. He also has 26 years of experience in the Radar and Telecommunications industries, and even has one of the original brick phones. He has written books on the basics of using the BeagleBone Black for robotics projects, and another for the Raspberry PI and yet another for the Arduino.
Read more about Richard Grimmett

Right arrow

Chapter 5. Building a Robot that Can Walk

You've built robots that can navigate using tracks. Now let's build one that can walk. Walking robots are interesting as they can go to terrains where wheeled or tracked vehicles can't go. They also perform advanced functions where they can utilize their legs for uses other than walking.

In this chapter, you will build the basic platform of a quadruped. To do this, you will learn the following:

  • The working of servos

  • Using the BeagleBone Black to control a large number of servos with the help of a servo controller

  • Creating complex movements out of simple servo commands

Building robots that can walk


In this chapter, you'll build a quadruped, that is, a robot with four legs. You'll be using 12 servos so that each leg has three points that can move, or three Degrees of Freedom (DOF). In Chapter 6, A Robot that Can Sail, you'll learn how to control servomotors directly using the GPIO pins of the BeagleBone Black. In this project, you'll control 12 servos at the same time, so it will make more sense to use an external servo controller that can supply the control signals and supply voltages for all the 12 servos.

Since servos are the main component of this project, it is perhaps useful to go through a tutorial on servos and how to control them.

Working of servomotors


Servomotors 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 case of a DC motor, you would generally want your motors to spin with continuous rotation speed that you control. But in the case of a servomotor, you would want your motor to move to a specific position that you control. This is done by sending a Pulse-Width-Modulated (PWM) signal to the control connector of the servo. PWM simply means that you are going to change the length of each pulse of electrical energy in order to control something. In this case, the length of this pulse will control the angle of the servo, as shown in the following diagram:

These pulses are sent out with a repetition rate of 60 Hz. You can position the servo to any angle by setting the correct control pulse.

Building the quadruped platform


You'll first need some parts so that you can build your quadruped robot. There are several kit possibilities out there, including the one available at www.trossenrobotics.com/p/PhantomX-AX-12-Quadruped.aspx. However, such kits can be expensive, so for this example, you'll create your own kit using a set of Lynxmotion parts. These are available from several online retailers such as robotshop.com. To build this quadruped, you'll need four legs, each leg requires two Lynxmotion parts. Here are the parts with their Robotshop part numbers:

Quantity

Description

1

Lynxmotion symmetric quadruped body kit: Mini QBK-02

2

Lynxmotion 3'' aluminum femur pair

2

Lynxmotion Robot Leg "A" pair (No servo) RL-01

4

Lynxmotion aluminum multi-purpose servo bracket Two Pack ASB-04

2

Ball bearing with flange: 3mm ID (pair)

Product code: RB-Lyn-317

This last part a bearing you'll need to connect the leg to the body.

You'll also need 12 servos of a standard size. There are...

Using a servo controller to control the servos


To make your quadruped walk, you will first need to connect the servomotor controller to the servos. The servo controller you are going to use for this project is a simple servomotor controller utilizing USB from Pololu (Pololu item number 1354, available at pololu.com) that can control 18 servomotors. Here is an image of the unit:

Make sure that you order the assembled version. This piece of hardware will turn USB commands from the BeagleBone Black into signals that control your servomotors. Pololu makes a number of different versions of this controller, each able to control a certain number of servos. In this case, you may want to choose the 18-servo version, so you can control all 12 servos with one controller and also add an additional servo to control the direction of a camera or sensor. You could also choose the 12-servo version. One advantage of the 18-servo controller is the ease of connecting power to the unit via screw-type connectors...

Communicating with the servo controller via a PC


Now that the hardware is connected, you can use some software provided by Pololu to control the servos. Let's do this using your personal computer. First download the Pololu software from www.pololu.com/docs/0J40/3.a and install it according to the instructions on the website. Once it is installed, run the software, and you should see something like the following screenshot:

You will first need to change the configuration of the serial settings, so select the Serial Settings tab and you should see this:

Make sure that USB Chained is selected; this will allow you to communicate with and control the motor controller over USB. Now go back to the main screen by selecting the Status tab, and now you can actually turn on the 12 servos. The screen should look like this screenshot:

Now you can use the sliders to actually control the servos. Check that servo 0 moves the right front lower servo, servo 1 moves the right front middle servo, servo 2 moves...

Connecting the servo controller to the BeagleBone Black


You've checked the servomotor controller and the servos. You'll now connect the motor controller to the BeagleBone Black and make sure you can control the servos from it. Remove the USB cable from the PC and connect it to the BeagleBone Black. The entire system will look like this:

Let's now talk to the motor controller by downloading the Linux code from Pololu at www.pololu.com/docs/0J40/3.b. Perhaps the best way is to log in to your BeagleBone Black using PuTTY, then type wget http://www.pololu.com/file/download/maestro-linux-100507.tar.gz?file_id=0J315. Then move the file by typing mv maestro-linux-100507.tar.gz\?file_id\=0J315 maestro-linux-100507.tar.gz. Unpack the file by typing tar –xzfv maestro_linux_011507.tar.gz. This will create a directory called maestro_linux. Go to that directory by typing cd maestro_linux and then type ls. You should see something like this:

The README.txt document will give you explicit instructions on...

Creating a program on Linux to control your quadruped


You now know that you can talk to your servomotor controller, and move your servos. In this section, you'll create a Python program that will let you talk to your servos to move them to specific angles.

Let's start with a simple program that will make your legged mobile robot's servos go to 90 degrees (the middle of the 0 to 180 degrees you can set). This particular controller uses bytes of information, so the code will translate the input of the channel and angle to numbers that the controller can understand. For more details, see http://www.pololu.com/docs/0J40. Here is the code to move all the connected servos to the 90 degree point:

Here is an explanation of the code:

  • #! /usr/bin/python: This first line allows you to make this Python file executable from the command line.

  • import serial: This line imports the serial library. You need the serial library to talk to your unit via USB.

  • def setAngle(ser, channel, angle): This function converts...

Issuing voice commands to your quadruped


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 1, Preparing the BeagleBone Black, to issue voice commands to initiate movement.

You'll need to modify your voice recognition program so that it can run your Python program when it gets a voice command. You have 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 continuous.c. The changes will occur in the same section as your other voice commands and will look like this:

The additions are pretty straightforward. Let's walk through them:

  • else if (strcmp(word, "FORWARD") == 0): This checks the...

Summary


You now have a robot than can walk! You can also add other sensors, like the ones you discovered for your tracked robot, sensors that can watch for barriers, or even a webcam.

In the next chapter, you'll start on a new robot. You'll build a robot that can sail under your control or autonomously. You'll start by adding some basic control, then you'll learn how to add a device to sense the wind and a GPS to add direction.

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Mastering Beaglebone Robotics
Published in: Dec 2014Publisher: ISBN-13: 9781783988907
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Richard Grimmett

Richard Grimmett has more fun that should be allowed working on robotics projects while teaching Computer Science and Electrical Engineering at Brigham Young University Idaho. He has a Bachelors and Masters degree in Electrical Engineering and a PhD in Leadership Studies. He also has 26 years of experience in the Radar and Telecommunications industries, and even has one of the original brick phones. He has written books on the basics of using the BeagleBone Black for robotics projects, and another for the Raspberry PI and yet another for the Arduino.
Read more about Richard Grimmett