Programming LEGO MINDSTORMS with Java Fast Track 407 Index 421 177 LEGO Java Fore.Qxd 4/2/02 5:01 PM Page Xix
Total Page:16
File Type:pdf, Size:1020Kb
177_LEGO_Java_FM.qxd 4/3/02 1:09 PM Page i [email protected] With more than 1,500,000 copies of our MCSE, MCSD, CompTIA, and Cisco study guides in print, we continue to look for ways we can better serve the information needs of our readers. One way we do that is by listening. Readers like yourself have been telling us they want an Internet-based ser- vice that would extend and enhance the value of our books. Based on reader feedback and our own strategic plan, we have created a Web site that we hope will exceed your expectations. [email protected] is an interactive treasure trove of useful infor- mation focusing on our book topics and related technologies. The site offers the following features: I One-year warranty against content obsolescence due to vendor product upgrades. You can access online updates for any affected chapters. I “Ask the Author” customer query forms that enable you to post questions to our authors and editors. I Exclusive monthly mailings in which our experts provide answers to reader queries and clear explanations of complex material. I Regularly updated links to sites specially selected by our editors for readers desiring additional reliable information on key topics. Best of all, the book you’re now holding is your key to this amazing site. Just go to www.syngress.com/solutions, and keep this book handy when you register to verify your purchase. Thank you for giving us the opportunity to serve your needs. And be sure to let us know if there’s anything else we can do to help you get the maximum value from your investment. We’re listening. www.syngress.com/solutions 177_LEGO_Java_FM.qxd 4/3/02 1:09 PM Page ii 177_LEGO_Java_FM.qxd 4/3/02 1:09 PM Page iii 1 YEAR UPGRADE BUYER PROTECTION PLAN Programming ® ™ with The ULTIMATE Tool for Mindstorms Maniacs! Giulio Ferrari Andy Gombos Søren Hilmer Jürgen Stuber Mick Porter Jamie Waldinger Dario Laverde Technical Editor 177_LEGO_Java_FM.qxd 4/3/02 1:09 PM Page iv Syngress Publishing, Inc., the author(s), and any person or firm involved in the writing, editing, or production (collectively “Makers”) of this book (“the Work”) do not guarantee or warrant the results to be obtained from the Work. There is no guarantee of any kind, expressed or implied, regarding the Work or its contents.The Work is sold AS IS and WITHOUT WARRANTY.You may have other legal rights, which vary from state to state. In no event will Makers be liable to you for damages, including any loss of profits, lost savings, or other incidental or consequential damages arising out from the Work or its contents. Because some states do not allow the exclusion or limitation of liability for consequential or incidental damages, the above limitation may not apply to you. You should always use reasonable care, including backup and other appropriate precautions, when working with computers, networks, data, and files. Syngress Media®, Syngress®,“Career Advancement Through Skill Enhancement®,” and “Ask the Author UPDATE®,” are registered trademarks of Syngress Publishing, Inc. “Mission Critical™,”“Hack Proofing™,” and “The Only Way to Stop a Hacker is to Think Like One™” are trademarks of Syngress Publishing, Inc. Brands and product names mentioned in this book are trademarks or service marks of their respective companies. KEY SERIAL NUMBER 001 99K6GTTBE8 002 2WYH4RUJAZ 003 2QMJF6TVXD 004 3JHGF56YZP 005 S45TG2SP9U 006 5VGBBHWE44 007 6Y6Q4V9NFR 008 7MFGM99EFV 009 W3YHVDKPZ4 010 8GFHR5TNU8 PUBLISHED BY Syngress Publishing, Inc. 800 Hingham Street Rockland, MA 02370 Programming LEGO® MINDSTORMS™ with Java Copyright © 2002 by Syngress Publishing, Inc.All rights reserved. Printed in the United States of America. Except as permitted under the Copyright Act of 1976, no part of this publication may be reproduced or distributed in any form or by any means, or stored in a database or retrieval system, without the prior written permission of the publisher, with the exception that the program listings may be entered, stored, and executed in a computer system, but they may not be reproduced for publication. Printed in the United States of America 1 2 3 4 5 6 7 8 9 0 ISBN: 1-928994-55-5 Technical Editor: Dario Laverde Cover Designer: Michael Kavish Technical Reviewer: Simon Ritter Page Layout and Art by: Shannon Tozier Acquisitions Editor: Catherine B. Nolan Copy Editor: Jesse Corbeil, Michael McGee Developmental Editor: Kate Glennon Indexer: J. Edmund Rush CD Production: Michael Donovan Distributed by Publishers Group West in the United States and Jaguar Book Group in Canada. 177_LEGO_Java_FM.qxd 4/3/02 1:09 PM Page v Acknowledgments We would like to acknowledge the following people for their kindness and support in making this book possible. Karen Cross, Lance Tilford, Meaghan Cunningham, Kim Wylie, Harry Kirchner, Kevin Votel, Kent Anderson, Frida Yara, Bill Getz, Jon Mayes, John Mesjak, Peg O’Donnell, Sandra Patterson, Betty Redmond, Roy Remer, Ron Shapiro, Patricia Kelly,Andrea Tetrick, Jennifer Pascal, Doug Reil, and David Dahl of Publishers Group West for sharing their incredible marketing experience and expertise. Jacquie Shanahan,AnnHelen Lindeholm, David Burton, Febea Marinetti, and Rosie Moss of Elsevier Science for making certain that our vision remains worldwide in scope. Annabel Dent and Paul Barry of Elsevier Science/Harcourt Australia for all their help. David Buckland,Wendi Wong, Marie Chieng, Lucy Chong, Leslie Lim,Audrey Gan, and Joseph Chan of Transquest Publishers for the enthusiasm with which they receive our books. Kwon Sung June at Acorn Publishing for his support. Ethan Atkin at Cranbury International for his help in expanding the Syngress program. Jackie Gross, Gayle Voycey,Alexia Penny,Anik Robitaille, Craig Siddall, Darlene Morrow, Iolanda Miller, Jane Mackay, and Marie Skelly at Jackie Gross & Associates for all their help and enthusiasm representing our product in Canada. Lois Fraser, Connie McMenemy, Shannon Russell and the rest of the great folks at Jaguar Book Group for their help with distribution of Syngress books in Canada. Thank you to our hard-working colleagues at New England Fulfilmment & Distribution who manage to get all our books sent pretty much everywhere in the world.Thank you to Debbie “DJ” Ricardo, Sally Greene, Janet Honaker, and Peter Finch. A special thanks to Matt Gerber at Brickswest for his help and support for our books. v 177_LEGO_Java_FM.qxd 4/3/02 1:09 PM Page vi 177_LEGO_Java_FM.qxd 4/3/02 1:09 PM Page vii Contributors Søren Hilmer (SCJP,SCJD, SCWCD) is Research and Development Manager at IT+, a company in the TietoEnator group. He currently works on security related projects involving Single Sign On. Søren holds a master’s degree in computer science and a bachelor’s degree in physics from the University of Århus. Søren has been giving talks on program- ming the RCX with Java, most notably at the JAOO conference in 2000 (www.jaoo.org). He has been programming in Java since 1996, at that time using Java for coding industrial control systems. Søren would like to dedicate his part of the book to his wonderful wife Joan and his children, Rebecca and Sebastian. Giulio Ferrari works as a Software Developer at EDIS, a leader in pub- lishing and finishing solution and promotional packaging. He studied engineering and economics at the University of Modena and Reggio Emilia, and in the past has developed applications, entertainment software, and Web sites for several companies. He is fond of physical and mathe- matical sciences, as well as of puzzles and games in general (he has a col- lection of 1500 dice of every kind and shape). Giulio co-authored the best-selling Building Robots with LEGO Mindstorms (Syngress Publishing, ISBN: 1-928994-67-9) with his brother, Mario and Ralph Hempel (tech- nical editor), a book that has quickly become a fundamental reference and source of ideas for many LEGO robotics fans. He has been playing with LEGO bricks since he was very young, and his passion for robotics started in 1998, with the arrival of the MINDSTORMS series. From that moment on, he held an important place in the creation of the Italian LEGO community, ItLUG, now one of the largest and most important LEGO users group worldwide. He works in Modena, Italy, where he lives with his girlfriend, Marina. vii 177_LEGO_Java_FM.qxd 4/3/02 1:09 PM Page viii Jamie Waldinger (SCJP) is a developer at Viant Corporation in Boston, where he develops Web-enabled systems for a global client base. He has coded in Java for three years, and holds a bachelor’s degree in business from the University of Massachusetts. Jamie wishes to dedicate his portion of this book to his beautiful fiancée, Rory, and also both her and his loving parents for their endless support. Jürgen Stuber is one of the administrators of the leJOS project and one of the few people who have worked on the internals of leJOS. Jürgen has made important contributions to the leJOS virtual machine, in particular fixes that made rotation sensors usable and that improved the speed of the main instruction loop. Jürgen holds a doctorate from the University of Saarbrücken, Germany. He is currently working as an INRIA postdoc- toral fellow at the LORIA Research Institute for Computer Science in Nancy, France. His main research interests are theorem proving and term rewriting. Mick Porter (SSJCP,MCP) is a Senior Technical Architect for Logica, a global systems integrator. Mick specializes in the design and implementa- tion of wireless and mobile commerce systems.With 15 years of experi- ence in the IT industry, Mick has worked on an enormous variety of systems and projects, and over the last few years, he has delivered a number of major e-commerce systems.