Raspberry Pi Robotic Projects Third Edition Work through a mix of amazing robotic projects using the Raspberry Pi Zero or the Raspberry Pi 3 Richard Grimmett BIRMINGHAM - MUMBAI Raspberry Pi Robotic Projects Third Edition Copyright © 2016 Packt Publishing All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews. Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book. Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information. First published: February 2014 Second edition: April 2015 Third edition: October 2016 Production reference: 1041016 Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK. ISBN 978-1-78646-796-6 www.packtpub.com Credits Author Copy Editor Richard Grimmett Safis Editing Reviewer Project Coordinator Jon Witts Suzanne Coutinho Commissioning Editor Proofreader Kartikey Pandey Safis Editing Acquisition Editor Indexer Tushar Gupta Rekha Nair Content Development Editor Graphics Merint Mathew Abhinash Sahu Technical Editor Production Coordinator Hussain Kanchwala Shraddha Falebhai About the Author Richard Grimmett has always been fascinated by computers and electronics from his very first programming project that used Fortran on punch cards. He has a bachelor's and master's degree in electrical engineering and a PhD in leadership studies. He also has 26 years of experience in the Radar and Telecommunications industries and even has one of the original brick phones. Currently, he teaches computer science and electrical engineering at Brigham Young University, Idaho, where his office is filled with many of his robotics projects. This book is the result of working with many of the wonderful students at BYU-Idaho. It also wouldn’t be possible without the help of my wonderful wife, Jeanne. About the Reviewer Jon Witts has been working in the IT industry since 2002, specifically in educational IT since 2004. He was introduced to Linux back in 2001 through his collaboration with two German artists who were visiting the arts organisation he was then working with. Having studied fine arts and educational technology, he sought to innovate with open and accessible digital technologies within his creative practice and is happiest when deconstructing technology and finding its limits. Jon has embedded the use of Raspberry Pi computers in his school as an integral part of the delivery of the computer science curriculum, as well as to run various school clubs and projects. Jon is a Raspberry Pi Certified Educator and also helps to organize and run the Hull Raspberry Jam events. I would like to thank my wife, Sally, and our three daughters for putting up with all the cables and components around the house, and not least for being so tolerant of the need to dodge the robots racing around the kitchen floor! www.PacktPub.com For support files and downloads related to your book, please visit www.PacktPub.com. Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at [email protected] for more details. At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks. https://www.packtpub.com/mapt Get the most in-demand software skills with Mapt. Mapt gives you full access to all Packt books and video courses, as well as industry-leading tools to help you plan your personal development and advance your career. Why subscribe? Fully searchable across every book published by Packt Copy and paste, print, and bookmark content On demand and accessible via a web browser Table of Contents Preface 1 Chapter 1: Getting Started with the Raspberry Pi 5 Setting up the Raspberry Pi 3 6 Powering the board 8 Hooking up a keyboard, mouse, and display 9 Installing the operating system 9 Adding Internet access 14 Accessing your Raspberry Pi 3 from your host PC 14 Setting up the Raspberry Pi Zero 29 Powering the board 30 Hooking up a keyboard, mouse, and display 31 Installing the operating system 34 Adding Internet access 35 Summary 39 Chapter 2: Building Your Own Futuristic Robot 40 Modifying the R2D2 41 Adding wheels and motors 42 Connecting to the top of the R2D2 47 Controlling R2D2 using the Raspberry Pi in Python 50 Adding voice recognition 56 Using eSpeak to allow your robot to speak 63 Using PocketSphinx to accept your voice commands 64 Interpreting commands and initiating actions 73 Adding video capability 75 Downloading and installing OpenCV – a fully featured vision library 80 Controlling your R2D2 remotely 85 Summary 86 Chapter 3: Building a Wall-E Robot 87 Creating the hardware platform 88 Adding the Raspberry P and a DC motor controller 95 Building Wall-E's arms 97 Constructing the arms 100 Controlling Wall-E's tracks using a Raspberry Pi in Python 108 How servo motors work 111 Using a servo controller to control the servos 111 Communicating between the servo controller and a PC 115 Controlling the Servo Controller with the Raspberry Pi 117 Adding the Kinect 360 to your Wall-E 123 Accessing the Kinect 360 using the Raspberry Pi 124 Controlling your Wall-E remotely 128 Summary 128 Chapter 4: Building a Robotic Fish 129 Creating the hardware platform 129 Adding the electronics to your fish 136 Adding the RaspiCamera 142 Controlling your fish remotely 147 Summary 150 Chapter 5: Creating a Robotic Hand with the Raspberry Pi 151 Creating the hardware platform 151 Moving the hand 154 Connecting the servo controller to the Raspberry Pi 158 Controlling your hand 161 Following your hand 165 Summary 173 Chapter 6: A Self-Balancing Robot 174 Creating the hardware platform 174 Adding the electronics to your platform 175 Controlling the DC motors 176 Reading the IMU 177 Accessing the compass programmatically 180 The balancing algorithm 184 Summary 189 Chapter 7: Adding the Raspberry Pi to a Quadcopter 190 Accessing the hardware platform 191 Connecting to the hardware 191 Remote communication 194 Configuring the XBee device 196 Communicating over the XBee interface 202 Adding GPS to your quadcopter 204 Connecting the Raspberry Pi to a USB GPS device 204 [ ii ] Accessing the USB GPS programmatically 212 Summary 218 Index 219 [ iii ]
Description: