85
Basic NXT-G Programming

Basic NXT-G Programming

  • Upload
    chika

  • View
    59

  • Download
    0

Embed Size (px)

DESCRIPTION

Basic NXT-G Programming. NXT-G. Sequence Beams Blocks Structures (special blocks) Wires (connect ports on blocks & structures). Forward 2, Back 2, Talk. 01-Basic Program.rbt. Save this program!. Forward 2, Back 2, Talk. Save this program!. Loop 36 times. - PowerPoint PPT Presentation

Citation preview

Page 1: Basic NXT-G Programming

Basic NXT-G Programming

Page 2: Basic NXT-G Programming

NXT-G

•Sequence Beams•Blocks•Structures (special blocks)

•Wires (connect ports on blocks & structures)

Page 3: Basic NXT-G Programming

Forward 2, Back 2, Talk

01-Basic Program.rbt

Save this program!

Page 4: Basic NXT-G Programming

Forward 2, Back 2, Talk

Save this program!

Page 5: Basic NXT-G Programming

Loop 36 times

02 Simple Structure - Loop.rbt

Save this program!

Page 6: Basic NXT-G Programming

Loop 36 times

Save this program!

Page 7: Basic NXT-G Programming

Branch on a Variable & Use Wires

• What's a “Variable”?– It's a box to put something in, like text, a

number, or a true/false value.• Why might we use a “Variable”?

– To reference it later in the program.• What is a “Compare” block?

– A “Compare” block tests the value of a numeric variable against a another number.

• When might we use a “Compare” block?– To test the value of a sensor...

Page 8: Basic NXT-G Programming

Branch on a Variable & Use Wires

03 Variables.rbt03-Variables.rbt

Page 9: Basic NXT-G Programming

Branch on a Variable & Use Wires

Page 10: Basic NXT-G Programming

Branch on a Sensor & Use Wires

03.1-Sensor And Branch.rbt

Extra Credit!

Page 11: Basic NXT-G Programming

Branch on a Sensor & Use Wires

Page 12: Basic NXT-G Programming

Design Principles & Strategies

Page 13: Basic NXT-G Programming

Design Principles & Strategies

•KISS•Tool Design First – Then Program•Leapfrog Development•Competitive Development•Test Repeatedly•Change 1 Small Thing at a Time•Test Repeatedly

Page 14: Basic NXT-G Programming

Design Principles & Strategies

•KISS•Quick Attachment Switching•Specialized Tools•Test Repeatedly•Stiff & Stable is Repeatable and Reliable•Leverage•Change 1 Small Thing At A Time•Repetitive Testing•Slow Motion Video

Page 15: Basic NXT-G Programming

Tactical Techniques

•Standard Starting Location•Standard Starting Configuration•Straight Lines using Move Blocks•Pivot Turns (some folks call these Swing Turns)

Page 16: Basic NXT-G Programming

Basic Techniques

Page 17: Basic NXT-G Programming

Incremental Development with Bluetooth

Where to go from here?

Page 18: Basic NXT-G Programming

Incremental Development with Bluetooth

•Now we will write a program together using Bluetooth incremental development

– Move Forward– Lower Arm Trapping 3 Pylons and Blue Ring– Backup to Base– Raise Arm Back to Starting Position

Page 19: Basic NXT-G Programming

Incremental Development with Bluetooth

Mission 1 - Basic

Page 20: Basic NXT-G Programming

Incremental Development with Bluetooth

Page 21: Basic NXT-G Programming

Precise TurnsLeft Face!

•Hold one wheel still•Drive with the other wheel•Make your drive in two parts, slow then fast•You’re not done until you have strung it together with the moves before and after the turn

Page 22: Basic NXT-G Programming

Precise TurnsLeft Face!

04-Left Face.rbt

Page 23: Basic NXT-G Programming

Precise TurnsLeft Face!

Page 24: Basic NXT-G Programming

VideoWhat’s really going on here?

•Once we looked at a slow motion video of our robot we found out we hadn’t really been seeing what our robot was doing…

Page 25: Basic NXT-G Programming

VideoWhat’s really going on here?

•We're going to show you:– Video at full speed– Video in slow motion– Video in frame by frame– Watch: 1 House & Core Rig Slow Mo video.MP4

Page 26: Basic NXT-G Programming

SensorsWhen should I stop?

•Go Forward until you see dark–Use a move and a wait block–Then add a stop block–Check your light levels

Page 27: Basic NXT-G Programming

SensorsWhen should I stop?

Page 28: Basic NXT-G Programming

SensorsWhen should I stop?

Page 29: Basic NXT-G Programming

