23,99 €
Smart robots are an ever-increasing part of our daily lives. With LEGO MINDSTORMS EV3, you can now prototype your very own small-scale smart robot that uses specialized programming and hardware to complete a mission. EV3 is a robotics platform for enthusiasts of all ages and experience levels that makes prototyping robots accessible to all.
This book will walk you through six different projects that range from intermediate to advanced level. The projects will show you building and programming techniques that are used by engineers in the real world, which will help you build your own smart robot.
You'll see how to make the most of the EV3 robotics platform and build some awesome smart robots. The book starts by introducing some real-world examples of smart robots. Then, we'll walk you through six different projects and explain the features that allow these robots to make intelligent decisions. The book will guide you as you build your own object-tracking tank, a box-climbing robot, an interactive robotic shark, a quirky bipedal robot, a speedy remote control race car, and a GPS-navigating robot.
By the end of this book, you'll have the skills necessary to build and program your own smart robots with EV3.
Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:
Seitenzahl: 208
Veröffentlichungsjahr: 2018
Copyright © 2018 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 or its dealers and distributors, will be held liable for any damages caused or alleged to have been 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.
Commissioning Editor: Vijin BorichaAcquisition Editor: Rahul NairContent Development Editor: Sharon RajTechnical Editor: Komal KarneCopy Editor: Safis EditingProject Coordinator: Virginia DiasProofreader: Safis EditingIndexer: Aishwarya GangawaneGraphics: Tom ScariaProduction Coordinator: Aparna Bhagat
First published: April 2018
Production reference: 1020418
Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK.
ISBN 978-1-78847-156-5
www.packtpub.com
Mapt is an online digital library that gives you full access to over 5,000 books and videos, as well as industry leading tools to help you plan your personal development and advance your career. For more information, please visit our website.
Spend less time learning and more time coding with practical eBooks and Videos from over 4,000 industry professionals
Improve your learning with Skill Plans built especially for you
Get a free eBook or video every month
Mapt is fully searchable
Copy and paste, print, and bookmark content
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.
Twenty years ago, the world was introduced to a bright yellow LEGO brick made of more than just plastic. Powered by 6 AA batteries, the simple 3-input 3-output RCX was born. With this brick, the LEGO Group launched LEGO MINDSTORMS, a new brand to combine robotics with the iconic LEGO platform. Like millions of other children over the past two decades, this combination of building and programming would launch my career.
The modern LEGO MINDSTORMS EV3 continues to inspire children. However, like any new technology, getting started can be difficult. Kyle, or as I will forever know him, Builderdude35, is a great friend, and cornerstone of the modern LEGO MINDSTORMS community. For years, Kyle has introduced both children and adults to LEGO MINDSTORMS via his YouTube channel. In this book, Kyle takes some of the outstanding lessons and formulates tutorials to aid both the novice and advanced users, alike. From introducing the use of real-world data through sensors to programming GPS-based navigation, this book features a unique set of projects for any aspiring roboticist.
Besides providing a starting point with LEGO MINDSTORMS, Kyle showcases his own discoveries in creating the iconic Timmyton and Grunt robots. Focusing on human-robot interaction, these robots showcase how to make robotics inviting and provide character to an otherwise predictable machine. This book is another example of Kyle sharing his wisdom with the community and contributing to the rich LEGO MINDSTORMS legacy. Like Builderdude35's YouTube channel, may this book help you to discover something new, inspire others, and share in the MINDSTORMS magic!
Andy Milluzzi
LEGO MINDSTORMS Community Partner
Kyle Markland is a young robotics enthusiast and aspiring engineer who is committed to helping others learn about technology. His first introduction to robotics was when he joined a FIRST LEGO League (FLL) team. In 2015, he started a weekly series of robotics tutorials on his YouTube channel Builderdude35. The videos aims to teach viewers engineering and programming concepts such as PID line following, dog gears, and pneumatics. In recognition of his efforts in robotics education, LEGO MINDSTORMS officially named Kyle a MINDSTORMS Community Partner (MCP) in August 2017.
Marc-André Bazergui has been with IBM for over 20 years. He is currently a technical solution manager in the Power Systems team. His spare time is spent creating LEGO robots and sharing his passion for MINDSTORMS with the world. He has been a member of the MINDSTORMS Community Partner (MCP) program since 2009. This led him to be involved with the development of the EV3 in 2011. Among his contributions are the design for the EV3 robot, KRAZ3, one of the 12 bonus robots you can build with the LEGO MINDSTORMS 31313 kit. You can find more about Marc-André's work online under the pseudonym bazmarc.
If you're interested in becoming an author for Packt, please visit authors.packtpub.com and apply today. We have worked with thousands of developers and tech professionals, just like you, to help them share their insight with the global tech community. You can make a general application, apply for a specific hot topic that we are recruiting an author for, or submit your own idea.
Title Page
Copyright and Credits
Building Smart LEGO MINDSTORMS EV3 Robots
Packt Upsell
Why subscribe?
PacktPub.com
Foreword
Contributors
About the author
About the reviewer
Packt is searching for authors like you
Preface
Who this book is for
What this book covers
To get the most out of this book
Download the example code files
Download the color images
Robots in action
Conventions used
Get in touch
Reviews
Introduction to Smart Robots
What makes a robot smart?
Examples of smart robots in the real world
Robotic vacuum cleaners
Autonomous cars
Where does the EV3 fit in?
What will we build and why?
Summary
Security Tank – Object-Tracking Robot
Technical requirements
Mechanical design
Drivetrain
Turret
Firing projectiles
Ammo silos
Rotation
Spiked roller
Sensors
Programming
Setting up the program
Beacon check
Setting up the switch
Programming the false case
Change to tabbed view
Following the beacon
Proportional steering
Measuring distance to control speed
K values
Controlling the driving
Aiming the turret
Fire!
Using the compare switch
Program the switch cases
Keeping the beacon in sight
Set up the first switch (right side)
Program the return-to-center (right side)
Programming the left side
Putting it all together
Summary
Omnilander – Ultimate All-Terrain Vehicle
Technical requirements
Mechanical design
Drivetrain – tank tracks reapplied
Climbing mechanism
Hook submechanism
Jack submechanism
Proximity sensors
Ultrasonic sensor
Infrared sensor
Programming
RC
Setting up the loop
Setting up the switch
Configuring the switch cases
Autonomous mode
Setting up the loop and switches
Programming the false case
Programming the true case
Programming the obstacle avoidance sequence
Programming the climbing sequence
Putting it all together
Summary
Timmyton – Interactive Robotic Shark
Technical requirements
Mechanical design
Drivetrain
Cosmetics
Chassis
Pectoral fins
Jaws
Tail
Animating the jaws and tail
Chomping jaws
Wagging tail
Sensors
Infrared sensor
Color sensor
Programming
GUI
Creating the menu graphics
Programming the GUI
Operating modes
Remote control
Jaws
Hungry mode
Funky mode
Autonomous
Putting it all together
Summary
Grunt – Quirky Bipedal Robot
Technical requirements
Mechanical design
Walking mechanism
Cosmetic design
Motorized functions
Mouth
Arms
Sensors
Infrared sensor
Color sensor
Touch sensor
Programming
Setting up a simple AI
Initial code
Nesting the switches
Programming the modes
Hungry mode
Handshake
Remote control
Tantrum
Handshake – alternative trigger
Null case
Putting it all together
Summary
Falcon – Remote Control Race Car
Technical requirements
Mechanical design
Drivetrain
Drive motors
Gear ratios
Differential
Final drive ratio
Steering
Cosmetic design
Sensors
Infrared sensor
Rotation sensor
Programming
Control scheme
MyBlocks
Centering the steering
Saving code as a MyBlock
Steering left
Steering right
Returning the steering to center
Assembling the program
Accessing your MyBlocks
Getting started
Programming the cases
Putting it all together
Summary
GPS Car – Autonomous EV3 Navigation
Technical requirements
Hardware
Dexter Industries dGPS
Basic principles of GPS navigation
Using the dGPS
HiTechnic compass
Using the compass
Modifying the Falcon
Software
Preparing the EV3 software
GPS test program
Sensor blocks
Text blocks
Display blocks
Wait block
Putting it all together
Autonomous navigation
Acquiring target coordinates
MyBlocks for car steering
Importing/exporting MyBlocks
Steering left and right
getAngle MyBlock
Program
Save as MyBlock and create parameters
Define parameter inputs/outputs within the code
Writing the program
Putting it all together
Summary
Other Books You May Enjoy
Leave a review - let other readers know what you think
Building Smart LEGO MINDSTORMS EV3 Robots explores six EV3 projects that range from a low intermediate level to an advanced level. Each chapter uses examples to teach the building and programming concepts applied in each project, then relating them to an application in a real-world smart robot. Each chapter builds on the knowledge learned in the previous chapter, which makes a structured progression that expands your library of EV3 knowledge as you work your way up to the most advanced project in the final chapter. By the time you finish the book, you will have achieved mastery of EV3 and will have developed all of the skills necessary to make your own EV3 robots.
LEGO MINDSTORMS EV3 is a fantastic robotics platform for enthusiasts of all ages and skill levels. Since its inception, MINDSTORMS has made robotics accessible for an entire generation of hobbyists. EV3 is the third iteration of LEGO MINDSTORMS robotics, and it has provided an introduction to robotics for many young enthusiasts. Robots are assembled using the versatile LEGO Technic elements and are animated using motors. Sensors enable the robots to respond to the environment. Finally, programs are written on a computer using unique graphical software and downloaded to the EV3 intelligent brick to make the robot come to life. EV3 has become a staple in classrooms, homes, and in the FIRST LEGO League robotics competition as educators worldwide have recognized its educational value. The EV3 has proven itself to be a tool for serious learning while delivering the fun of playing with LEGO.
This book is for anyone who is interested in getting started with robotics and wants to learn building and programming concepts so that they can start making their own robots. Readers should be familiar with the basics of using EV3 and its graphical programming and have experience with the LEGO Technic building system.
Chapter 1, Introduction to Smart Robots, explains what qualities a robot must have in order to be considered smart and discusses two examples of smart robots in the real world. Then, it introduces the LEGO MINDSTORMS EV3 robotics platform and summarizes the six projects included in this book.
Chapter 2, Security Tank – Object-Tracking Robot, explains how tank-style driving works; introduces mechanisms such as gear ratios, turntables, cams, and EV3's infrared sensor; explores the advantages of using proportional logic in a smart robot, and outlines how to make a beacon following program that applies proportional logic.
Chapter 3, Omnilander – Ultimate All-Terrain Vehicle, reapplies tank tracks for a rugged off-road application; introduces advanced mechanisms such as the worm gear, rack-and-pinion gears, and clutches; describes how to make a remote control program for a tank-style robot; and explains how to use proximity sensors to make an autonomous collision avoidance program.
Chapter 4, Timmyton – Interactive Robotic Shark, covers the original one-kit-wonder's compact mechanical design, its innovative custom GUI that incorporates several programs into one, programming the color sensor, and the myriad of programming features that make this robotic shark come to life.
Chapter 5, Grunt - Quirky Bipedal Robot, demonstrates a simple walking mechanism that can be used in an EV3 project, shows how a robot's cosmetic design can develop its personality, describes how nested switches can enable a robot to make decision making, and lists the programming features that lend Grunt its rich interactive qualities.
Chapter 6, Falcon - Remote Control Race Car, explains how to build a drivetrain and steering system that are modeled after those found in a real-world car, shows how to program car-style steering that automatically returns to the center, describes how to create a remote control program for a car-style robot, and introduces the basics of MyBlocks.
Chapter 7, GPS Car - Autonomous EV3 Navigation, introduces two navigation sensors (the GPS receiver and the magnetic compass) and outlines the basic knowledge necessary for using them. Then, it describes how to modify the Falcon to incorporate these sensors and explains how to program the car to use the sensors to autonomously navigate to a pair of GPS coordinates defined by the user.
Install EV3 Home Edition (version 1.2.2 or newer) on your computer. The software can be downloaded from
https://www.lego.com/en-us/mindstorms/downloads/download-software
.
Spend some time familiarizing yourself with EV3. It is graphical programming software in which programs are written by connecting code blocks together. You should know the names of the blocks and where to find each one of them in the programming palette. You should also be comfortable with dragging and dropping blocks to place them in your program, know how to change their modes, and have a basic understanding of what individual blocks do.
Familiarize yourself with the EV3 brick and understand the basics of using it. Know how to power it on and off, download programs from a computer via the USB cable,
navigate its menus to select a program to run,
and replace the batteries when necessary.
You should have experience of building with LEGO Technic. All of the robots in this book are made using Technic elements.
You may choose to install LEGO Digital Designer (LDD) version 4.3 on your computer. You can download the LDD software from
https://www.lego.com/en-us/ldd/download
. LDD is a LEGO CAD program that allows you to build and view digital models of LEGO creations. It also allows you to generate building instructions for a digital model.
The LDD software will guide you when you build the projects in this book.
You can download the LDD files (
.lxf
) for each project from
http://builderdude35.com/downloads-2/
and open them using the LDD software.
In addition to an EV3 retail set (31313), you will need additional LEGO Technic elements for the projects included in this book. (The only exception is the Timmyton, which can be made with the parts included in one EV3 retail set). You can use LDD to generate a bill of materials, which will help you identify the additional Technic elements you will need.
Chapter 7
,
GPS Car – Autonomous EV3 Navigation
, also requires some third-party hardware from Dexter Industries and HiTechnic.
Before you start programming, update the firmware on your EV3 brick to version 1.09H or newer. Perform the following steps to update your EV3 brick's firmware:
Start EV3 Home Edition on your computer.
Turn on your EV3 brick and plug it into your computer using a USB cable.
Open a new project in EV3.
Navigate to
Tools
|
Firmware Update
.
If version 1.09H is not already available, follow the steps to download it from
https://www.lego.com/en-us/mindstorms/
.
Select the firmware version 1.09H (or newer, if available), click on
Update Firmware
, and wait for the update to complete. The EV3 brick will restart when the update is complete.
You can download the example code files for this book from your account at www.packtpub.com. If you purchased this book elsewhere, you can visit www.packtpub.com/support and register to have the files emailed directly to you.
You can download the code files by following these steps:
Log in or register at
www.packtpub.com
.
Select the
SUPPORT
tab.
Click on
Code Downloads & Errata
.
Enter the name of the book in the
Search
box and follow the onscreen instructions.
Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:
WinRAR/7-Zip for Windows
Zipeg/iZip/UnRarX for Mac
7-Zip/PeaZip for Linux
The code bundle for the book is also hosted on GitHub athttps://github.com/PacktPublishing/Building-Smart-LEGO-MINDSTORMS-EV3-Robots. In case there's an update to the code, it will be updated on the existing GitHub repository.
We also have other code bundles from our rich catalog of books and videos available athttps://github.com/PacktPublishing/. Check them out!
We also provide a PDF file that has color images of the screenshots/diagrams used in this book. You can download it here: https://www.packtpub.com/sites/default/files/downloads/BuildingSmartLEGOMINDSTORMSEV3Robots_ColorImages.pdf.
Visit the following link to check out the robots in action:
https://goo.gl/GB4sFr
There are a number of text conventions used throughout this book.
CodeInText: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: "Set the target number of degrees to 600; this is how far the motor needs to rotate to fire two projectiles."
Bold: Indicates a new term, an important word, or words that you see onscreen. For example, words in menus or dialog boxes appear in the text like this. Here is an example: "The mode on the switch block should be set to Motor Rotation | Compare | Degrees."
Feedback from our readers is always welcome.
General feedback: Email [email protected] and mention the book title in the subject of your message. If you have questions about any aspect of this book, please email us at [email protected].
Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details.
Piracy: If you come across any illegal copies of our works in any form on the Internet, we would be grateful if you would provide us with the location address or website name. Please contact us at [email protected] with a link to the material.
If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit authors.packtpub.com.
Please leave a review. Once you have read and used this book, why not leave a review on the site that you purchased it from? Potential readers can then see and use your unbiased opinion to make purchase decisions, we at Packt can understand what you think about our products, and our authors can see your feedback on their book. Thank you!
For more information about Packt, please visit packtpub.com.
What are smart robots? At today's pace of technological innovation, the word smart is being applied to all sorts of devices: smartphones, smart watches, smart televisions, and the list goes on. The word is even in the title of this book! But what does it mean when we say that a robot is smart? What do smart robots do, and how do they accomplish their task?
When we talk about smart robots, we are not necessarily referring to an advanced artificial intelligence like those in a science fiction movie or a supercomputer that wins the Jeopardy championship, although those are some very smart robots. The definition of a smart robot is actually much broader and includes some devices you may not have originally considered smart.
A smart robot is simply any device that uses sensors to measure some condition in its environment, then decides what to do next based on a set of pre-programmed instructions. They have some kind of computer or controller acting as their brain that processes the sensor information and interprets these instructions. You can think of the software loaded into the robot as the set of instructions that the smart robot follows. The software's programming allows a smart robot to make an observation, then make a decision based on this observation. Of course, a person must first build the robot and write the software, but after that, a smart robot operates on its own without human intervention.
To put it more concisely, a smart robot is a machine that does all of the following things or has all of the following features:
It is able to follow a series of pre-programmed instructions specified by the user or engineer
It is able to makes an observation about the outside world
It has a central computer or other type of controller that interprets both the instructions in the software and the data from the sensor
It is able to make a decision and react based on the observation, following the instructions defined in the program
It is able to complete all of the preceding steps automatically, without human intervention
The ability to make a decision on its own without help from a person is what makes a robot smart. The more decisions a robot can make on its own, the smarter it is.
As you can see, this definition still includes the obvious examples of smart robots that we discussed earlier, but it also includes some simpler devices. Using this definition, a robotic vacuum cleaner is considered a smart robot!
That definition may have seemed somewhat abstract, so let's put it into context with two real-world examples. We will first discuss a simple smart robot—the robotic vacuum cleaner—then talk about a much more sophisticated example—the autonomous car.
These are some of the simpler smart robots that you are likely to encounter, but they are nonetheless smart robots because they fulfill all of the points of our definition:
They follow a series of pre-programmed instructions
: These machines come with their vacuum-cleaning program pre-installed on their control unit. The engineers who developed the product have already sorted out what the robot needs to do during its routine to keep the floors clean. The software is installed on each robot before it leaves the factory. After the customer purchases the robot, all they have to do is charge it, then turn it on, and it gets right to work, following the instructions that the engineers defined in the software.
They make an observation about the outside world
