Hacking Roomba®
Total Page:16
File Type:pdf, Size:1020Kb
Hacking Roomba® Tod E. Kurt Wiley Publishing, Inc. Hacking Roomba® Published by Wiley Publishing, Inc. 10475 Crosspoint Boulevard Indianapolis, IN 46256 www.wiley.com Copyright © 2007 by Wiley Publishing, Inc., Indianapolis, Indiana Published simultaneously in Canada ISBN-13: 978-0-470-07271-4 ISBN-10: 0-470-07271-7 Manufactured in the United States of America 10 9 8 7 6 5 4 3 2 1 No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 646-8600. Requests to the Publisher for permission should be addressed to the Legal Department, Wiley Publishing, Inc., 10475 Crosspoint Blvd., Indianapolis, IN 46256, (317) 572-3447, fax (317) 572-4355, or online at http://www.wiley.com/go/permissions. Limit of Liability/Disclaimer of Warranty: The publisher and the author make no representations or warranties with respect to the accuracy or completeness of the contents of this work and specifically disclaim all warranties, including without limitation warranties of fitness for a particular purpose. No warranty may be created or extended by sales or promotional materials. The advice and strategies contained herein may not be suitable for every situation. This work is sold with the understanding that the publisher is not engaged in rendering legal, accounting, or other professional services. If professional assistance is required, the services of a competent professional person should be sought. Neither the publisher nor the author shall be liable for damages arising herefrom. The fact that an organization or Website is referred to in this work as a citation and/or a potential source of further information does not mean that the author or the publisher endorses the information the organization or Website may provide or recommendations it may make. Further, readers should be aware that Internet Websites listed in this work may have changed or disappeared between when this work was written and when it is read. For general information on our other products and services or to obtain technical support, please contact our Customer Care Department within the U.S. at (800) 762-2974, outside the U.S. at (317) 572-3993 or fax (317) 572-4002. Library of Congress Cataloging-in-Publication Data Kurt, Tod E., 1969– Hacking Roomba / Tod E. Kurt. p. cm. ISBN-13: 978-0-470-07271-4 (paper/website) ISBN-10: 0-470-07271-7 (paper/website) 1. Robots—Programming. 2. Roomba vacuum cleaner. 3. Autonomous robots. 4. Mobile robots. I. Title. TJ211.45.K87 2007 629.8´9251—dc22 2006031031 Trademarks: Wiley, the Wiley logo, and related trade dress are trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its affiliates, in the United States and other countries, and may not be used without written permission. ExtremeTech and the ExtremeTech logo are trademarks of Ziff Davis Publishing Holdings, Inc. Used under license. All rights reserved. iRobot and Roomba are registered trademarks of iRobot Corporation. All other trademarks are the property of their respective owners. Wiley Publishing, Inc., is not associated with any product or vendor mentioned in this book. Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available in electronic books. About the Author Tod E. Kurt has engineered the hardware and software for robotic camera systems that went to Mars. He was a founding developer and systems architect of Overture Systems, originally GoTo.com, later sold to Yahoo. Now as co-creator of ThingM.com, he’s designing sketchable hardware and networked smart objects. He has degrees in electrical engineering from Caltech and physics from Occidental College. He started robotics hacking at the age of twelve when he took apart his BigTrak, RC car, and chemistry set to make an upright programmable robot. Credits Executive Editor Vice President and Executive Publisher Chris Webb Joseph B. Wikert Development Editor Compositor Kelly Talbot Happenstance Type-O-Rama Copy Editor Proofreader Michael Koch Nancy Riddiough Editorial Manager Indexer Mary Beth Wakefield Ted Laux Production Manager Anniversary Logo Design Tim Tate Richard Pacifico Vice President and Cover Design Executive Group Publisher Anthony Bunyan Richard Swadley Contents at a Glance Acknowledgments. xi Introduction . xiii Part I: Interfacing Chapter 1:Getting Started with Roomba. 3 Chapter 2:Interfacing Basics. 19 Chapter 3:Building a Roomba Serial Interface Tether . 41 Chapter 4:Building a Roomba Bluetooth Interface . 65 Chapter 5:Driving Roomba . 89 Chapter 6:Reading the Roomba Sensors . 109 Part II: Fun Things to Do Chapter 7:Making RoombaView. 131 Chapter 8:Making Roomba Sing. 151 Chapter 9:Creating Art with Roomba . 167 Chapter 10:Using Roomba as an Input Device . 189 Part III: More Complex Interfacing Chapter 11:Connecting Roomba to the Internet. 205 Chapter 12:Going Wireless with Wi-Fi . 231 Chapter 13:Giving Roomba a New Brain and Senses . 257 Chapter 14:Putting Linux on Roomba. 297 Chapter 15:RoombaCam: Adding Eyes to Roomba. 333 Chapter 16:Other Projects . 365 Appendix A:Soldering and Safety Basics. 383 Appendix B:Electrical Diagram Schematics . 405 Appendix C:iRobot Roomba Open Interface (ROI) Specification . 415 Index . 427 Contents Acknowledgments . xi Introduction. xiii Part I: Interfacing Chapter 1: Getting Started with Roomba. 3 Quick Start . 3 What Is Roomba?. 3 Which Roomba Cleaners Are Hackable?. 5 Internal and External Components . 13 OSMO//hacker: Hope for Older Third Generation Roombas . 16 Summary. 17 Chapter 2: Interfacing Basics . 19 What Can Be Done with the ROI? . 19 The ROI Connector. 21 The ROI Protocol . 24 Introducing the RoombaComm API . 39 Summary. 40 Chapter 3: Building a Roomba Serial Interface Tether. 41 Alternatives . 41 Parts and Tools. 43 The Circuit . 44 Building the Serial Tether . 48 Connecting to a Computer . 56 Commanding Roomba . 62 Summary. 63 Chapter 4: Building a Roomba Bluetooth Interface. 65 Alternatives . 65 Why Bluetooth? . 66 How Bluetooth Works. 67 Parts and Tools. 68 The Circuit . 70 Building the Bluetooth Adapter . 71 Setting Up Bluetooth . 78 Testing Bluetooth . 83 viii Contents Using the Adapter . 83 Making RoombaComm . 84 Summary. 88 Chapter 5: Driving Roomba. 89 The Roomba Motors and Drive Train. 89 The ROI DRIVE Command . 92 Simple Tank-Like Motion. 98 Moving in Curves . 102 Real-Time Driving . 104 Writing Logo-Like Programs . 107 Summary . 108 Chapter 6: Reading the Roomba Sensors . 109 Roomba Sensors . 109 ROI SENSORS Command . 115 Parsing Sensor Data . 118 Using Sensor Data . 121 BumpTurn: Making an Autonomous Roomba. 122 Measuring Distance and Angle . 124 Spying on Roomba. 126 Summary . 127 Part II: Fun Things to Do Chapter 7: Making RoombaView . 131 About Processing . 131 Using RoombaComm in Processing . 136 Designing RoombaView . 140 Summary . 150 Chapter 8: Making Roomba Sing . 151 Sonic Capabilities of Roomba . 151 ROI SONG and PLAY Commands. 154 Playing Roomba as a Live Instrument . 157 Roomba Ringtones. 159 RoombaMidi: Roomba as MIDI Instrument . 161 Summary . ..