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?

Prepare for lift off

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 3, Providing Speech Input and Output, to issue voice commands to initiate movement.

Engage thrusters

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 3, Providing Speech Input and Output. 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, and will look like this:

Engage thrusters

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

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

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.

Objective complete – mini debriefing

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.

Classified intel

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 moves your robot forward, a different backwards, another to turn right or left.

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

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