




























































































Estude fácil! Tem muito documento disponível na Docsity
Ganhe pontos ajudando outros esrudantes ou compre um plano Premium
Prepare-se para as provas
Estude fácil! Tem muito documento disponível na Docsity
Prepare-se para as provas com trabalhos de outros alunos como você, aqui na Docsity
Encontra documentos específicos para os exames da tua universidade
Prepare-se com as videoaulas e exercícios resolvidos criados a partir da grade da sua Universidade
Responda perguntas de provas passadas e avalie sua preparação.
Ganhe pontos para baixar
Ganhe pontos ajudando outros esrudantes ou compre um plano Premium
mecatronica e robotica
Tipologia: Notas de estudo
1 / 441
Esta página não é visível na pré-visualização
Não perca as partes importantes!





























































































iii
Contents at a Glance
■ CHAPTER 1 A Primer..................................................... 1
■ CHAPTER 2 Serial Communication....................................... 15
■ CHAPTER 3 Motion...................................................... 51
■ CHAPTER 4 Sensors.................................................... 109
■ CHAPTER 5 Speech.................................................... 137
■ CHAPTER 6 Vision...................................................... 165
■ CHAPTER 7 Navigation................................................. 221
■ CHAPTER 8 Other Topics............................................... 289
■ CHAPTER 9 Sample Programs.......................................... 319
■ APPENDIX A The Definitive Guide API.................................... 383
■ APPENDIX B Microcontroller Reference.................................. 395
■ APPENDIX C Robot Parts Reference...................................... 399
■ INDEX.................................................................... 403
ix
About the Author
■ SCOTT PRESTON works as a Java architect in Columbus, Ohio, where he resides with his wife, Emily, and dog, Castle. Scott has over 20 years of soft- ware and electrical experience, including positions with the U.S. Navy, Bank One, CompuServe, UUNET, and Covansys Inc., in addition to running his own robotics company, Preston Research LLC. Scott also gives lectures about robotics at COSI (Center of Science and Industry) and manufactures small Java-enabled robots called CubeBots®. Scott is a member of the Java Community Process and an alumnus of The Ohio State University.
xiii
Acknowledgments
I would like to especially thank my loving wife, Emily, for putting up with me while I wrote this book and for all the hours I spent at the PC and downstairs with the robots when I could have been spending it with her. Second, I would like to thank Steve Anglin, Simon Ritter, Sofia Marchant, Michael McGee, and Katie Stence for helping me write this book, and to readers and others at Apress who have been a joy to work with. Third, I would like to thank Ken Gracey from Parallax, Inc., and Jim Frye from Lynxmotion, Inc., for supplying me with various parts, components, and advice during the writing of this book. Fourth, I would like to thank my mother for passing on her common sense and buying me an Atari 400 in 1980, and my father for passing on his engineering smarts and helping me build the original Feynman in 2002. Fifth, I would like to thank my in-laws, Frikkie and Karen Roets, for their hospitality last Christmas (and always), and for the use of their office to contact Apress about writing this book. Sixth, I would like to thank my high-school science teacher, Jan Greissinger, for inspiring me to love science as much as I do today, and also Guy Kawasaki for his books and e-mails, which inspired me to write this book. Finally, I could not end without mentioning my friends Harry and Crissy, Ron and Sophia, Mark and Maria, Bard and Ann, Mark and Tracy, and John and Kristi. I was meaning to spend more time with you this summer, and even come out and visit those who are a little more than a drive away. Plan on that in 2006.
Scott Preston
xv
Introduction
Notes on Style
I admit I was a programmer before I started building robots. So my perspective may be some- what skewed in the direction of a programmer. However, I also didn’t want this book to be from a purely software engineering perspective. I wanted to keep the text balanced between robotics and programming and not get too cute with either discipline, though from time to time I’m afraid I may have indulged myself.
Who Should Read This Book
If you want off-the-shelf robot components, free software, and development tools, this is the book for you. You can download all the software—it’s GPL (General Public License) or Apache License—and you can purchase the components from your favorite robot supplier and/or hobby shop. The following sections outline the experience you should have to get the most out of the book.
Your Programming/Java Experience
I could say that you should have a good understanding of object-oriented techniques and Java before getting started with this book, but if you’re like most roboticists, you’ll likely learn as you go, and by following the various examples I’ve included within these pages. Of course, if you don’t have a background in Java, you will undoubtedly experience a learning curve before things begin to click. If you start getting lost due to the vocabulary or the complexity of the examples, just purchase one of the beginning Java books from Apress. They’re excellent. If things still don’t make sense, send me an e-mail or visit my web site and post a question.
Your Robot Building Experience
For those picking up this book, you should hopefully be an intermediate robot builder already; be familiar with microcontroller concepts, servo controllers, electronic speed controls, and sensors; and have either built a robot from scratch or from a kit. I can recommend a few robots from Lynxmotion, Inc., or if you want to build one from scratch, take a look at some of the Apress books penned by David Cook.
xvi ■I N T R O D U C T I O N
How This Book Is Structured
I’ve structured this book as if I were sitting down to build a Java robot. I start out by reviewing the basics of communication, and then discuss how to get the robot to move, hear, see, and navigate, before exploring how to optimize code and create shortcuts. I’ve divided each chapter into subtopics that progress from easy to difficult. Each subtopic includes the following:
What You Will Need While you can use this book quite effectively without every item named in the following table, the required and optional items shown will help you facilitate the examples in this book. I also provide a list of what you need in each chapter’s introduction.
Platform and Version Notes
I developed this book and its examples with the Sun Java Standard Edition 1.4.2 SDK, using the Eclipse 3.02 IDE running on Microsoft Windows XP. However, if you don’t have a Microsoft operating system, you can easily port the examples in this book to Linux, Macintosh, or any OS running a JVM.
Table 1. Items Needed for Book Examples Required Optional Java 1.4 SDK DLink DBT-120 or other Bluetooth adapter Java APIs (comm, advanced imaging, speech, etc.) EB500 Bluetooth Transceiver from Parallax Parallax Javelin or BASIC Stamp Pan and Tilt Camera Kit from Lynxmotion MiniSSC-II Servo controller Lynxmotion SSC-32 Servo controller Parallax Board of Education (BOE) or other carrier board
Lynxmotion Extreme Hexapod 2
Web camera Sound card and microphone Small mobile robot Miscellaneous robot sensors (sonar, infrared, bump, etc.)
xviii ■I N T R O D U C T I O N
Updates and Software
I will constantly be updating my site at www.scottsbots.com/definitiveguide. Please stop by to visit, download new source code and examples, and get links to Internet resources. I have also included a special section for purchasing robots or parts needed for this book.
1
■ ■ ■
C H A P T E R 1
A Primer
“Everything should be made as simple as possible, but not simpler.”
— Albert Einstein
1.0 Introduction
Before you begin programming your robot with Java, you should consider some things that will make your Java robot experience much more enjoyable. They include the following:
■ Note Be sure your PC has a fast Internet connection as I will often refer to links from the Internet for download or reference.
To begin, I’ll walk you through a setup similar to mine. Forgive me non-Windows users, all screen captures are from Windows XP. When the occasion arises, I’ll mention an alternative way of achieving the same thing with a UNIX-based operating system.
Personal Computer Setup
To facilitate use of your personal computer for this book, you should do the following. Download and install the Java Standard Edition 1.4.2 from:
Download and install Eclipse 3.02 from: