lego mindstorms robotic invention system 2.0

37
LEGO Mindstorms Robotic Invention System Barb Ericson [email protected] Georgia Institute of Technology

Upload: lenhu

Post on 14-Feb-2017

230 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Lego Mindstorms Robotic Invention System 2.0

LEGO Mindstorms Robotic Invention System

Barb [email protected]

Georgia Institute of Technology

Page 2: Lego Mindstorms Robotic Invention System 2.0

What is it?

• A kit for creating and programming robots built with LEGOs

Page 3: Lego Mindstorms Robotic Invention System 2.0

What is in it?• 717 LEGO elements

– One RCX programmable brick– 2 motors– 2 push sensors– 1 light sensor– Infrared transmitter for transferring the programs

• A Constructopedia book with plans for 3 robots and many variations on them

• CD with video on getting started and visual programming environment (RCX code)– 9 robots total

Page 4: Lego Mindstorms Robotic Invention System 2.0

What else do you need?

• 6 AA batteries• Computer

– Windows 98/Me/XP– Pentium II 233MHz – 32 MB RAM– 115 MB Disk Space– USB Port (for the infrared transmitter)

Page 5: Lego Mindstorms Robotic Invention System 2.0

What else might you want?

• Plastic storage containers– For storing built robots– And for sorting parts better

• Ultimate Accessory Kit - $50– 45 LEGO pieces including

• 1 remote control• 1 touch sensor• 1 rotation sensor• 1 lamp• 1 Constructopedia

Page 6: Lego Mindstorms Robotic Invention System 2.0

More Sensors

• http://www.legoeducationstore.com/catalog.cfm?dest=itempg&itemid=920&secid=9&linkon=subsection&linkid=45 Angle (Rotation)Light

Touch

TouchTemp

Page 7: Lego Mindstorms Robotic Invention System 2.0

DCP Sensors

• http://www.legoeducationstore.com/catalog.cfm?dest=itempg&itemid=922&secid=9&linkon=subsection&linkid=45

Page 8: Lego Mindstorms Robotic Invention System 2.0

What else might you want?• Vision Command - $100

– A video camera• 30 frames per second• 352 by 288 color • 145 LEGO elements• USB connection• Built-in microphone• Vision recognition software

• Or get just the camera and USB cable for $39.00 at LEGO Education Store

Page 9: Lego Mindstorms Robotic Invention System 2.0

What does it cost?

• About $200• Buy at

– Toys R Us– Shop.lego.com– Amazon.com– Wallmart.com– http://legomindstorms2.0.hobbytron.net/robotl

egosub.html?source=1359– Ebay.com

Page 10: Lego Mindstorms Robotic Invention System 2.0

What can you do with it?

• Use it with RCX code or Robolab (visual programming)– To teach about commands, programs, iteration,

conditionals, and variables– Without worrying about syntax

• Use it with leJOS (Java)– To teach about commands, programs, iteration,

conditionals, and variables– Arrays, strings, recursion, listeners, static– Using Java syntax

Page 11: Lego Mindstorms Robotic Invention System 2.0

Programming your Robot

• Click the Program button in the main menu

Page 12: Lego Mindstorms Robotic Invention System 2.0

Pick the Robot

• Pick the robot to program. If you are using your own design pick “Freestyle”.

Page 13: Lego Mindstorms Robotic Invention System 2.0

Create a Program using RCX code

• Big Blocks are shown for a particular robot

• Click and drag them to make a program– They will snap into

place• You can save the

program using the File menu– This will name your

program

Page 14: Lego Mindstorms Robotic Invention System 2.0

Download your Program

• Turn on the RCX (OnOff button) • Plug the IR Tower into your computer• Put the RCX near the IR Tower• Click the “Download” button

– The default is to download to slot 5– You can change this by clicking on “Settings”

• When the download is finished the RCX will play a short tune– It displays dots during the download

Page 15: Lego Mindstorms Robotic Invention System 2.0

Running the Program• Two ways to run

– Click the Run button on the RCX

– Or click the Run button on the screen

• Stopping the program– Click the Run button

again on the RCX– Or click the Stop

button on the screen

Page 16: Lego Mindstorms Robotic Invention System 2.0

Modify a Block

• Click on the edit tab at the right edge of the block

• You can change the duration of commands– Use the arrow key to

use preset values– Or type a value in the

textbox

Page 17: Lego Mindstorms Robotic Invention System 2.0

Robot Challenge

• Make your robot go forward for 2 seconds• Make your robot turn right for 1.5 seconds• Make your robot go backwards for 3

seconds• Make your robot spin left for 1.5 seconds• Save your program using the File menu

Page 18: Lego Mindstorms Robotic Invention System 2.0

Getting More Information• Click on Help • Click on What’s this?• The cursor will show

What’s this? with an arrow

• Click on something you want more information about– Like a block– Or a menu item

Page 19: Lego Mindstorms Robotic Invention System 2.0

Robot Challenge

• Use the help to find out the difference between turn left and spin left

• Use the help to figure out what a Dance block will do

• Use the edit tab to try out the Dance block– Make sure your robot is on and near the IR

tower

Page 20: Lego Mindstorms Robotic Invention System 2.0

Using the Sensors• Click a Touch Sensor on

the left and position it on the right – Pick the input port attached

to your sensor– Click next

• Pick when to respond– On press, release, or click

(press and release)– Click next

• Click “Try It” to try it or “Done”

Page 21: Lego Mindstorms Robotic Invention System 2.0

Handling a Sensor Event

• Add command blocks after the if sensor event block– These actions will

happen when that sensor event happens

– Like when the touch sensor is pressed

– Or when the light sensor’s value is > or < some amount

Page 22: Lego Mindstorms Robotic Invention System 2.0

Robot Challenge

• Make your robot go forward for 10 seconds

• If your robot’s touch sensor is pressed backup for 1 second and spin right

• Set up items to block your robot and try it

Page 23: Lego Mindstorms Robotic Invention System 2.0

Adding Iteration

• Use Repeat Blocks to add iteration (looping)

• You can change the number of iterations

• You can repeat a group of commands

Page 24: Lego Mindstorms Robotic Invention System 2.0

Conditionals

• Add a test– Do one thing if

the test is true• Like turn left

– Do something else if the test is false

• Like turn right

Page 25: Lego Mindstorms Robotic Invention System 2.0

Variables

• You can create new variables– freq

• And use them in other blocks– Add to them– Subtract from

them– Multiply them– Divide them

Page 26: Lego Mindstorms Robotic Invention System 2.0

Create New Blocks

• You can create new blocks using My Blocks– Name the block– Add other blocks

to it– You can collapse

the interior commands

• Click on upper left square

Page 27: Lego Mindstorms Robotic Invention System 2.0

Small Blocks• Finer control of

robot• Big Blocks are

made up of small block commands

• Click on the top left box to open a big block– And see the

internal small blocks

Page 28: Lego Mindstorms Robotic Invention System 2.0

Where to get help?

• http://mindstorms.lego.com\– Main web site

• Books – at LEGO Education Store– Building Robots with LEGO Mindstorms– Creative Projects with LEGO Mindstorms– LEGO Mindstorms: RIS 2 Projects

Page 29: Lego Mindstorms Robotic Invention System 2.0

Project Ideas• Anders Project ideas (scanner, fan)

– http://www.norgesgade14.dk/legoSider/mindstorm_en.html• Andy’s Page (chess playing robot)

– http://www.artilect.co.uk/lego/default.asp?page=Chess• Buick Music Study (Play MIDI or WAV files)

– http://www.aga.it/%7Eguy/lego/bms.html• Joe’s Nagata’s Mindstorms Gallery (vehicles)

– http://homepage3.nifty.com/mindstorms/– http://members.at.infoseek.co.jp/Milano/studio1.html (movies)

• Mario Ferrari’s Web Pages (piano player, skier, etc)– http://www.marioferrari.org/lego_mindstorm.html

Page 30: Lego Mindstorms Robotic Invention System 2.0

Using Java with LEGO Robots

• Install leJOS (the Java Operating System)– Download from

http://lejos.sourceforge.net/faq.html• Set the system variables• Plug in the IR Tower to the top USB port• Download the firmware using a command

prompt– lejosfirmdl

Page 31: Lego Mindstorms Robotic Invention System 2.0

Setting System Variables

• Create new System Variables– LEJOS_HOME variable to the directory where leJOS

is installed– RCXTTY=USB

• Add to the PATH variable– The Java SDK bin directory– ;%LEJOS_HOME%\bin

• Add to the CLASSPATH variable– ;%LEJOS_HOME%/lib/classes.jar;%LEJOS_HOME

%/lib/pcrcxcomm.jar

Page 32: Lego Mindstorms Robotic Invention System 2.0

Using leJOS

• Import the classes in leJOS– import josx.platform.rcx.*;

• Compile for Java 1.1 using– lejosjc.bat Class.java

• Link together an executable– lejoslink.bat -o Class.bin Class

• Download the executable to the RCX– lejosdl.bat Class.bin

Page 33: Lego Mindstorms Robotic Invention System 2.0

LCD Control

Page 34: Lego Mindstorms Robotic Invention System 2.0

Motor Class– 3 objects are available as public static (class)

variables• Motor.A, Motor.B, and Motor.C

– You make the motor go forward, backward, stop (brake), and float to a stop

– When you start a motor forward it will keep going until you tell it to stop or float to a stop.

– Use Thread.sleep(numMilliseconds) to control how long the motor is moving

– Control how fast the motor moves with • setPower(num) with num from 0 to 7 (fastest)

Page 35: Lego Mindstorms Robotic Invention System 2.0

Motor Test

• Make both A and C motors go forward at power 7 for 1 second

• Stop for 1 second• Have both motors go forward at power 2

for 3 seconds• Float to a stop

Page 36: Lego Mindstorms Robotic Invention System 2.0

leJOS Resources

• Download from– http://lejos.sourceforge.net/

• Tutorial at – http://lejos.sourceforge.net/tutorial/

• Discussion at – http://sourceforge.net/mailarchive/forum.php?

forum_id=552• Books

– http://lejos.sourceforge.net/books.html

Page 37: Lego Mindstorms Robotic Invention System 2.0

FIRST LEGO League

• Robotics competition for a team of kids (ages 9-14) – Up to 10 kids on a team

• Register by Sept 30th– Work for 8 weeks on a challenge

• New one each year– Compete at tournaments Nov – Dec

• Georgia Tech hosted one Jan 15, 2005– Cost (about $600 per team)