You're reading from BeagleBone Robotic Projects
Perhaps the easiest way to make your projects mobile is to add a wheeled platform. In this project, you will be introduced to some of the basics of controlling DC motors and using the BeagleBone Black to control the speed and direction of your wheeled platform.
Even though you can talk to your board, and it can talk back and see, you need to make it mobile to really call it a robot. In this project, you'll learn how to attach your board, both mechanically and electrically, to a wheeled platform. Mobility—what could be more amazing than that?
Tip
Downloading the example code and colored images
You can download the example code files and colored images for this Packt book you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.
The first step to make the platform mobile is adding a motor controller. This allows us to control the speed of each wheel (or track) independently.
Before you get started, let's spend some time understanding the basics of the motor control. Whether you chose the two-wheeled mobile platform or the tracked platform, the basic movement control is the same. The unit moves by engaging the motors. If the desired direction is straight, the motors run at the same speed. If you want to turn the unit, the motors run at different speeds. The unit can turn in a circle if you run one motor forward and one backwards.
DC motors are fairly straightforward devices. The speed and direction of the motor is controlled by the magnitude and polarity of the voltage applied to its terminals. The higher the voltage, the faster the motor will turn. If you reverse the polarity of the voltage, you can reverse the direction the motor is...
Now that you have your basic motor controller functionality up and running, you need to connect both motor controllers to the BeagleBone Black. This task will cover this, and then show you how to control your entire platform programmatically.
Now you'll hook up both motor controllers to the battery power supply and motors. Let's start with the motor controllers. The screw-type connectors on your motor controllers make this easy and help you avoid any soldering.
First, run the battery connectors to the VIN and GND connections on one of the motor controllers. Then, take one of the two small lengths of the jumper wire and place that in the VIN connector, and then do the same with the second jumper wire and the GND connector, as shown in the following image:
Now screw the connection tight. Do this on both the VIN and GND connectors. Now, take the other end of these two jumper wires and place them...
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 task, you will use the principles from Chapter 2, Programming the BeagleBone Black, 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 2, Programming the BeagleBone Black. 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 continuous.c
. The changes will come in the same section as your other voice commands...
You have already covered how to add vision to your BeagleBone Black project. A great addition to your mobile robot is the ability to follow a colored object attached to a target.
Remember how you used OpenCV to find a colored object, and could then find out where in your field of view (left or right, or up or down) it existed? You can use this to decide whether to move your mobile platform right or left, or forward or backward. Try this, and then move the target to see if your mobile robot can follow it.