Reader small image

You're reading from  Raspberry Pi Robotics Essentials

Product typeBook
Published inJun 2015
Publisher
ISBN-139781785284847
Edition1st Edition
Concepts
Right arrow
Author (1)
Richard Grimmett
Richard Grimmett
author image
Richard Grimmett

Dr. Richard Grimmett has been fascinated by computers and electronics from his very first programming project, which used Fortran on punch cards. He has bachelor's and master's degrees 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 now teaches computer science and electrical engineering at Brigham Young University, Idaho, where his office is filled with his many robotics projects.
Read more about Richard Grimmett

Right arrow

Chapter 3. Motion for the Biped

Now that you've got your biped all up and running, you can start developing interesting ways to make it move. In this chapter, you'll learn

  • How to adjust the positions of your servos for the Tyrannosaurus Rex pose

  • The basic walking gait for your robot

  • The basic turn for your robot

Before you begin, however, it will be best if you create a harness for your biped. Your robot is going to be inherently unstable with only two legs, and, as you experiment, you're going to make some mistakes. With only two legs, these mistakes can, and probably will, result in your robot toppling over, which can damage the robot.

If you have an electronics board vise, or an "Extra Hands" device, they can be useful for this purpose. Here is a picture of how to use this device to create a harness:

If you don't, you can easily create this sort of overhead support using a PVC pipe or wood. Really, just something to keep your biped from crashing over during your experimentation.

A basic stable pose


Now that your biped is built and you know how to program the servos using Python, you can experiment with some basic poses. You'll first create a program that allows you to set individual servos so that you can experiment. Here is the program:

This code includes the Python setAngle function from Chapter 2, Building the Biped. The specifics were taken from the www.pololu.com website, but it simply allows you to set a specific servo to a specific angle.

The next part of the code sets all of the servos to their center location. The final piece of the code, the while 1: code set, simply asks the user for a servo and an angle, and then sends the command to the servo controller.

Once the program is run, you should see your biped standing straight up. If not, you may need to center your servos by adjusting the position of the horns. This is a useful pose, but there are others that are more stable. As an excellent first example, you can change the pose to be more like a Tyrannosaurus...

A basic walking motion


Your robot is poised to walk, however, you first have to get a leg off the ground. Of course, that is easy enough; if you simply lift the leg by changing the angle of the knee joint, your leg can get off the ground. You may also want to change the angle of the front to back ankle; this will allow you to lift the leg without raising it quite as high.

However, you'll have a problem if you change just these two servos; as you lift the leg, your robot will fall over. This is due to a simple principle called the center of gravity. When your robot is at rest, your center of gravity looks like this:

It is clear that if you lift a leg, the robot will fall over in the direction of the leg that has been lifted. What you need to do is to shift the center of gravity over the leg that will be left on the ground using the ankle servo that can tilt the robot left and right, so that it ends up like this:

You'll then want to set your servos to lift the left leg. Here is a side view of...

A basic turn for the robot


Your robot can walk forward, but you'll also want your robot to be able to turn. Your turning is limited to the amount you can turn the hip of your robot, which is around 20 degrees for this robot. So, to perform a full 90 degree turn, you'll need to take the turn in several steps. The big difference here is that when you return to the standing state, you do not want to reset your hip rotation servos to 90 degrees. Here are the diagrams, including several that are rear view, for a turn:

Here is the Python code for a basic turning operation:

And here is the Python code to chain these basic states together to step a turn:

Now your robot can walk and turn! Obviously, your robot could walk backward by reversing the order of servo control statements in each of the functions. There are many more types of motions you can program with your robot, following the planning method outlined in this chapter.

Summary


Now, your robot is mobile. The next step is to add some sensors so that your robot can avoid, or find, objects in its path.

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Raspberry Pi Robotics Essentials
Published in: Jun 2015Publisher: ISBN-13: 9781785284847
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

Dr. Richard Grimmett has been fascinated by computers and electronics from his very first programming project, which used Fortran on punch cards. He has bachelor's and master's degrees 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 now teaches computer science and electrical engineering at Brigham Young University, Idaho, where his office is filled with his many robotics projects.
Read more about Richard Grimmett