Making your mobile platform truly mobile by issuing voice commands

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. Once you have started executing the program, you can't alter its behavior. In this section, you will use the principles from Chapter 2, Programming Raspberry Pi, to issue voice commands to initiate movement.

You'll need to modify your voice recognition program so that it will run your Python program when it gets a voice command. If you feel your knowledge of how this works is rusty, review Chapter 2, Programming Raspberry Pi. You are going to make a simple modification to the continuous.c program in /home/ubuntu/pocketsphinx-0.8/src/. To do this, type cd /home/ubuntu/ pocketsphinx-0.8/src/programs and then type emacs continuous.c. The changes will appear in the same section as your other voice commands and will look as shown in the following screenshot:

Making your mobile platform truly mobile by issuing voice commands

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

  • else if (strcmp(hyp, "FORWARD") == 0) checks the input word as recognized by your voice command program. If it corresponds with the word FORWARD, you will execute everything within the if statement. You use { and } to tell the system which commands go with this else if clause.
  • system("espeak "moving robot"") executes Espeak, which should tell you that you are about to run your robot program.
  • system("/home/ubuntu/maestro_linux/robot.py") indicates the name of the program you will execute. In this case, your mobile platform will do whatever the program robot.py tells it to.

After doing this, you will need to recompile the program, so type make and the executable pocketsphinx_continuous will be created. Run the program by typing ./pocketsphinx_continuous. Disconnect the LAN cable and the mobile platform will now take the forward voice command and execute your program. You should now have a complete mobile platform! When you execute your program, the mobile platform can now move around based on what you have programmed it to do.

You don't have to put all of your capabilities in one program. You can create several programs, each with a different function, and then connect each of the programs to their appropriate voice commands. Perhaps one command can move your robot forward, a different one can move it backwards, and another can turn it right or left.

Congratulations! Your robot should now be able to move around in any way you program it to move. You can even have the robot dance. You have now built a two-legged robot and you can easily expand on this knowledge to create robots with even more legs. The following is an image of the mechanical structure of a four-legged robot that has eight DOF and 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:

Making your mobile platform truly mobile by issuing voice commands

You'll need eight servos and lots of batteries. If you search eBay, you can often find kits for sale for four-legged robots with 12 DOF, but realize that the battery will need to be much bigger. For these kinds of applications, we often use RC (remote control) batteries. These are nice as they are rechargeable, but make sure you either purchase one that is 5 volts to 6 volts or include a way to regulate the voltage. The following is an image of such a battery, available at most hobby stores:

Making your mobile platform truly mobile by issuing voice commands

If you use this type of battery, don't forget its charger. The hobby store can help with choosing an appropriate match.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.204.201