Book Image

Raspberry Pi Robotics Essentials

By : Richard Grimmett
Book Image

Raspberry Pi Robotics Essentials

By: Richard Grimmett

Overview of this book

Table of Contents (14 chapters)
Raspberry Pi Robotics Essentials
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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.