North Alabama Robotics Team Monkey Madness

49
1 North Alabama Robotics Team Monkey Madness FLL Intro Programming FLL Intro Programming Workshop Workshop 2012 2012 Kim Daugherty Kim Daugherty [email protected] [email protected] 256-955-9521 256-955-9521

description

North Alabama Robotics Team Monkey Madness. FLL Intro Programming Workshop. 2012. Kim Daugherty [email protected] 256-955-9521. Goals. Present NXT-G programming concepts that you can teach your FLL team Conduct a hands-on NXT workshop to facilitate learning - PowerPoint PPT Presentation

Transcript of North Alabama Robotics Team Monkey Madness

Page 1: North Alabama Robotics Team Monkey Madness

1

North Alabama Robotics Team Monkey Madness

FLL Intro Programming FLL Intro Programming WorkshopWorkshop

20122012

Kim DaughertyKim [email protected]@gmail.comm

256-955-9521256-955-9521

Page 2: North Alabama Robotics Team Monkey Madness

2

Goals

Present NXT-G programming concepts that you can teach your FLL team

Conduct a hands-on NXT workshop to facilitate learning

Provide tips and strategies that have been learned through trial and error over five years

Page 3: North Alabama Robotics Team Monkey Madness

3

Agenda Introductions Our motivation NXT introduction Basic movement Sensors Control flow (loops and switches) Debugging

Page 4: North Alabama Robotics Team Monkey Madness

4

Our Motivation To help Alabama FLL teams be

competitive at the national (US Open) and international level (World Festival) Robot design is typically not an obstacle for

teams – programming is… Teams can design robust software if they

are given a few tips… To help teams have a great FLL

experience so they consider continuing into FTC/FRC

Page 5: North Alabama Robotics Team Monkey Madness

5

NXT Introduction Programming window Version checking NXT brick basics

Page 6: North Alabama Robotics Team Monkey Madness

6

Start a New Program

1. Enter “MoveTest”

TIP: Use descriptive program names written in mixed case

2. Click on Go to open program

Page 7: North Alabama Robotics Team Monkey Madness

7

Programming Window 1 of 2

Common palette

Move

Record/play

Sound

Display

Wait

Loop

Switch

TIP: The common palette is usually sufficient for basic navigation

Page 8: North Alabama Robotics Team Monkey Madness

8

Programming Window 2 of 2

Complete palette

Common

Action

Sensor

Flow

Data

Advanced

TIP: The complete palette contains advanced commands

Move

Record/play

Sound

Display

Wait

Loop

Switch

Page 9: North Alabama Robotics Team Monkey Madness

9

Comment and Pan Tools

Comment tool allows you to add documentation

TIP: Document your program so you can remember what it does

Pan tool allows you move the screen around

Pointer tool allows you to select and insert blocks

Page 10: North Alabama Robotics Team Monkey Madness

10

NXT Version Number

New Program

V2.1.f3

Patch f3 located at http://education.lego.com/en-gb/preschool-and-school/secondary-11-18/11plus-lego-mindstorms-education/downloads/

Help->About

TIP: Patch f3 reportedly fixes the Error 1003 Broken Wire problem in NXT 2.x

Page 11: North Alabama Robotics Team Monkey Madness

11

Firmware Version NumberTools>Update NXT Firmware…

Version 1.31 is the latest

TIP: Check the NXT firmware on the brick by going to Settings->NXT Version

Page 12: North Alabama Robotics Team Monkey Madness

12

Before We Start The NXT

Outputs for Motors/Lights (A,B,C) Inputs for Sensors (1,2,3,4) Buttons (Enter, Back, Left, Right) USB port

Motors Middle (A), Left (B), Right (C)

Sensors Light sensor (1), touch sensor (3), color

sensor, ultrasonic sensor, rotation sensor

B C

A

1 – Light3 – Touch

Page 13: North Alabama Robotics Team Monkey Madness

Practice Robot

13Robot instructions obtained from Oregon Robotics Tournament and Outreach Program (ORTOP) http://www.ortop.org/Workshops/index2011.html

Horizontal mount points

High torque for lifting (small gear connected to large gear)

Two light sensors

Caster wheel

