Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Raspberry Pi Robotic Projects
Raspberry Pi Robotic Projects

Raspberry Pi Robotic Projects: Work through a mix of amazing robotic projects using the Raspberry Pi Zero or the Raspberry Pi 3 , Third Edition

Arrow left icon
Profile Icon Richard Grimmett Profile Icon Jon Witts
Arrow right icon
R$80 R$196.99
Full star icon Full star icon Full star icon Full star icon Empty star icon 4 (3 Ratings)
eBook Oct 2016 238 pages 3rd Edition
eBook
R$80 R$196.99
Paperback
R$245.99
Subscription
Free Trial
Renews at $19.99p/m
Arrow left icon
Profile Icon Richard Grimmett Profile Icon Jon Witts
Arrow right icon
R$80 R$196.99
Full star icon Full star icon Full star icon Full star icon Empty star icon 4 (3 Ratings)
eBook Oct 2016 238 pages 3rd Edition
eBook
R$80 R$196.99
Paperback
R$245.99
Subscription
Free Trial
Renews at $19.99p/m
eBook
R$80 R$196.99
Paperback
R$245.99
Subscription
Free Trial
Renews at $19.99p/m

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Table of content icon View table of contents Preview book icon Preview Book

Raspberry Pi Robotic Projects

Chapter 2. Building Your Own Futuristic Robot

Now that you are up and running, let's start with a simple but impressive project in which you'll take a toy robot and give it much more functionality. You'll start with an R2D2 toy robot and modify it to add a webcam, voice recognition, and motors so that it can get around.

In this chapter, we'll cover the following topics:

  • Using the Raspberry Pi to control two DC motors

  • Hooking up the hardware to make and input sound

  • Using eSpeak to allow our projects to respond with a robot voice

  • Using PocketSphinx to accept your voice commands

  • Using Python and the other tools to interpret commands and initiate actions

  • Hooking up a USB webcam so that you can add vision to your project

  • Downloading and configuring OpenCV so that your project can use this amazing open source software to detect objects, faces, colors, and motion

Creating your own R2D2 will require a bit of mechanical work; you'll need a drill and perhaps a Dremel tool, but most of the mechanical work will...

Modifying the R2D2


There are several R2D2 toys that can provide the basis for this project. They are available from online retailers. This project will use one that is inexpensive but also provides such interesting features as a top that turns and a wonderful place to put a webcam. It is the Imperial Toy R2D2 bubble machine. Here is a picture of the unit:

The unit can be purchased at websites such as Amazon, Toys R Us, and a number of other e-retailers. It is normally used as a bubble machine that uses a canister of soap to produce bubbles, but you'll take all of that capability out to make your R2D2 much more like the original robot.

Adding wheels and motors

In order to make your R2D2 a reality, the first thing you'll want to do is add wheels to the robot. In order to do this, you'll need to take the robot apart, separating the two main plastic pieces that make up the lower body of the robot. Once you have done this, both the right and left arms can be removed from the body. You'll need...

Controlling R2D2 using the Raspberry Pi in Python


The hardware is ready; now you can access all this functionality from the Raspberry Pi. First, install the library associated with the control board, found at http://www.monkmakes.com/rrb3/. Perform the following steps:

  1. Type cd ~.

  2. Run the command git clone https://github.com/simonmonk/raspirobotboard3.git —this will retrieve the library.

  3. Then type cd raspirobotboard3/python to go to the raspirobotboard3/python directory.

  4. Type sudo python setup.py install—this will install the files.

  5. Now you'll create some Python code that will allow you to access both the DC motor to turn the top and/or light the LED. Here is that code:

#!/usr/bin/python 
import time 
import RPi.GPIO as io 
from rrb3 import * 
 
io.setmode(io.BCM) 
 
forward_pin = 27 
backward_pin = 22 
led1 = 24 
led2 = 23 
 
def forward(): 
    io.output(forward_pin, True) 
    io.output(backward_pin, False) 
 
...

Adding voice recognition


Now that your robot is mobile, it is time to allow your robot to speak and respond to voice commands as well. This will make your R2D2 more interactive. To do this, you'll need to add some hardware. This project requires a USB microphone and a speaker adapter. The Raspberry Pi has an audio output, but does not have an audio input, so you'll need the following three pieces of hardware:

  • A USB device that supports microphone in and speaker out:

  • A microphone that can plug into the USB device:

  • A powered speaker that can plug into the USB device. In particular, you'll want one that has an internal battery that can connect to a USB port for charging, like this:

Fortunately, these devices are very inexpensive and widely available.

Tip

Make sure the speaker is powered because your board will generally not be able to drive a passive speaker with enough power for your applications.

Now, on to allowing the Raspberry Pi access to these devices. You can execute all of the following...

Using eSpeak to allow your robot to speak


Sound is an important tool in our robotic toolkit, but you will want to do more than just play music. Let's make our robot speak. You're going to start by enabling eSpeak, an open source application that provides us with a computer voice. eSpeak is an open source voice generation application. To get this free functionality, download the eSpeak library by typing sudo apt-get install espeak in the prompt. The download may take a while, but the prompt will reappear when it is complete. Now, let's see if our Raspberry Pi has a voice. Type the espeak "hello" command. The speaker should emit a computer-voiced hello. If it does not, check the speakers and the volume level.

Now that we have a computer voice, you may want to customize it. eSpeak offers a fairly complete set of customization features, including a large number of languages, voices, and other options. To access these, you can type in the options at the command prompt. For example, type in espeak...

Using PocketSphinx to accept your voice commands


Now that your robot can speak, you'll want it to also obey voice commands. This section will show you how to add speech recognition to your robotic projects. This isn't nearly as simple as the speaking part, but thankfully, you have some significant help from the open source development community. You are going to download a set of capabilities named PocketSphinx, which will allow our project to listen to our commands.

The first step is downloading the PocketSphinx capabilities. Unfortunately, this is not quite as user friendly as the espeak process, so follow along carefully. There are two possible ways to do this. If you have a keyboard, mouse, and display connected, or want to connect through vncserver, you can do this graphically by performing the following steps:

  1. Go to the Sphinx website hosted by Carnegie Mellon University (CMU) at http://cmusphinx.sourceforge.net/ using a web browser window. This is an open source project that provides...

Interpreting commands and initiating actions


Now that the system can both hear and speak, you'll want to provide the capability to respond to your speech and execute some commands based on the speech input. Next, you're going to configure the system to respond to simple commands.

In order to respond, you're going to edit the continuous.c code in the /home/pi/ pocketsphinx-0.8/src/programs directory. You could create our own C file, but this file is already set up in the makefile system and is an excellent starting spot. You can save a copy of the current file in continuous.c.old so that you can always get back to the starting program, if required. Then, you will need to edit the continuous.c file. It is very long and a bit complicated, but you are specifically looking for the section in the code, which is shown in the following screenshot. Look for the /* Exit if the first word spoken was GOODBYE */ comment line:

In this section of the code, the word has already been decoded and is held...

Adding video capability


No self-respecting R2D2 robot would be complete without the ability to see. Fortunately, your R2D2 has just the right spot for a webcam. Once you remove the bubble blowing port, you have the perfect spot for a round webcam.

Here is a picture of a round webcam, which is available on amazon.com and other online retailers:

Here is a picture of the webcam mounted in the slot:

You now need to connect the USB camera to the USB port of the Raspberry Pi. To access the USB webcam directly on the Raspberry Pi, you can use a Linux program called guvcview. Install this by powering up the Raspberry Pi, logging in, and entering the sudo apt-get install guvcview command.

To try your USB camera, connect it and reboot your Raspberry Pi. To check if the Raspberry Pi has found your USB camera, go to the /dev directory and type ls. You should see something similar to the following screenshot:

Look for video0, as this is the entry for your webcam. If you see it, the system knows your...

Downloading and installing OpenCV - a fully featured vision library


Now that you have your camera connected, you can begin to access some amazing capabilities that have been provided by the open source community. The most popular of these for computer vision is OpenCV. To do this, you'll need to install OpenCV. There are several possible ways of doing this; I'm going to suggest the ones that I follow to install it on my system. Some of these packages may have already been installed based on earlier activities, but I'll document all the steps here. Once you have booted the system and opened a Terminal window, type the following commands in the given order:

  1. sudo apt-get update: If you haven't done this in a while, it is a good idea to do this now, before you start. You're going to download a number of new software packages, so it is good to make sure that everything is up to date.

  2. sudo apt-get install build-essential: You should have done this in a previous chapter. If you skipped that part...

Controlling your R2D2 remotely


Now, via vncserver, you can access a video feed and control your robot. Simply access vncserver, open two Terminal windows, and in one Terminal window run camera.py, while in the other Terminal window run r2d2Control.py, like this:

In this instance, there is a third window so that you can use aplay to play R2D2 WAV files that you have downloaded from the Internet. Now you can remotely pilot your R2D2 from a host computer or tablet. If you'd like to do it via a tablet or phone, you'll want to download an SSH app; there are several available from the different app stores. You can use your Wi-Fi settings to connect to the R2D2 access point. Then run the SSH app to access your R2D2 and start vncserver. Then you'll need a vncviewer app; again, there are several available, to access your R2D2 and run a similar configuration from your tablet or phone.

OpenCV is an amazing, powerful library of functions. You can do all sorts of incredible things with just a few lines...

Summary


You've completed your first project, your own R2D2. You can now move it around, program it to respond to voice commands, or run it remotely from a computer, tablet, or phone. Following in this theme, your next robot will look and act like WALL-E.

Left arrow icon Right arrow icon

Key benefits

  • Easy to follow instructions, yet the ones that help you build powerful robots, and exclusive coverage of mobile robots with the Pi Zero
  • Build robots that can run, swim and fly and the cutting-edge dimension of robotics that is possible with the Raspberry Pi Zero and Pi 3
  • Interact with your projects wirelessly and make sci-fi possible, right in your home

Description

This book will allow you to take full advantage of Raspberry Pi Zero and Raspberry Pi 3 by building both simple and complex robotic projects. The book takes a mission-critical approach to show you how to build amazing robots and helps you decide which board to use for which type of robot. The book puts a special emphasis on designing mobile (or movable) robots using the Raspberry Pi Zero. The projects will show inexpensive, yet powerful, ways to take full advantage. It will teach you how to program Raspberry Pi, control the movement of your robot, and add features to your robots.

Who is this book for?

This book is for hobbyists and programmers who are excited about using the Raspberry Pi 3 and Raspberry Pi Zero. It is for those who are taking their first steps towards using these devices to control hardware and software and write simple programs that enable amazing projects. No programming experience is required, Just a little computer and mechanical aptitude and the desire to build some interesting projects.

What you will learn

  • Control a variety of different DC motors
  • Add a USB webcam to see what your robot can see
  • Attach a projector to project information
  • Insert USB control hardware to control a complex robot with two legs
  • Include speech recognition so that your projects can receive commands
  • Add speech output to that the robot can communicate with the world around it
  • Include wireless communication so that you can see what the robot is seeing and control the robot from a distance

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Oct 17, 2016
Length: 238 pages
Edition : 3rd
Language : English
ISBN-13 : 9781786469472
Category :
Languages :
Concepts :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Product Details

Publication date : Oct 17, 2016
Length: 238 pages
Edition : 3rd
Language : English
ISBN-13 : 9781786469472
Category :
Languages :
Concepts :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just R$25 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just R$25 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total R$ 936.97
Raspberry Pi: Amazing Projects from Scratch
R$417.99
Raspberry Pi for  Python Programmers  Cookbook
R$272.99
Raspberry Pi Robotic Projects
R$245.99
Total R$ 936.97 Stars icon

Table of Contents

7 Chapters
Getting Started with the Raspberry Pi Chevron down icon Chevron up icon
Building Your Own Futuristic Robot Chevron down icon Chevron up icon
Building a Wall-E Robot Chevron down icon Chevron up icon
Building a Robotic Fish Chevron down icon Chevron up icon
Creating a Robotic Hand with the Raspberry Pi Chevron down icon Chevron up icon
A Self-Balancing Robot Chevron down icon Chevron up icon
Adding the Raspberry Pi to a Quadcopter Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
(3 Ratings)
5 star 66.7%
4 star 0%
3 star 0%
2 star 33.3%
1 star 0%
Amazon Customer Oct 03, 2018
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Great wealth of information.
Amazon Verified review Amazon
Thomas L. Jun 01, 2019
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I really like the way this book is organized. It gives all of the information that would be needed for the projects described inside, among which are an interactive R2-D2, Wall-E, and others. If you have some previous experience with the pi, building these projects shouldn't be a problem. It gives a nice overview of a lot of different, modern tools that can be used on the platform. I'm using the information on Pocketsphinx (voice control), for example, right now in a separate project, and can say that it provides information much more concisely and effectively than online resources and addresses issues that are specific to implementation on a pi. For specific issues related to my project, I can still search out what I need online, but this book gives a great foundation. I highly recommend this book for those looking for a great overview of many of the current software and hardware tools that can be used on the raspberry pi and other GNU/Linux systems.
Amazon Verified review Amazon
Al Swanson Nov 28, 2016
Full star icon Full star icon Empty star icon Empty star icon Empty star icon 2
I was very excited to get this book based on the description. I did note there were very few reviews for the two earlier editions (especially given the huge numbers of pi's out there) but I know not everyone writes reviews and not everyone is going to use their Pi for robotics. I was also confident because, after all, this was the 3rd edition.The promise of the description is not kept in the content. The promise of using a Kinect for vision? Somehow the author felt that was kept in five pages. Do this, do this, do that. Almost nothing inn terms of explanation and certainly nothing in the way of troubleshooting. If it doesn't work with the instructions (in other words, if the code supplied that you type in) didn't work - don't expect ANY help.True, the description includes the fact that it's less than 200 pages. Even basic OpenCV books run multiple hundreds of pages with no robotics thrown in. So, bad on me.The other issue is that it's from Packt publishers. This company is just a small step above the Kindle Unlimited tech titles. Whether they are self publishers or just completely lacking in any sort of author assistance, I don't know. Some titles are excellent and often they are the only publisher offering books on recent tech subjects. But many titles are put out with little or no editing. Many are released with, like this one, false or (like here) misleading descriptions. Often the English is so poor as to make the book unusable. Poor translations might work for some subjects but not for tech.Not to mention the prices for Packt titles are usually absurdly high for what you get.I checked out the sample chapter on kindle for this book, but like all Packt books, that means you get the table of contents.In this case, I'm surprised because I've read some of the author's work and it's usually high quality. Not sure if this is for the bucks or was rushed, but no way does it fulfill the promise of the description. I'm very disappointed.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.