SensorsWhen should I stop?

•Go Forward until you see dark–Use a move and a wait block–Then add a stop block–Check your light levels–The wait until sensor block is one way to stop on a line... Our way is better when you need both power and accuracy.–Now we'll build an improved loop checking sensor every 6 degrees–Then try changing the number of degrees

Page 30: Basic NXT-G Programming

SensorsWhen should I stop?

Page 31: Basic NXT-G Programming

SensorsWhen should I stop?

Page 32: Basic NXT-G Programming

Medium Techniques

Page 33: Basic NXT-G Programming

MyBlocksGood things come in small packages

•Take our “Go to Dark” loop program and make it a MyBlock•Combine a move with our “Go to Dark” MyBlock

Page 34: Basic NXT-G Programming

MyBlocksGood things come in small packages

Page 35: Basic NXT-G Programming

MyBlocksGood things come in small packages

Page 36: Basic NXT-G Programming

MyBlocksGood things come in small packages

Page 37: Basic NXT-G Programming

MyBlocksGood things come in small packages

Page 38: Basic NXT-G Programming

MyBlocksGood things come in small packages

Page 39: Basic NXT-G Programming

Multi-Threaded Programmingwalking and chewing gum at the same time

•Advance on the blue ring while lowering the arm to just above the blue ring.•Continue to move forward slowly while lowering the arm the rest of the way.•Return to base.

Page 40: Basic NXT-G Programming

Multi-Threaded Programmingwalking and chewing gum at the same time

Page 41: Basic NXT-G Programming

Multi-Threaded Programmingwalking and chewing gum at the same time

Page 42: Basic NXT-G Programming

More Tactical Techniques

•Standard Starting Location•Standard Starting Configuration•Straight Lines using Move Blocks•Pivot Turns•1-Count Loops to Synchronize Threads•“Crowbars” to pry open loops and switches•Use your own loops to check sensors and control movement for best accuracy•CONTROL your own destiny by writing your own code

Page 43: Basic NXT-G Programming

Multi-Threaded Programmingwalking and chewing gum at the same time

Page 44: Basic NXT-G Programming

HappyBirthday

Kate

Page 45: Basic NXT-G Programming

Advanced Techniques

Page 46: Basic NXT-G Programming

MyBlocks with Parameters“Siri, take me here!”

• Parameters make MyBlocks reusable in more situations

• MyBlocks become adaptable• You only program 1 MyBlock that is

applicable in different scenarios

Page 47: Basic NXT-G Programming

MyBlocks with Parameters“Siri, take me here!”

• Take our two part turn and add direction math

• Determine desired direction• Add a variable for input• Cut the wire and make a MyBlock!

Page 48: Basic NXT-G Programming

MyBlocks with Parameters

Page 49: Basic NXT-G Programming

Sensor CalibrationIs it night or just cloudy?

•First we'd like to explain the Calibrate Block•Then we'll show you how we use it in our Calibrate program•We've posted “Cougar Calibrate.rbc”, our calibrate program, on CougarRobot.com•Why is Cougar Calibrate better?

Page 50: Basic NXT-G Programming

Sensor CalibrationIs it night or just cloudy?

Page 51: Basic NXT-G Programming

Sensor CalibrationIs it night or just cloudy?

Page 52: Basic NXT-G Programming

Position RegistrationOur Favorite, X marks the spot

How should I register my position?1.Register using touch2.Register using light3.Register using odometry

What should I register my position against?1.The strategic object you are manipulating2.The mat3.Field walls

Page 53: Basic NXT-G Programming

Position RegistrationOur Favorite, X marks the spot

•Back to Wall

Page 54: Basic NXT-G Programming

Position RegistrationOur Favorite, X marks the spot

Page 55: Basic NXT-G Programming

Position RegistrationOur Favorite, X marks the spot

•Back to Wall•Back to Line

Page 56: Basic NXT-G Programming

Position RegistrationOur Favorite, X marks the spot

Page 57: Basic NXT-G Programming

Position RegistrationOur Favorite, X marks the spot

•Back to Wall•Back to Line•Advance to Line

Page 58: Basic NXT-G Programming

Position RegistrationOur Favorite, X marks the spot

Page 59: Basic NXT-G Programming

Position RegistrationOur Favorite, X marks the spot

•Back to Wall•Back to Line•Advance to Line•We've posted “Cougar Advance To Line.rbt” on our website CougarRobot.com.

Page 60: Basic NXT-G Programming

Dependent Threads & Synchronizationthrowing the newspaper while riding your bike

•Let's take a look at our Final Mission, CA Black 5-8 Timmy and Friends!•The turn in front of the dynamometer is now jam-proof!•2 Slow Motion Video How it's supposed to work.MP4•3 Slow Motion Video How it sometimes failed.MP4•4 Slow Motion Video How we fixed it.MP4

Page 61: Basic NXT-G Programming

Dependent Threads & Synchronizationthrowing the newspaper while riding your bike

Page 62: Basic NXT-G Programming

Dependent Threads & Synchronizationthrowing the newspaper while riding your bike

•Our Grey Balls mission from Climate Connection really showed smoothness of dependent threads.•5 Philip & Jacob 400 point run - FLL First Lego League 2009 Climate Connections Robot Run.mp4

Page 63: Basic NXT-G Programming

Dependent Threads & Synchronizationthrowing the newspaper while riding your bike

Page 64: Basic NXT-G Programming

Master Programs/Menus/ScriptingYour wish is my command

•We use a Master Program– We have a plan and a script– FIRST changed the rules because of the

Cougars's mission checklist!

Page 65: Basic NXT-G Programming

Master Programs/Menus/ScriptingYour wish is my command

Page 66: Basic NXT-G Programming

Master Programs/Menus/ScriptingYour wish is my command

•We use a Master Program– We have a plan and a script– FIRST changed the rules because of the

Cougars's mission checklist!– Our Master Program helps us follow our plan

and do it quickly

Page 67: Basic NXT-G Programming

Master Programs/Menus/ScriptingYour wish is my command

•Let's build a simple sequencer.– Make 01-Basic into a MyBlock– Make 02-Loop 36 times into a MyBlock– Make 5.4 Go To Dark into a MyBlock

Page 68: Basic NXT-G Programming

Master Programs/Menus/ScriptingYour wish is my command

•Let's build a simple sequencer.– Start a new program– Drop the 3 MyBlocks onto a sequence beam– Add wait blocks– Add a sound at the start

Page 69: Basic NXT-G Programming

Master Programs/Menus/ScriptingYour wish is my command

Page 70: Basic NXT-G Programming

Master Programs/Menus/ScriptingYour wish is my command

•Now Check out a Full Featured Sequencer...

Page 71: Basic NXT-G Programming

Master Programs/Menus/ScriptingYour wish is my command

Page 72: Basic NXT-G Programming

Master Programs/Menus/ScriptingYour wish is my command

•For the Smart Move challenge we improved our Master Program by altering “LB or EB” program.•LB (left button) is repeat last mission•EB (enter button) is run next mission.•We added RB (right button) which jumps ahead one mission in the sequence•Our new program is “LB or EB or RB”

Page 73: Basic NXT-G Programming

Master Programs/Menus/ScriptingYour wish is my command

Page 74: Basic NXT-G Programming

Master Programs/Menus/ScriptingYour wish is my command

Page 75: Basic NXT-G Programming

TimersWhen will this match be over?

•Here's how we used a timer in our master program during Climate Connections

Page 76: Basic NXT-G Programming

TimersWhen will this match be over?

Page 77: Basic NXT-G Programming

TimersWhen will this match be over?

Page 78: Basic NXT-G Programming

Miscellaneous

TIME is your most valuable resource

Make choices that put you in CONTROL

Page 79: Basic NXT-G Programming

Miscellaneous

60ish blocks per program

At roughly 60 blocks per program the NXT-G editor will start to get really flakey

Page 80: Basic NXT-G Programming

Miscellaneous

Know how many degrees or

rotations per inch

You should be able to predict the numbers to feed to a move block by using a tape measure.

You should also be able to predict the numbers to make the robot turn 90 degrees.

Page 81: Basic NXT-G Programming

Miscellaneous

Innovate Early

Consolidate Late

Page 82: Basic NXT-G Programming

Miscellaneous

Version control(can use “Pack and Go”)

Backup solution (can use 7-Zip)

Page 83: Basic NXT-G Programming

Resources• http://www.cougarrobot.com• http://nxtasy.org• http://www.teamhassenplug.org/• http://www.teamhassenplug.org/NXT/NXTGTips/• http://www.teamhassenplug.org/NXT/NXT-GCodeIndex.html• http://mindstorms.lego.com/nxtlog/ProjectDisplay.aspx?

id=c3dcfabe-9802-444d-8b76-c7e23d41f9b8• http://www.nxtasy.org/repository/nxt-g-blocks/•Brian Davis Ph.D., Adjunct Assistant Professor at Indiana University South Bend, & LEGO MDP

Page 84: Basic NXT-G Programming

Put It All Together!

Page 85: Basic NXT-G Programming

Our Thanks to...