Good balance and weight distribution over drive wheels

Low center of gravity for stability

Page 14: North Alabama Robotics Team Monkey Madness

14

Name Your Robot

This button brings up the NXT window

This is where you name the brick

This tab allows you to delete files from the brick

TIP: You can delete sound files and demo programs to free up space on the NXT

Connect robot to laptop using USB cable

Page 15: North Alabama Robotics Team Monkey Madness

15

Basic Movement The easiest way to get around is the

Move block This is the block you will use the most

Page 16: North Alabama Robotics Team Monkey Madness

16

Most Basic Command

1. Click here and drag a Move block to the Start area

Speed control

Degrees OR rotations should be used; rarely use seconds

It is usually better to brake than coast

Steering control

TIP: Get familiar with all aspects of the Move command

Motor selection

2. Click here to download the program to the brick

Direction control

B C

A

1 – Light3 – Touch

Page 17: North Alabama Robotics Team Monkey Madness

17

Run the Program First menu is “My Files” Select with orange button Second menu is “Software Files” Select with orange button Use arrow keys to find “MoveTest” Select with orange button Press orange button to Run

B C

A

1 – Light3 – Touch

Page 18: North Alabama Robotics Team Monkey Madness

Two Ways to Turn Use slider bar on steering control

Middle position means robot will go straight The further the slider is from the middle (but not all

the way to one side), the sharper the curve will be (swing turn)

If the slider is all the way to one side, the robot will turn in place by turning one wheel forward and the other backward

Make sure motors on steering control set to B and C Move one wheel only

Click on either port B or C, but not both Only one wheel will turn; this is a pivot turn

18TIP: Pivot turns are the most precise, but swing turns are faster

B C

A

1 – Light3 – Touch

Page 19: North Alabama Robotics Team Monkey Madness

19

Experiment with Move Write a program to:

Move forward 100% speed for 2 rotations Make a right pivot turn at 75% speed (hint 390

deg) Move backward 50% speed for 360 degrees Make a left swing turn at 75% speed for 1

second Turn in place clockwise all the way around at

25% speed (hint 800 deg) Move forward 100% speed for 1 rotation

Observations? What could improve repeatability and

accuracy?

B C

A

1 – Light3 – Touch

Page 20: North Alabama Robotics Team Monkey Madness

20

Wait Block

TIP: Waiting a short time after each move improves repeatability and accuracy

B C

A

1 – Light3 – Touch

1. Click here, select 1st block (time), and drag after Move block

2. Enter 0.25 seconds

3. Repeat until 5 Wait blocks have been added

Page 21: North Alabama Robotics Team Monkey Madness

21

Help Screen

Move cursor over block to get short description in this window

TIP: Access help for selected block by clicking on “More help” on NXT right bottom

Click here to get detailed help screen

Page 22: North Alabama Robotics Team Monkey Madness

For Improved Navigation Use Wait blocks after Move blocks to

allow robot motion to completely stop Start in the same position in base each

time; it is common to have the robot bumper pressed again the wall1

Use pivot turns instead of swing turns Don’t exceed 50% power when turning

22

1 In previous years, FLL mat is centered East West and flush with South wall; distance between East or West wall and mat can vary on different tables

Page 23: North Alabama Robotics Team Monkey Madness

Sensors Allows the robot to feel (touch),

see (light), hear (sound), and measure distance (ultrasonic)

Are often used to determine when to stop moving

23TIP: Light and touch sensors are more useful in FLL than ultrasonic and sound

B C

A

1 – Light3 – Touch

Page 24: North Alabama Robotics Team Monkey Madness

24

Developing an algorithm An algorithm is a step-by-step logical

sequence Example: Move forward until robot runs

into wall Step 1: Turn on motors 100% speed Step 2: Wait until touch sensor is

pressed Step 3: Turn off motors

TIP: It is a good idea to write an algorithm before you start writing the program

B C

A

1 – Light3 – Touch

Page 25: North Alabama Robotics Team Monkey Madness

Touch Sensor

25

B C

A

1 – Light3 – Touch

2. Click here and drag a Move block to the Start area

1. Click here to start a new program

3. Select Unlimited for Duration of Move

4. Click here, select 2nd block (touch), and drag next to Move block

