Mordechai Ben-Ari Francesco Mondada Elements of Robotics Elements of Robotics Mordechai Ben-Ari Francesco Mondada (cid:129) Elements of Robotics MordechaiBen-Ari Francesco Mondada Department ofScience Teaching Laboratoire deSystèmes Robotiques WeizmannInstitute ofScience EcolePolytechnique Fédérale deLausanne Rehovot Lausanne Israel Switzerland ISBN978-3-319-62532-4 ISBN978-3-319-62533-1 (eBook) https://doi.org/10.1007/978-3-319-62533-1 LibraryofCongressControlNumber:2017950255 ©TheEditor(s)(ifapplicable)andTheAuthor(s)2018.Thisbookisanopenaccesspublication. Open Access This book is licensed under the terms of the Creative Commons Attribution 4.0 International License (http://creativecommons.org/licenses/by/4.0/), which permits use, sharing, adap- tation,distributionandreproductioninanymediumorformat,aslongasyougiveappropriatecreditto the originalauthor(s)and the source, providealink tothe CreativeCommonslicense andindicate if changesweremade. The images or other third party material in this book are included in the book’s Creative Commons license,unlessindicatedotherwiseinacreditlinetothematerial.Ifmaterialisnotincludedinthebook’s CreativeCommonslicenseandyourintendeduseisnotpermittedbystatutoryregulationorexceedsthe permitteduse,youwillneedtoobtainpermissiondirectlyfromthecopyrightholder. Theuse ofgeneraldescriptivenames,registerednames,trademarks,servicemarks,etc. inthis publi- cationdoesnotimply,evenintheabsenceofaspecificstatement,thatsuchnamesareexemptfromthe relevantprotectivelawsandregulationsandthereforefreeforgeneraluse. The publisher, the authors and the editors are safe to assume that the advice and information in this book are believed to be true and accurate at the date of publication. Neither the publisher nor the authorsortheeditorsgiveawarranty,expressorimplied,withrespecttothematerialcontainedhereinor for any errors or omissions that may have been made. The publisher remains neutral with regard to jurisdictionalclaimsinpublishedmapsandinstitutionalaffiliations. Printedonacid-freepaper ThisSpringerimprintispublishedbySpringerNature TheregisteredcompanyisSpringerInternationalPublishingAG Theregisteredcompanyaddressis:Gewerbestrasse11,6330Cham,Switzerland For Itay, Sahar and Nofar. Mordechai Ben-Ari For Luca, Nora, and Leonardo. Francesco Mondada Preface Roboticsisavibrantfieldwhichgrowsinimportancefromyeartoyear.Itisalsoa subject that students enjoy at all levels from kindergarten to graduate school. The aim of learning robotics varies with the age group. For young kids, robots are an educationaltoy;forstudentsinmiddle-andhigh-schools,roboticscanincreasethe motivation of students to study STEM (science, technology, engineering, mathe- matics); at the introductory university level, students can learn how the physics, mathematics, and computer science that they study can be applied to practical engineering projects; finally, upper level undergraduate and graduate students prepare for careers in robotics. Thisbookisaimedatthemiddleoftheagerange:studentsinsecondaryschools and in their first years of university. We focus on robotics algorithms and their mathematical and physical principles. We go beyond trial-and-error play, but we don’texpectthestudenttobeabletodesignandbuildrobotsandroboticalgorithms that perform tasks in the real world. The presentation of the algorithms without advancedmathematicsandengineeringisnecessarilysimplified,butwebelievethat theconceptsandalgorithmsofroboticscanbelearnedandappreciatedatthislevel, andcanserveasabridgetothestudyofroboticsattheadvancedundergraduateand graduate levels. The required background is a knowledge of programming, mathematics, and physics at the level of secondary schools or the first year of university. From mathematics: algebra, trigonometry, calculus, matrices, and probability. Appendix B provides tutorials for some of the more advanced mathematics. From physics: time, velocity, acceleration, force, and friction. Hardly a day goes by without the appearance of a new robot intended for educationalpurposes.Whatevertheformandfunctionofarobot,thescientificand engineeringprinciplesandalgorithmsremainthesame.Forthisreason,thebookis not based on any specific robot. In Chap. 1 we define a generic robot: a small autonomous mobile robot with differential drive and sensors capable of detecting the direction and distance to an object, as well as ground sensors that can detect markings on a table or floor. This definition is sufficiently general so that students should be able to implement most of algorithms on any educational robot. vii viii Preface The quality of the implementation may vary according to the capabilities of each platform, but the students will be able to learn robotics principles and how to go from theoretical algorithms to the behavior of a real robot. For similar reasons, we choose not to describe algorithms in any specific pro- gramming language. Not only do different platforms support different languages, buteducationalrobotsoftenusedifferentprogrammingapproaches,suchastextual programming and visual programming using blocks or states. We present algo- rithms in pseudocode and leave it to the students to implement these high-level descriptions in the language and environment for the robot they are using. The book contains a large number of activities, most of which ask you to implement algorithms and to explore their behavior. The robot you use may not havethecapabilitiestoperformalltheactivities,sofeelfreetoadaptthemtoyour robot. This book arose from the development of learning materials for the Thymio educational robot (https://www.thymio.org). The book’s website http:// elementsofrobotics.net contains implementations of most of the activities for that robot. Some of the more advanced algorithms are difficult to implement on edu- cational robots so Python programs are provided. Please let us know if you implementtheactivitiesforothereducationalrobots,andwewillpostalinkonthe book’s website. Chapter1presentsanoverviewofthefieldofroboticsandspecifiesthegeneric robot and the pseudocode used in the algorithms. Chapters 2–6 present the fun- damental concepts of autonomous mobile robots: sensors, reactive behavior, finite state machines, motion and odometry, and control. Chapters 7–16 describe more advanced robotics algorithms: obstacle avoidance, localization, mapping, fuzzy logic, image processing, neural networks, machine learning, swarm robotics, and thekinematicsofroboticmanipulators.Adetailedoverviewofthecontentisgiven in Sect. 1.8. Acknowledgements ThisbookarosefromtheworkontheThymiorobotandtheAsebasoftwaresystem initiated by the second author’s research group at the Robotic Systems Laboratory of the Ecole Polytechnique Fédérale de Lausanne. We would like to thank all the students, engineers, teachers, and artists of the Thymio community without whose efforts this book could not have been written. OpenaccesstothisbookwassupportedbytheEcolePolytechniqueFédéralede Lausanne and the National Centre of Competence in Research (NCCR) Robotics. Preface ix We are indebted to Jennifer S. Kay, Fanny Riedo, Amaury Dame, and Yves Piguet for their comments which enabled us to correct errors and clarify the presentation. We would like to thank the staff at Springer, in particular Helen Desmond and Beverley Ford, for their help and support. Rehovot, Israel Moti Ben-Ari Lausanne, Switzerland Francesco Mondada Contents 1 Robots and Their Applications. .... .... .... .... .... ..... .... 1 1.1 Classification of Robots .. .... .... .... .... .... ..... .... 2 1.2 Industrial Robots... ..... .... .... .... .... .... ..... .... 3 1.3 Autonomous Mobile Robots... .... .... .... .... ..... .... 4 1.4 Humanoid Robots.. ..... .... .... .... .... .... ..... .... 6 1.5 Educational Robots. ..... .... .... .... .... .... ..... .... 7 1.6 The Generic Robot. ..... .... .... .... .... .... ..... .... 11 1.6.1 Differential Drive. .... .... .... .... .... ..... .... 11 1.6.2 Proximity Sensors.... .... .... .... .... ..... .... 12 1.6.3 Ground Sensors.. .... .... .... .... .... ..... .... 13 1.6.4 Embedded Computer.. .... .... .... .... ..... .... 13 1.7 The Algorithmic Formalism ... .... .... .... .... ..... .... 14 1.8 An Overview of the Content of the Book. .... .... ..... .... 15 1.9 Summary .... .... ..... .... .... .... .... .... ..... .... 18 1.10 Further Reading ... ..... .... .... .... .... .... ..... .... 19 References. .... .... .... ..... .... .... .... .... .... ..... .... 19 2 Sensors... .... .... .... ..... .... .... .... .... .... ..... .... 21 2.1 Classification of Sensors.. .... .... .... .... .... ..... .... 22 2.2 Distance Sensors... ..... .... .... .... .... .... ..... .... 22 2.2.1 Ultrasound Distance Sensors.... .... .... ..... .... 23 2.2.2 Infrared Proximity Sensors . .... .... .... ..... .... 24 2.2.3 Optical Distance Sensors... .... .... .... ..... .... 24 2.2.4 Triangulating Sensors . .... .... .... .... ..... .... 26 2.2.5 Laser Scanners... .... .... .... .... .... ..... .... 27 2.3 Cameras . .... .... ..... .... .... .... .... .... ..... .... 30 2.4 Other Sensors. .... ..... .... .... .... .... .... ..... .... 31 2.5 Range, Resolution, Precision, Accuracy .. .... .... ..... .... 32 xi xii Contents 2.6 Nonlinearity .. .... ..... .... .... .... .... .... ..... .... 34 2.6.1 Linear Sensors... .... .... .... .... .... ..... .... 34 2.6.2 Mapping Nonlinear Sensors. .... .... .... ..... .... 35 2.7 Summary .... .... ..... .... .... .... .... .... ..... .... 36 2.8 Further Reading ... ..... .... .... .... .... .... ..... .... 37 References. .... .... .... ..... .... .... .... .... .... ..... .... 37 3 Reactive Behavior .. .... ..... .... .... .... .... .... ..... .... 39 3.1 Braitenberg Vehicles..... .... .... .... .... .... ..... .... 39 3.2 Reacting to the Detection of an Object... .... .... ..... .... 40 3.3 Reacting and Turning.... .... .... .... .... .... ..... .... 42 3.4 Line Following.... ..... .... .... .... .... .... ..... .... 44 3.4.1 Line Following with a Pair of Ground Sensors... .... 45 3.4.2 Line Following with only One Ground Sensor ... .... 48 3.4.3 Line Following Without a Gradient... .... ..... .... 49 3.5 Braitenberg’s Presentation of the Vehicles .... .... ..... .... 51 3.6 Summary .... .... ..... .... .... .... .... .... ..... .... 52 3.7 Further Reading ... ..... .... .... .... .... .... ..... .... 52 References. .... .... .... ..... .... .... .... .... .... ..... .... 53 4 Finite State Machines ... ..... .... .... .... .... .... ..... .... 55 4.1 State Machines.... ..... .... .... .... .... .... ..... .... 55 4.2 Reactive Behavior with State .. .... .... .... .... ..... .... 56 4.3 Search and Approach .... .... .... .... .... .... ..... .... 57 4.4 Implementation of Finite State Machines . .... .... ..... .... 58 4.5 Summary .... .... ..... .... .... .... .... .... ..... .... 60 4.6 Further Reading ... ..... .... .... .... .... .... ..... .... 61 References. .... .... .... ..... .... .... .... .... .... ..... .... 61 5 Robotic Motion and Odometry. .... .... .... .... .... ..... .... 63 5.1 Distance, Velocity and Time... .... .... .... .... ..... .... 64 5.2 Acceleration as Change in Velocity . .... .... .... ..... .... 65 5.3 From Segments to Continuous Motion... .... .... ..... .... 67 5.4 Navigation by Odometry . .... .... .... .... .... ..... .... 69 5.5 Linear Odometry... ..... .... .... .... .... .... ..... .... 69 5.6 Odometry with Turns.... .... .... .... .... .... ..... .... 71 5.7 Errors in Odometry. ..... .... .... .... .... .... ..... .... 73 5.8 Wheel Encoders ... ..... .... .... .... .... .... ..... .... 76 5.9 Inertial Navigation Systems ... .... .... .... .... ..... .... 77 5.9.1 Accelerometers .. .... .... .... .... .... ..... .... 78 5.9.2 Gyroscopes ..... .... .... .... .... .... ..... .... 78 5.9.3 Applications .... .... .... .... .... .... ..... .... 80 5.10 Degrees of Freedom and Numbers of Actuators.... ..... .... 81 5.11 The Relative Number of Actuators and DOF.. .... ..... .... 82 5.12 Holonomic and Non-holonomic Motion.. .... .... ..... .... 88
Description: