lego™ mindstorms™ nxt workshop - first in … · lego™ mindstorms™ nxt workshop william...
TRANSCRIPT
LEGO™ Mindstorms™ NXT Workshop
William AucoinDana Aucoin
NXT Workshop
Dana Aucoin
University of Maryland, Baltimore County (UMBC)
September 10, 2011
Revisions And Notes To Presenters
Target Audience: This presentation was initially generated to provide “rookie coaches” an introduction to the basics of NXT-G programmingDuration: This tutorial takes about 5 hours to give, without giving much
Rev Date Notes
Duration: This tutorial takes about 5 hours to give, without giving much time for doing the hands-on exercises
1.0 September 25, 2010 Initial presentationCustomized for 2010 Body Forward FLL Season
1.5 September 26, 2010 Revised based on comments made during Sept 25th1.5 September 26, 2010 25th course
1.6 Revised Not ReleasedAdded Information on NXT Kits
2.0 September 9, 2011 Revised for 2011 Food Factor FLL Season
2.1 September 21, 2011 Revised based on comments made during September 10th course
V2.1
Thank YOU For Being Here Today!
• We know that you are busy and thi k f th fcan think of many other uses for
your time today
• By working with our children, you y o g t ou c d e , youare helping them to develop into wonderful young ladies and gentlemen
• FIRST relies heavily upon the thousands of volunteers to carry out its missionout its mission
V2.13
Photograph ©2010 Dan Lynch
Our Primary Goal Is To Have FunOur Secondary Goal Is To Learn Something
1. Have Fun
2 Learn about NXT-G Programming2. Learn about NXT G Programming
3. Learn About FIRST LEGO League
Thi li i ill t kThis clinic will not make you an ace NXT-G programmer
We will give you the fundamentals and h f ll id ith fhopefully provide you with some fun and entertainment on the way!
Note: Coaching Tips might be annotated though out theannotated though-out the presentation. It is up to the individual coach on how to implement these recommendations.
V2.15
Tip
Guidelines For Today
• Toilet facilities are right outside this room, to the right
• Feel free to enter and leave at any time quietly
• No food or drinks in the computer lab
V2.16
Credits
Thanks to Northrop Grumman and UMBC for loaning the robot parts to us today
Thanks to UMBC for hosting our clinic
Thanks for Kelly Roulette, Dana Aucoin, Dave Parker, Jamie Gurganus, Dr. Anne Spence, Bill Duncan, and JT Wojtowicz for helping with planning, setting up and running this workshopworkshop
V2.1
Portions of This Presentation Were Adapted From A Presentation Generated by INSciTE
Portions of this presentation were based on a previous presentation developed by Doug Frevert which was based on the work of Fred Rose A portion of theirby Doug Frevert which was based on the work of Fred Rose. A portion of their material was taken from “Building LEGO Robots for FIRST LEGO League” by Dean Hystad.
© 2006 INSciTE in agreement with, and permission from FIRST and the LEGO Group. This document is developed by INSciTE and is not an official FLL document from FIRST and the LEGO Group. This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike License. To view a copy of this license, visit
http://creativecommons.org/licenses/by-nc-sa/2.0/ p // g/ / y / /
or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
LEGO, ROBOLAB, and MINDSTORMS are trademarks of the LEGO Group used here with special permission. FIRST LEGO League is a trademark owned by FIRST (For Inspiration and Recognition of Science and Technology) and the LEGO Group used here with specialand Recognition of Science and Technology) and the LEGO Group used here with special permission. INSciTE is a trademark of Innovations in Science and Technology Education.
V2.1
Thanks to High Tech Kids For MakingTheir Material Available For Our Use
Professionally, the open source software movement has shown that far flung software d l b d
Attribution-NonCommercial-ShareAlike 2.0
You are free:
to copy distribute display and perform the work developers can cooperate to create robust and widely used software. The open source process is a model High Tech Kids wants to emulate for much of the material we develop. The open source software license is a key
to copy, distribute, display, and perform the work
to make derivative works
Under the following conditions:
p yenabler in this process. That is why we have chosen to make this work available via a Creative Commons license. Please check the complete license at: http://creativecommons.org/licenses/by-nc-sa/2.0/.
Attribution. You must give the original author credit.
Noncommercial. You may not use this work for commercial purposes. p://c ea veco o s.o g/ ce ses/by c sa/ .0/.
Share Alike. If you alter, transform, or build upon this work, you may distribute the resulting work only under a license identical to this one.
For any reuse or distribution, you must make clear to others the license terms of
this work.
Any of these conditions can be waived if you get permission from the copyright
holder.
V2.1
Your fair use and other rights are in no way affected by the above.
FLL Allows Two Different RobotsOur Workshop Uses The NXT Robot
RCX Robot
• Older Robot
NXT Robot
• Newer Robot
• LEGO Construction
• Introduced in 1998
• Technic Construction
• Introduced in July 2006
V2.111
• Infrared (IR) Communications • USB and Bluetooth Communications
The Robots Can Purchased As A Pile of Parts From www.legoeducation.com (the Annapolis Mall, eBay and…)
LEGO® MINDSTORMS®Education NXT Base Set
~$260
Classroom Kits For24 Children Workingg
In Pairs (12 Kits) ~$3500
V2.112
The Core of the NXT Robot is the “Brick”
USB Communications Port3 Outputs (Motors)
LCD display
Right Button
On/Select Button
Left Button
Go Back Button
V2.14 Sensor Inputs
The NXT Robot Can Run UsingRechargeable Or Disposable Batteries
R h bl Di bl
LEGO, FIRST and FLL Do Not Endorse Any Specific Battery Vendor
Rechargeable Disposable
Older Battery (uses 9-12 VAC Charger)Li Ion Polymer 7.4 VDC 1500 mAh
Considerations after you choose your battery type:
Newer Battery (uses 10 VDC Charger)Li Ion 7.4 VDC 2200 mAh
V2.114
Considerations after you choose your battery type:• LEGO Batteries are bigger• Can you plug in the charger when the robot is built?• Can you replace the batteries when the robot is built?
Tip
Word Of Caution: Don’t Put Markings Or Stickers On Your Robots Like We Have Done
V2.115Reference: FLL Rules http://firstlegoleague.org/sites/default/files/Challenge/FoodFactor/FLL2011_Complete_Challenge.pdf
HiTechnic NXT-G Blocks Are Not Allowed For FLL Competitions
HiTechnic Motor PID BlockThis block implements a PID controller to control an NXT motor to power it toward a specified Set Point position. The block can be used either in a loop, where each time through the loop it will update the power or it can be used stand alone with the Wait for Completion option set The block also supports several types of Reset actions to establish a reference position based onwill update the power, or it can be used stand-alone with the Wait for Completion option set. The block also supports several types of Reset actions to establish a reference position based on either the current position or one or both mechanical limits.
Description Version Release Date SizeHiTechnic Motor PID Block 1.0 April 19th, 2011 405.80 KB
HiTechnic Sin/Cos Math Block for Mindstorms NXT 2.0 SoftwareThe Sin/Cos block makes the sine and cosine functions available to NXT-G programmers. Supports both degrees and radians. This version uses floating point math and only works the theMindstorms 2.0 and beyond software.
Description Version Release Date SizeDescription Version Release Date SizeHiTechnic Sin/Cos Math Block for Mindstorms NXT 2.0 Software 1.0 January 14th, 2011 154.37 KB
HiTechnic ATan2 Math Block for Mindstorms NXT 2.0 SoftwareThe ATan2 block makes the atan2 functions available to NXT-G programmers. Supports both degrees and radians. This function determines the angle to a point (x,y). This version uses floating point math and only works the the Mindstorms 2.0 and beyond software.
Description Version Release Date SizeHiTechnic ATan2 Math Block for Mindstorms NXT 2.0 Software 1.0a January 21st, 2011 144.82 KB
HiTechnic Integer Sin/Cos Math Block for Mindstorms NXT 1.0 SoftwareThe Integer Sin/Cos block makes the sine and cosine functions available to NXT-G 1.0 programmers. It take an input in degrees and returns sine and cosine values scaled up by 100 to be in the range -100 to 100. This version works with all versions of the LEGO Mindstorms NXT software.
Description Version Release Date SizeHiTechnic Integer Sin/Cos Math Block for Mindstorms NXT 1.0 Software 1.0 January 14th, 2011 132.32 KB
HiTechnic Integer ATan2 Math Block for Mindstorms NXT 1.0 SoftwareThe Integer ATan2 block makes the atan2 functions available to NXT-G 1 0 programmers This function determines the angle in degrees to a point (x y) This version works with all versions
V2.117
The Integer ATan2 block makes the atan2 functions available to NXT-G 1.0 programmers. This function determines the angle, in degrees, to a point (x,y). This version works with all versions of the LEGO Mindstorms NXT software.
Description Version Release Date SizeHiTechnic Integer ATan2 Math Block for Mindstorms NXT 1.0 Software 1.0 January 14th, 2011 118.61 KB
FLL Limits You to The “Six Non-Rotation Sensors” In The Competition Area – Only Five Different Types Are Allowed
Six Non-Rotation Sensors, Maximum
Three Mindstorms™ Motors, Maximum
Parts Limits Apply To What You Bring To The Competition Table
V2.118Reference: FLL Rules http://firstlegoleague.org/sites/default/files/Challenge/FoodFactor/FLL2011_Complete_Challenge.pdf
FLL Allows “3 Mindstorms™ Motors”
• NXT has a Bi-directional Geared Motor
• Can be controlled with two types of programming blocks in NXT-G– Move blocks Will be discussed inMove blocks– Motor blocks
• FLL allows up to 3 motorsNXT Motor
Will be discussed in programming session
• RCX Motor is rarely used with NXT robots– It does not have its own rotation sensor
NXT Motor
V2.1
RCX (Legacy) Motor
Touch Sensors
T h d f d t ti t hi• Touch sensors are good for detecting touching or bumping into something– The wooden wall of the table
Th i i d l– The mission models– Etc.
• Also good for detecting robot attachment/arm g gmovements– The sensor activates when the arm moves far enough
to push in the touch sensor
• Three modes (in NXT-G programming)– Pressed– Released
V2.1
e eased– Bumped
Light Sensor
• The light sensor has two modes:• The light sensor has two modes:
– Ambient
– Reflected (most commonly used in FLL)
• Typically operates in "percent" mode – 0 to 100
Higher number = more light– Higher number = more light
– A lighter surface reflects more light
• Calibrate the sensor using the sensor calibration program
• Most commonly used for detecting features on the FLL Mission Mat
V2.1
on the FLL Mission Mat
– Especially for “line following” (Google “NXT Line Follower Program”)
Light Sensor Readings
• Readings depend on the color of the• Readings depend on the color of the surface
• Sensitive to the distance between the sensor and the reflecting surface– Variations can make the readings unusable– Keep the sensor close to the surface, but not
t ltoo close• 2 Penny “Rule of Thumb”
• Shield the sensor from other light sourcesg
Tip
V2.1
The Light Sensor Averages Its Readings Over Roughly A Circular Area
• Cross a line too fast and you may miss the line
• Recalibrate when your robot is used in an area of different ambient light• Recalibrate when your robot is used in an area of different ambient light (e.g. on the FLL competition field after practicing in the pits)
Tip
V2.1
Tip
Only “LEGO-manufactured Mindstorms” Sensors Are Allowed
LEGO NXT Light Sensor
Allowed
LEGO NXT Color Sensor
Allowed
HiTechnic Color Sensor
Not Allowed!
V2.126
Allowed
The Color Sensor Can Be Used In 3 Modes
• Color sensor
– Detects one of 6 color hues
• Red, Blue, White, Black, Yellow, and Green
– You get what you get, all intermediate colors will be “rounded off” to one of the 6
• Light sensor
– Similar to the standard light sensor, except you can choose your illumination color
– Unfortunately calibration is not supported!
• Color lamp (as an output)
– Just shines the light in one of 3 colors
V2.1
– This block is in the action menu, not the sensor menu
Rotation Sensors
• Rotation sensors measures how far a rotating axle has turned
E h NXT t h b dd d t ti• Each NXT motor has an embedded rotation sensor
• For NXT-G programming, you can use rotations NXT R t ti S
p g g, yor degrees NXT Rotation Sensor
(inside NXT motor)
V2.1
RCX Legacy Sensor
Ultrasonic Sensor
• Transmits Inaudible Sound and Listens For The Sound To Bounce Back– Similar to sonar used by ships and echo-location
d b b tused by bats
• Susceptible to interference by other ultrasonic sensors– May detect the transmissions from other ultrasonic
sensors
TiTip
V2.1
The Brick Has A Timer And The Keys Can Be Used
• The Robot Can Be Programmed To Wait For A Specific Time Before Executing A Command
• The Front Panel Keys Can Be Used To Give The Robot An Input
Tip
V2.1
Some Sensors Are Disallowed By FLL
• Any sensors which are not “LEGO-manufactured elements” are not allowed according to the FLL rules:– HiTechnic™ or other non-LEGO™ Sensors like
• Color Sensor• Acceleration/Tilt Sensor• Gyro Sensor
I f d S• Infrared Sensors• Magnetic Sensors
• Sound Sensor/Microphone Is Not Allowed/ p
Tip
V2.1
Bluetooth Is Disallowed By FLL At The CompetitionBluetooth Can Be Used During Your Practice
• Bluetooth communications are not allowed at the competitions– Bluetooth can be very helpful during practices– The NXT Brick has Bluetooth built-inTip– You either need a computer with built-in
Bluetooth or you need a Bluetooth dongle
p
V2.1
NXT-G Will Run On Both Windows and Apple Macintosh Computers
• Windows– XP to Windows 7 Supported
• Macintosh– OS 10.4 to 10.6OS 10.4 to 10.6– 10.7 (OS X Lion) not currently supported
• Working on patch• 64 bit mode not supported for Macintoshpp
• Screen Resolution: 1024 x 768
• Nearly any processory y p
• More RAM is better– Software is “memory hungry”
V2.134
The Mindstorms Robots Use Software And Firmware To Make The Robot Work
The NXT-G software is loaded and run from your computer (PC or Mac) Aft th d thfrom your computer (PC or Mac) After programs are authored on the
computer, they are “downloaded” to the brick using USB or Bluetooth
The firmware resides
V2.135
The firmware resides in the NXT Brick
Firmware Must Be Downloaded To Your NXT So That The NXT Can Understand Your Programs
• If the Robot is not running or running incorrectly, the firmware may not be up to datenot be up to date
• Firmware is only required to be loaded:
T i t ll fi l– To install a new firmware release,
– NXT lost it’s firmware for some reason, or
– NXT starts behaving badly.
Tick .. Tick ...No firmware Firmware loaded.
V2.1
According To LEGO Education, All NXT MindstormFirmware/Software Pairs Are “Compatible”
• Any version of software will allegedly work with any version of firmware– You just might “loose some features”You just might loose some features
• You can download firmware from the internet– http://mindstorms.lego.com/en-us/support/files/default.aspx#Firmware
If t fi f th i t t d l d t– If you get new firmware from the internet, download to ...\Program Files\LEGO Software\LEGO MINDSTORMS NXT\engine\Firmware\
SoftwareVersion
FirmwareVersion
NotesVersion Version
Retail v2.0 v1.28 Firmware has extra files not in v1.29These files can be manually deleted to make room
Retail v2.0 v1.29 Firmware does not have some optional files (in v1.28)Retail v2.0 v1.29 Firmware does not have some optional files (in v1.28) to make room for programming
Educational v2.0 v1.26
Educational v2.1 v1.31 Includes data logging
V2.137
v1.0 or v1.1 v1.05 Older version
Updating The Firmware Is A Command Under The Tools Menu
V2.138
If you get new firmware from the internet, download to ...\Program Files\LEGO Software\LEGO MINDSTORMS NXT\engine\Firmware
If Your Brick Is Completely Unresponsive, You Can Do A Mechanical “Reset” of the NXT Brick
V2.139
Image Courtesy of: Jayson Falkner http://weblogs.java.net/blog/jfalkner/archive/lejos/reset-button.jpg
If You Want To Use The New Color Sensor, You Need To Have At Least NXT-G Version 2.0
• Since the color sensor is a newer sensor to LEGO Mindstorms, older versions of the software do not support the use of the color sensor
• The Color Sensor requires the NXT-G software• The Color Sensor requires the NXT-G software that comes with the NXT 2.0 Retail kit (8547) or the LEGO Education NXT-G 2.1 software
• Firmware v1.26 and above will support the color sensor
• If you do not have the color sensor block it canIf you do not have the color sensor block, it can be downloaded from the internet and installed if you have NXT-G v2.0 or greater– See next slides
V2.140
If You Want To Use The New Color Sensor, You Need To Have At Least NXT-G Version 2.0
The color sensor block can be downloaded from the internet and installed:
1 Do nload the ipped file and n ip1. Download the zipped file and unzip:– http://education.lego.com/en-gb/preschool-and-school/secondary-11-18/11plus-
lego-mindstorms-education/downloads/
2. Launch the NXT-G software and use the block import-export wizard:
… continued
V2.141
If You Want To Use The New Color Sensor, You Need To Have At Least NXT-G Version 2.0
3. Browse to the unzipped folder and select the palette where you want the sensor block (recommended: sensor):
4. Click on Import and you are done!– Call LEGO Education if you need help: 866-349-5346
V2.142
A Very Good (and Free) NXT-G Tutorial Was Authored Dale Yocum of Catlin Gabel School - On The ORTOP Website
http://www.ortop.org/NXT_Tutorial/index.html http://www.catlin.edu/msrobotics/downloadsYou Can download the full tutorial from:You can run the tutorial from:
V2.147LEGO, FIRST and FLL Do Not Endorse Any Tutorial Software
The Tutorial Starts From The Very Basic And Progresses To The Advanced With Exercises
http://www.ortop.org/NXT_Tutorial/index.html
V2.148
T h e r e A r e M a n y E x c e l l e n t R e s o u r c e s O n T h e I n t e r n e t
• www.hightechkids.org
• www.ortop.org
• http://www.ortop.org/NXT_Tutorial/index.html
• http://www.superquest.net/webclass/sboost/index.htm
• http://www.ortop.org/Workshops/
htt // d ti i d /• http://www.education.rec.ri.cmu.edu/
• http://www.ceeo.tufts.edu/curriculum/
• http://www techbrick org• http://www.techbrick.org
• http://www.thenxtstep.blogspot.com/
• http://www.teamhassenplug.org/NXT/NXTGTips/
V2.151
p // p g g/ / p /
LEGO Education Provides Phone Help With Real People Answering The Phones
•866-349-5346
•7:30AM to 5:30PM CST7:30AM to 5:30PM CST
V2.152
LEGO Also Provides Technical Support
Contact Customer ServiceContact Customer ServiceIn the US, call us toll-free on 1-800-838-9647
We are available Monday - Friday 8 am to 10 pm. Saturday & Sunday 10 am to 6pm EST.
The hours for MINDSTORMS technical support are Monday - Friday 7:30 am to 5:30 pm CST.
V2.153
Once Connected To The Robot, You Can Check The Robot Status
• When connected by USB cable:• When connected by USB cable:– Give your NXT a new name– Check Battery voltage– View available memory (in KiloBytes)
Tip
V2.1
View available memory (in KiloBytes)– Firmware version
You Can Also Free Up Memory On The Brick
Memory
Select, then delete Programs, Sounds, Graphics, and Unused files.
Can free up to 130Kb of Free Storage on the NXT
Tip
V2.1
Can free up to 130Kb of Free Storage on the NXT.
Move Block: Demonstration and Exercise!
1. Using one move block, make your robot move forward
• Experiment with time, degrees and rotationsp , g
2. Using two move blocks, make your robot move forward, then drive backwards to arrive at the starting position
V2.164
Motor Block Demonstration and Exercise!
1. Using one motor block, make your robot rotate its third motor (actuator/manipulator motor)
• Experiment with time, degrees and rotations
V2.166
For More Reliable Movements, Use Either Locked-Wheel Turns or Move Blocks With -100,0 or +100 Steering Commands
RecommendationsRecommendationsTip
Based on this battery-voltage experiment, we came up with the following recommendation for FLLfollowing recommendation for FLL teams when using NXT Software to program their LEGO® NXT robots:
Whenever you use the MOVEblock to control your robot, ensure both drive motors maintain theboth drive motors maintain the same power level (e.g. only use “steering” values of -100, 0, or +100).
V2.167http://paris.utdallas.edu/IEEE-RS-ATR/document/2009/2009-15.pdfhttp://www.ieeereliability.com/Newsletter/1_2010/Article1.htm
Wait Block: Demonstration and Exercise!
1. Using one motor block and various wait blocks, make your robot rotate its third motor (actuator/manipulator motor) until a sensor of your choice is activatedactivated
• Experiment with different sensors
V2.175
Loop Block: Demonstration and Exercise!
1. Using one motor block and one loop block, make your robot rotate its third motor (actuator/manipulator motor) until a sensor of your choice is activatedactivated
• Experiment with different sensors
V2.179
Switch Block: Demonstration and Exercise!
1. Using two motor blocks, one switch block, and a loop block make your robot rotate different motors depending on the output of a sensor of your choicechoice
• Experiment with different sensors
V2.182
The NXT-G Software Has Default Ports For Various Outputs and Sensors
P t D f lt U N t
While you can reprogram each port for a different device, it is easier to stay with the default outputs and sensors for each port
Port Default Usage Notes
A Motor Block and Lamp* Block Attachment motors, if needed
B Move Block Robot mobility (“left” motor)
C Move Block Robot mobility (“right” motor)
1 Touch Sensor
2 Sound Sensor (Not Allowed In FLL)2 Sound Sensor (Not Allowed In FLL)
3 Light Sensor
3 Color Sensor
4 Ultrasonic Sensor
Tip
V2.189 A B/C 1 2 3 4
p
3
Line Following Is Actually Line Edge Following
• When most FLL robots are following a line, they are actually following the edge of a line– The robot is using a sensor to determine when it is looking at one side of
the edge vs. the other side• For example, a light sensor reading dark vs. reading lighter shades
The process typically uses a:– The process typically uses a:• Loop block - to cause the robot to follow the line until something tells it
to stop• Switch block – to cause the robot to either turn into the direction of the
line or away from the line– The sensor used for the switch block determines which way to turn– The contents of the different switch block sequence beams dictate
h th b t i t i t f ll th li dhow the robot is turning to follow the line edge– The value used by the switch block, if a single value, is typically
the average (mean) of the higher and lower values (darkest and lightest)
V2.1
g )
93