5. Change port to 3

8. Save program and name it TouchTest

9. Click here to download the program to the brick

6. Click here and drag a Move block next to Wait block

7. Select Stop for direction

TIP: Be sure to stop the motors after a Wait block

Page 26: North Alabama Robotics Team Monkey Madness

26

Experiment with Touch Write a program to:

Move forward 100% speed until robot touches wall

Move backwards 50% speed for 2 rotations Make a right turn at 50% speed (Hint 390

deg) Move forward 100% speed until robot

touches wall Move backwards 50% speed for 2 rotations Make a right turn at 50% speed (Hint 390

deg) Move forward 100% speed until robot

touches wall Move backwards 50% speed for 2 rotations Make a right turn at 50% speed (Hint 390

deg) Observations?

B C

A

1 – Light3 – Touch

Page 27: North Alabama Robotics Team Monkey Madness

Questions? Did you use copy and paste? Did you remember to add waits

after each move command?

27

Page 28: North Alabama Robotics Team Monkey Madness

One Way to Do It

28

Repeat these blocks 3 times

B C

A

1 – Light3 – Touch

TIP: Copy and paste can save you a lot of time

Move forward 100% speed unlimited

Move backwards 50% speed for 2 rotations

Right pivot turn 50% speed for 390 degrees

Page 29: North Alabama Robotics Team Monkey Madness

The Loop Block (1 of 2)

29

B C

A

1 – Light3 – Touch

1. Click here and drag a Move block next to Wait block

2. Set Control to Count and set Count to 3

TIP: The Loop block allows you to repeat commands

3. Make sure Counter is not checked

Page 30: North Alabama Robotics Team Monkey Madness

The Loop Block (2 of 2)

30

B C

A

1 – Light3 – Touch

1. Click and drag these blocks inside the Loop block

2. Delete the remaining 12 blocks

TIP: Wait for the Loop block to expand before you let go of the blocks

3. Save, download, and run TouchTest

Page 31: North Alabama Robotics Team Monkey Madness

Reusing Blocks You may have a specific block or a

sequence of blocks that you want to repeat many times in the program Wait time block a) Move unlimited block followed by b) Wait

sensor block followed by c) Move stop block followed by d) Wait time block

One or more blocks can be captured in a MyBlock which can be reused

31

Page 32: North Alabama Robotics Team Monkey Madness

Create MyBlock (1 of 4)

32

B C

A

1 – Light3 – Touch

TIP: Use mixed case and name MyBlock something descriptive

1. Select Wait block and then click on Create My Block

2. Name block WaitTimeBlock and click Finish

Page 33: North Alabama Robotics Team Monkey Madness

Create MyBlock (2 of 4)

33

B C

A

1 – Light3 – Touch

TIP: When you edit a MyBlock, save it and download the main program

1. Select Custom palette

3. Select WaitTimeBlock and drag to previous locations of Wait blocks

2. Delete these Wait blocks

4. You can edit the MyBlock by double clicking on it

Page 34: North Alabama Robotics Team Monkey Madness

Why is this Better? Change the wait from .25 seconds

to 1.0 seconds; you only need to change it in the MyBlock instead of changing every Wait block

Don’t download the MyBlock; download the program that uses the MyBlock

34

Page 35: North Alabama Robotics Team Monkey Madness

Create MyBlock (3 of 4)

35

B C

A

1 – Light3 – Touch

TIP: When selecting blocks in a Loop, click outside the loop then drag

1. Select first four blocks and then click on Create My Block

2. Name block MoveTouchBlock and click Finish

Page 36: North Alabama Robotics Team Monkey Madness

Create MyBlock (4 of 4)

36

B C

A

1 – Light3 – Touch

TIP: There is no way to remove the space without redoing the Loop block

Page 37: North Alabama Robotics Team Monkey Madness

You Now Have Two MyBlocks

WaitTimeBlock Wait a specified time

MoveTouchBlock a) Move unlimited block b) Wait for touch sensor block c) Move stop block d) WaitTimeBlock

37TIP: MyBlocks are useful for reusing specific blocks or sequences of blocks

Page 38: North Alabama Robotics Team Monkey Madness

Light Sensors

38

Optimum height above mat is between ¼ and 1 inch; too low saturates sensor and too high gets poor reading of reflected light

Left light sensor connected to port 1

TIP: Light sensors should be calibrated and shielded from ambient light

• Turn on robot• Use arrow keys to move to “View”• Select with orange button• User arrow keys to find “Reflected Light”• Select with orange button• Use arrow keys to find “Port 1”• Select with orange button• Read different areas of the mat – values will be 0 to

100

Page 39: North Alabama Robotics Team Monkey Madness

Light Sensor Readings Percent Mode:

5% = lowest dark, 100% = very bright

Reflected Light Mode: shines a red light

The light can be turned off – detecting ambient light (surrounding light)

39TIP: The light sensor reads reflected light over an area determined by its height

Page 40: North Alabama Robotics Team Monkey Madness

Simple Line Following Does not actually follow the line…

Then what does it follow? HINT: Line following would NOT

work well on a very thin line

40

Page 41: North Alabama Robotics Team Monkey Madness

41

Another Algorithm Follows Left Edge of Line Two states: Left of desired position, Right of

desired position Determine state to control robot movement

If Sensor1 > Boundary (Left) Set Motor B to 60 Stop Motor C

If Sensor1 < Boundary (Right) Set Motor C to 60 Stop Motor B

B C

1 – Light3 – Touch

TIP: It is a good idea to write an algorithm before you start writing the program

Page 42: North Alabama Robotics Team Monkey Madness

Line Following

42TIP: Make sure to set motor ports correctly when line following

2. Click and drag Loop block

3. Click Switch block and put into Loop

4. Select Control to be Sensor and Sensor to be Light Sensor

5. Make sure Port is 1

5. Add Move blocks

1. Start new program and name it LineFollow

Page 43: North Alabama Robotics Team Monkey Madness

Experiment with Line Following Write a program to:

Test line following at 60 percent speed

Test line following at 40 percent speed

Test line following at 100 percent speed

Observations?

43

Page 44: North Alabama Robotics Team Monkey Madness

Line Following Observations Faster line following makes large

swerves back and forth and can lose the line

Slower line following is smoother It is good to have a strategy to end

line following

44

Page 45: North Alabama Robotics Team Monkey Madness

End Line Following

45TIP: Use the rotation sensor to stop line following after a specified distance

1. Click on Loop block

2. Select Control to be Sensor and Sensor to be Rotation Sensor

3. Make sure Port is B

4. Set Until to be > 500 degrees

Page 46: North Alabama Robotics Team Monkey Madness

Put it All Together Use Line Following, WaitTimeBlock,

and MoveTouchBlock to navigate robot from start of line to target area

46

Page 47: North Alabama Robotics Team Monkey Madness

A Possible Solution (1 of 2) Line follow for 1150 degrees at 60% speed WaitTimeBlock Right pivot turn at 50% speed for 390 degrees WaitTimeBlock MoveTouchBlock Move backward 50% speed for 1 rotation WaitTimeBlock Left pivot turn at 50% speed for 390 degrees WaitTimeBlock MoveTouchBlock

47

Page 48: North Alabama Robotics Team Monkey Madness

A Possible Solution (2 of 2)

48

Page 49: North Alabama Robotics Team Monkey Madness

Resources usfirst.org/roboticsprograms/fll – Official FLL site www.alabamafll.com – Official Alabama FLL site www.nxtprograms.com – NXT designs (not all robots) and sample

programs www.techbrick.com – Coaching tips and challenge worksheets www.forums.usfirst.org/forumdisplay.php?f=24 – Get help from the

FLL community; must register to post www.teammonkeymadness.com – Our team site www.ortop.org/Workshops/index2011.html – Coaches workshop

materials www.ortop.org/NXT_Tutorial/index.html – Online NXT tutorial www.education.rec.ri.cmu.edu/content/lego/curriculum/index.htm –

Carnegie Mellon Robotics Academy www.hightechkids.org/for-teams/coaches-library – Coaches

materials http://www.legoeducation.us/eng/characteristics/ProductLine~LEGO

%20Mindstorms%20Education – NXT Education Base set and Resource set

49TIP: Be positive and always set a good example for your team