70 advancedprogrammingandbestpractices2013!10!05

Upload: cesarbosch

Post on 28-Feb-2018

215 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    1/118

    Bill AucoinMaryland State FLL Committee

    University of Maryland, BaltimoreCounty (UMBC)

    October 5, 2013

    FLL Advanced Programming& Best Practices Workshop

    http://www.legoeducation.com/ImagePopup.aspx?reftype=1&refid=1275&defimg=3662&pop=1
  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    2/118

    v3.0

    Guidelines For Today

    Feel free to enter and leave at any time quietly The toilets are out the back of the auditorium and to the right

    This is intended to be a facilitated discussion, not a one-way lecture

    Group participation is expected at all times!

    This discussion is intended to stand alone

    We apologize if some of the topics you have heard already

    The target audience is all types of coaches: rookie to expert

    We will avoid specific discussions of this years challenge andstrategies for each mission

    Feel free to discuss that outside of this clinic

    3

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    3/118

    Introductions andAdministrivia

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    4/118

    v3.0

    Dont Be Worried If You Feel That You DontKnow Everything About FLL and Robotics!

    We are a team.

    We do the work to find solutions with guidance from our coaches andmentors.

    We know our coaches and mentors don't have all the answers; welearn together.

    We honor the spirit of friendly competition.

    What we discover is more important than what we win.

    We share our experiences with others.

    We display Gracious Professionalismand Coopertitionin everythingwe do.

    We have FUN!

    http://www.firstlegoleague.org/mission/corevalues

    http://www.firstlegoleague.org/mission/corevalueshttp://www.firstlegoleague.org/mission/corevalues
  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    5/118

    v3.0

    In The Spirit Of Coopertition, Please ConsiderHelping Other Teams

    Coopertitionis displaying unqualified kindness andrespect in the face of fierce competition

    Coopertitionis founded on the concept and aphilosophy that teams can and should help andcooperate with each other even as they compete

    Coopertitioninvolves learning from teammates

    It is teaching teammates

    It is learning from mentors

    And it is managing and being managed

    Coopertitionmeans competing always, butassisting and enabling others when you can

    8

    http://www.usfirst.org/aboutus/gracious-professionalism

    http://www.usfirst.org/aboutus/gracious-professionalismhttp://www.usfirst.org/aboutus/gracious-professionalismhttp://www.usfirst.org/aboutus/gracious-professionalismhttp://www.usfirst.org/aboutus/gracious-professionalism
  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    6/118

    v3.0

    If You Are A Beginning Team, Be ComfortableWith How Far You Team Can Go

    9

    We are a team.

    We do the work to find solutions withguidance from our coaches and mentors.

    We know our coaches and mentors don'thave all the answers; we learn together.

    We honor the spirit of friendly competition.

    What we discover is more important thanwhat we win.

    We share our experiences with others.

    We display Gracious Professionalism andCoopertitionin everything we do.

    We have FUN!

    http://www.firstlegoleague.org/mission/corevalues

    The topics we discuss today might besomething thing you are already doing,

    something you can do this year, orsomething you should try next year

    You make the choice!

    Regional Qualifier !

    State Tournament !!

    World Festival !!!

    http://www.usfirst.org/aboutus/gracious-professionalismhttp://www.firstlegoleague.org/mission/corevalueshttp://www.firstlegoleague.org/mission/corevalueshttp://www.usfirst.org/aboutus/gracious-professionalism
  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    7/118v3.010

    It Is Up To The Individual Coaches On How ToTeach/Apply These Ideas With Their Teams

    Please try to make FLLa learning experiencefor your teams!

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    8/118v3.0

    Agenda

    Start End Topic

    1:00 PM 3:00 PM FLL Advanced Programming and Best Practices

    3:00 PM ??? Open Questions and Answers

    Topics

    Sensors(including Wait For Blocks and Sensor Calibration)

    Squaring Up

    Program Flow Control(including Loops and Switch Blocks)

    Commenting and Printing Your Programs

    MyBlocks Master Programs or Sequencers

    Moving and Turning

    (including Motor Blocks and Move Blocks)

    Base Operations

    (including Starting Positions and Attachments)

    Motor Reset Blocks

    Multiple Sequence Beams

    Data Wires(including Constants, Variables)

    Generic Tips and Recommendations

    Line Following Other References (Books, Websites, etc.)

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    9/118

    Sensors

    (including Wait For Blocks

    and Sensor Calibration)

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    10/118v3.0

    Cougar Robotics Has Offered What They ConsiderTo Be A Better Way To Wait For Sensor

    13

    http://www.cougarrobot.com

    04 WaitForDark.rbt

    Author: RobotBillMD

    Revision: 03

    Required Sensors:

    Port 3 - Light Sensor

    This program drives forward until it detects a black line.

    05-WaitForDark.rbt

    Author: RobotBillMDRevision: 05

    Required Sensors:

    Port 3 - Light Sensor

    This program drives forward until it detects a black line. It checks for the

    line continually (every 6 degrees) vs. continuously.

    Credits: This program is adapted from the program provided by Cougar

    Robotics

    http://www.cougarrobot.com/index.php?option=com_content&view=category&layout=blog&id=78&Itemid=118

    Give these a try to see which ofthese programming styles work

    better for you

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    11/118v3.0

    Wait For NXT Buttons: Can Be Used For OperatorInteraction

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    12/118

    Back To Agenda

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    13/118

    Program Flow Control

    (including Loops and

    Switch Blocks)

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    14/118

    Repeated Code Execution

    Loop Blocks

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    15/118v3.0

    Loop Block: Commonly Used When ExecutingPortions Of Code When Waiting For A Condition

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    16/118v3.0

    Loop Block: The Loop Will Run Continuously UntilThe Selected Condition Is Met

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    17/118v3.0

    Here Is A Way To Ramp Up Your Speed

    20

    Use the value of the loopcounter to control the

    motor power

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    18/118

    Conditional Program

    Execution

    Switch Blocks

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    19/118v3.0

    Switch Block: Executes Different Sequence BeamsDepending On A Condition/Sensor

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    20/118v3.0

    You Can Nest Switch Blocks For Extra Logic

    23

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    21/118v3.0

    You Can Use Data Wires And Values To ControlThe Switch Block

    24

    Three Values and the defaultcondition is 2 (value = 20)

    Set default button

    Add or remove conditions

    Flat view turned off

    Note: This would NOT worksince I never connected thesensor to the switch block! Oops

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    22/118

    Back To Agenda

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    23/118

    MyBlocks

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    24/118

    v3.0

    My Blocks Can Be Used To Combine CommonSections Of Code Which Is Repeated

    O Of Th B R f O M Bl k I

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    25/118

    v3.0

    One Of The Best References On My Blocks IsOnline at www.NXTprograms.com

    28

    http://www.nxtprograms.com/help/MyBlocks/tutorial.html?r44b=no

    E Y K Th I A i t d With

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    26/118

    v3.0

    Ensure You Know The Issues Associated WithMyBlocks When Using Them

    When you edit a MyBlock, you can affect every program that usesthat MyBlock

    You need to re-download each program that uses the MyBlock to the robotto ensure each program is refreshed

    Downloading the MyBlock does not update the robot

    Deleting or renaming a MyBlock will break any program that usesthe MyBlock

    You need to edit each program that uses the MyBlock with the newlyrenamed Block

    A program and all of the MyBlocks it uses share the same list ofvariables

    Only one copy of a specific MyBlock can run at the same time

    If you need to run the same MyBlock concurrently, copy the MyBlock andgive it a different name

    29

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    27/118

    v3.0

    MyBlocks Are Stored In Their Own Folder

    Moving a file to a different folder with break any program that isusing that block

    Use Pack and Go to transfer programs

    30

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    28/118

    v3.0

    MyBlocks Can Be Broken

    A MyBlock will be broken if it has two data plugs with the samename

    A MyBlock will be broken if it uses data wires and there is a problemwith the data wire connections

    31

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    29/118

    Back To Agenda

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    30/118

    Moving and Turning

    (including Motor Blocks

    and Move Blocks)

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    31/118

    v3.0

    Differences Between Move and Motor Blocks

    Move Block Motor Block

    Number of motorscontrolled

    1, 2 or 3 Only 1 motor per block

    Motor Synchronization? Synchronization & Steering *

    Block to Block ErrorCorrection?

    Block to Block Error Correction Block to Block Error Correction

    Motor Power Control? None If selected, power control willincrease/decrease power tomaintain desired motor rotation

    Motor Action None Ramp Up Ramp Down Constant

    34

    Only if the duration isdegrees or rotations

    * If you choose to control two motors (Example: B & C), the motors will be synchronized* If you select three motors, motors B & C will be synchronized

    l bl h k d h l

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    32/118

    v3.0

    For More Reliable Movements, Use Either Locked-Wheel Turns orMove Blocks With -100,0 or +100 Steering Commands

    35 http://paris.utdallas.edu/IEEE-RS-ATR/document/2009/2009-15.pdfhttp://www.ieeereliability.com/Newsletter/1_2010/Article1.htm

    Recommendations

    Based on this battery-voltageexperiment, we came up with thefollowing recommendation for FLL

    teams when using NXT Softwareto program their LEGO NXTrobots:

    Whenever you use the MOVEblock to control your robot, ensure

    both drive motors maintain thesame power level (e.g. only usesteering values of -100, 0, or+100).

    Tip

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    33/118

    Basic RobotManeuverability

    Move Blocks andMotor Blocks

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    34/118

    v3.0

    Differences Between Move and Motor Blocks

    Move Block Motor Block

    Number of motorscontrolled

    1, 2 or 3 Only 1 motor per block

    Motor Synchronization? Synchronization & Steering *

    Block to Block ErrorCorrection?

    Block to Block Error Correction Block to Block Error Correction

    Motor Power Control? None If selected, power control willincrease/decrease power tomaintain desired motor rotation

    Motor Action None Ramp Up Ramp Down Constant

    41

    Only if the duration isdegrees or rotations

    * If you choose to control two motors (Example: B & C), the motors will be synchronized* If you select three motors, motors B & C will be synchronized

    Carnegie Mellon University Provides A Summary

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    35/118

    v3.0

    Carnegie Mellon University Provides A SummaryOf The Advantages & Disadvantages Of Each

    42

    http://www.education.rec.ri.cmu.edu/downloads/lego/resources/nxt/pdf/Motor%20vs.%20Move%20Blocks.pdf

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    36/118

    v3.0

    Other Move and Motor Block Considerations

    Motor Blocks with its Next Action Parameter set to Constant willapply the specified power level throughout the motion of the motor

    A Move Block will decrease the power near the end of the motion(so it does not overshoot the requested duration)

    A move block is similar to a Constant Motor Block for most of the durationfollowed by a Ramp Down Motor Block in this sense

    43

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    37/118

    Basic RobotManeuverability

    Driving Straight

    What Are Some Considerations For

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    38/118

    v3.0

    What Are Some Considerations ForMaking The Robot Move Straight?

    Matched wheels

    Same diameter? How To Make Your FLL Robot Go Straight on YouTube

    TheFLLCoach (Vienna Robotics)

    http://www.youtube.com/watch?NR=1&v=OlAO9Ho-N58

    Matched motors

    http://www.techbrick.com/Lego/TechBrick/TechTips/NXTCalibration/index.htm

    Programming

    Move vs. motor blocks

    Wheel slippage

    Friction control

    Programming correct/varying power levels

    Using external items

    Line following with a sensor

    Wall following by running along wall45

    Sometimes Features Are Used To Ride Along The

    http://www.youtube.com/watch?NR=1&v=OlAO9Ho-N58http://www.techbrick.com/Lego/TechBrick/TechTips/NXTCalibration/index.htmhttp://www.techbrick.com/Lego/TechBrick/TechTips/NXTCalibration/index.htmhttp://www.youtube.com/watch?NR=1&v=OlAO9Ho-N58
  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    39/118

    v3.0

    Sometimes Features Are Used To Ride Along TheTable Wall

    46

    Be careful of themounting location(s),because the robot might

    have a difficult timemaneuvering away fromthe wall

    Picture courtesy of Marco Ciavolino

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    40/118

    Basic RobotManeuverability

    Robot Turns

    For More Reliable Movements Use Either Locked Wheel Turns or

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    41/118

    v3.0

    For More Reliable Movements, Use Either Locked-Wheel Turns orMove Blocks With -100,0 or +100 Steering Commands

    48

    http://paris.utdallas.edu/IEEE-RS-ATR/document/2009/2009-15.pdfhttp://www.ieeereliability.com/Newsletter/1_2010/Article1.htm

    Recommendations

    Based on this battery-voltageexperiment, we came up with thefollowing recommendation for FLLteams when using NXT Softwareto program their LEGO NXTrobots:

    Whenever you use the MOVE

    block to control your robot, ensureboth drive motors maintain thesame power level (e.g. only usesteering values of -100, 0, or+100).

    Tip

    Experiment with different types of turns and

    see which one is more reliable for you!

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    42/118

    Basic RobotManeuverability

    am I there yet?

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    43/118

    v3.0

    Smooth Running by Dave Parker

    50

    http://forums.usfirst.org/showpost.php?p=53233&postcount=7

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    44/118

    Basic RobotManeuverability

    Navigation

    Where Possible You Should Sense Your Outside

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    45/118

    v3.0

    Where Possible, You Should Sense Your OutsideEnvironment For Navigation

    Dead Reckoning Maneuvering without using sensors to determinewhere you are relative to the positions of the mission models

    Fix Using sensors to determine your position relative to the matandmission models by sensing the outside environment

    52

    Good - Motion with Move/Motor Blocks using time (seconds)

    Sensitive to starting position Sensitive to starting orientation Sensitive to battery voltage

    Better - Motion with Move/Motor Blocks using internal sensors(rotation or degrees)

    Sensitive to starting position Sensitive to starting orientation

    Best - Motion with Move/Motor Blocks while sensing or contactingthe external environment (light, color, touch, ultrasonic, wall,mission model, strategic object)

    Relatively insensitive to starting position and orientation Sensitive to sensor performance and environment

    How Accurately You Need To Navigate Depends

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    46/118

    v3.0

    Initial Guidance

    When leaving the base, sometimes you can be prettyloose with your navigation accuracy

    Midterm Guidance

    While approaching the mission models, you shouldtighten up your navigation accuracy

    Terminal Guidance

    At the very end of your maneuvering, you must ensurethe accuracy and precision of your navigation aresufficient to get the job done

    How Accurately You Need To Navigate DependsOn What Part Of The Mission You Are Executing

    53

    Some of the better teams can program some of their missions such thatthey can loosely place the robot in the base and have the robot figure

    out where it is and where it needs to be after leaving base

    If Your Robot Needs Accurate Alignment In The

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    47/118

    v3.0

    If Your Robot Needs Accurate Alignment In TheBase, Consider An Alignment Fixture

    The attachment needs to bemade out of LEGO-manufacturedpieces [Rule 4]

    The team member must not be

    touching the alignment fixturewhen the robot leaves base[Rule 16]

    54

    Picture courtesy of Marco Ciavolino

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    48/118

    Back To Agenda

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    49/118

    Motor Reset Blocks

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    50/118

    Basic RobotManeuverability

    Motor Reset Blocks

    Move Block Error Correction and Motor Reset

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    51/118

    v3.0

    Move Block Error Correction and Motor ResetBlocks Going 8 Rotations With A Final Brake

    58

    2.2 2.3 2.1 2.0

    8.6

    8.0

    With one move block, the motors

    will go exactly 8 rotations

    2.2 2.3 2.1 1.4

    8.0

    Notes:The last move block in each sequence above uses

    brake, all of the others coast.

    What Are These Motor Reset Blocks Actually

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    52/118

    v3.0

    What Are These Motor Reset Blocks ActuallyDoing?

    Both move and motor blocks will keep track of, and try to correct for,

    accumulated errors in the motors These errors are typically very small when the motor and move blocks include abrake

    When the coast option is used, these errors can build up

    Setting direction to stop does not appear to reset accumulated move ormotor errors

    This might be an error in the NXT-G help

    It is never necessary to use motor reset blocks at the beginning of aprogram

    All motors are automatically reset at the beginning of a program

    Motor reset blocks might be helpful at the beginning of code packaged inmyblocks

    It depends on what the motors are doing prior to and at the beginning of the myblock

    59

    The Bottom Line:

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    53/118

    v3.0

    Experts Recommendation On Motor Reset Blocks

    60

    For most FLL teams, motor reset blocks are not relevant and you never really need

    them If you use brake for all of your movements, as many FLL teams do, accumulated errors are small Its coasting that causes big errors to accumulate

    The main good use of motor reset blocks in FLL is when teams combine more thanone outing into a single longer program (e.g. a menu or sequencer program)

    In this case, it is necessary to coast the motor(s) to make it possible to adjust a motorized attachmentbetween outings, since the program is still running Coasting the motors may cause large errors to accumulate (as the humans move the coasted motors

    between outings) which will forwarded to the next motion, which is definitely not the desired result. In a sequencer, each outing should begin with a Red Reset and end with a Coast for any relevant motors

    Another possibleapplication for the making sure a new motion starts from a fresh

    measurement would be the first movement after pushing into a stationary object withthe intent to stall into it, such as having the robot push into a wall until it stallsAt this point, the rotation counts can be unpredictable (especially left to right), and you want your first

    movement away from the wall to start at zero accumulated error on both sides This is only really applicable if you drive into the wall by rotations/degrees (when seconds is really the

    better choice when a stall is expected) Many teams are likely to use degrees anyway because they dont know any better

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    54/118

    Back To Agenda

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    55/118

    Multiple Sequence

    Beams

    You Can Use Multiple Sequence Beams For

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    56/118

    v3.0

    p qConcurrent Robot Operations

    63

    Move Forward

    While Moving Forward(move block on other

    sequence beam), moveMotor A

    Note: Can do the same thingwith a motor block in serieswith a Move Block as long asyou uncheck the Wait for

    Completion option

    Branch Sequence Beams Can Be Added In The

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    57/118

    v3.0

    qMiddle Of The Main Sequence Beam

    64

    NXT Program Flow Rules

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    58/118

    v3.0

    NXT Program Flow Rules

    The program runs until it reaches the end of all sequence beams ora stop block whichever comes first

    A Block can only start when there are values on all of the input datawires

    A Loop Block or Switch Block cannot start until there are values onall of the data wires that enter the block

    A data wire that starts inside a Loop Block will have a value onlywhen the Loop Block finishes

    A data wire that starts inside a Switch Block will have a value onlywhen the Switch Block finishes

    65

    Be Careful Of Multiple Sequence Beams

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    59/118

    v3.0

    p qKnow The Issues With Them!

    Use multiple sequence beams only when you think you really needthem

    Avoid busy loops where one sequence beam is hogging the CPU

    Dont try to control the same motor on different sequence beams at

    the same time

    Be very careful about data wires going into and out of Loop Blocksand Switch blocks

    Only one copy of a particular My Block can run at a time

    If the same MyBlock is on different sequence beams, it will run the first MyBlock, then run the second instance once the first one completes

    Copy and rename the My Block if you need to run multiple copiesconcurrently

    66

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    60/118

    Back To Agenda

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    61/118

    Data Wires

    (including Constants

    and Variables

    Data Wires Carry Information Between

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    62/118

    v3.0

    Programming Blocks

    You create a data wire by drawing it out of a blocks data hub

    Nearly all of the programming blocks have data hubs and cansupport data wires.

    Open a blocks data hub by clicking the tab at the lower left edge of

    the block after it has been placed on the work area.

    The cursor will change shape when it hovers over or is near a dataplug. If you then press the mouse button and drag to the right, adata wire will unroll that can be connected to a plug on anotherblocks data hub.

    To delete a data wire that stretches from left to right between twodata plugs, click on the right plug

    69

    Data Wires Carry Information Between

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    63/118

    v3.0

    Programming Blocks

    Data wires carrying information to a block (i.e., carrying input) areconnected to the plugs on the left side of its data hub. Data wirescarrying information away from a block to another block (i.e.,carrying output) are connected to the plugs on the right side.

    70

    Data Wires Carry Information Between

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    64/118

    v3.0

    Programming Blocks

    You create a data wire by drawing it out of a blocks data hub

    Nearly all of the programming blocks have data hubs and cansupport data wires

    Open a blocks data hub by clicking the tab at the lower left edge of

    the block after it has been placed on the work area

    The cursor will change shape when it hovers over or is near a dataplug

    If you then press the mouse button and drag to the right, a data wire willunroll that can be connected to a plug on another blocks data hub.

    Deleting a data wire

    To delete a data wire that stretches from left to right between two dataplugs, click on the right plug

    71

    Data Wires Carry Specific Types Of Data

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    65/118

    v3.0

    Data Wires Carry Specific Types Of Data

    Each data wire carries a specific type of data between blocks. Forexample, if a data wire is dragged from a logic plug on a blocksdata hub, it can only be connected to a logic plug on another blocksdata hub.

    Data wires are identified with specific colors:

    wires carrying number data are coloredyellow

    wires carrying logic (true/false) data are colored green

    wires carrying text data are colored orange.

    72

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    66/118

    Back To Agenda

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    67/118

    Line Following

    Follow TheYellow Brick

    RoadBlack Curvy Line

    2 State Line Follower Most Basic

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    68/118

    v3.0

    2 State Line Follower Most Basic

    76

    http://www.nxtprograms.com/line_follower/steps.html Note: For FLL, thesedisplay blocks might be

    an unnecessary waste ofthe NXT memory

    You will not be able toread the display as it isrunning anyway!

    Question: How long willthis line followerprogram follow the line?

    3 State Line Follower Adds Go Straight

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    69/118

    v3.0

    3 State Line Follower Adds Go Straight

    77

    Art of LEGO MINDSTORMS NXT-G Programminghttp://www.nostarch.com/nxt-g.htm

    Go straight if you are justover the edge of the line

    5 State Line Follower

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    70/118

    v3.0

    5 State Line Follower

    78

    http://www.nxtprograms.com/line_follower/steps.html

    Proportional Line Follower

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    71/118

    v3.0

    Proportional Line Follower

    79

    http://www.nxtprograms.com/line_follower/steps.html

    This is getting a bit

    advanced for most FLLteams

    My opinion: If the childrendont understand it, dontuse it

    This Line Follower Sets The B Motor Speed To AC t t d Th ttl th C M t S d

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    72/118

    v3.0

    Constant and Throttles the C Motor Speed

    80

    http://www.hightechkids.org/sites/default/files/CoachingLibrary/fllprogramming_nxtPL_v1.0.1.ppt

    Proportional Integral Differential (PID) Controllers Are OverkillFor Most FLL Applications (But They Show Up At The World

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    73/118

    v3.0

    pp ( y pFestival All The Time)

    81

    http://nxt-progs.blogspot.com/2011/02/line-following-pid-controller.html

    If your team memberscannot understand it,DONT use it.

    There Are Even Fuzzy Logic Line Followers

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    74/118

    v3.0

    There Are Even Fuzzy Logic Line Followers

    82

    http://stefans-robots.net/en/fuzzy-line-follwing-nxt-robot.php

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    75/118

    Back To Agenda

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    76/118

    Squaring Up

    You Can Set The Orientation (Heading) Of TheRobot By Backing Into The Wall Or Using Sensors

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    77/118

    v3.0

    Robot By Backing Into The Wall Or Using Sensors

    You can use either time or multiple touch sensors to back into thewall and orient the robot perpendicular to the wall at any time

    You can detect the motor stall condition to see if you are against ahard object (e.g. the wall)

    You can use light or color sensors to detect the location of a lineand orient the robot perpendicular to the line

    85

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    78/118

    Back To Agenda

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    79/118

    Commenting and

    Printing Your Programs

    What the Heck Is ThisProgram Telling Me?

    Annotations (Comments) In The Programs Help ToDocument The Program (Judges like it too!)

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    80/118

    v3.0

    Document The Program (Judges like it too!)

    Tip

    You can entercomments which aregeneric to the entireprogram by clicking

    on the start icon

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    81/118

    Printing Your Programs

    You Can Print Directly To Your Printer Or CaptureThe Printout Electronically In HTML and RTF

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    82/118

    v3.0

    The Printout Electronically In HTML and RTF

    90

    HTML will create both the HTMLcode as well as pictures of the codeThese pictures can be inserted intomost document editing programs

    Rich Text Format (RTF) can beopened with most common word

    processing programs

    When You Print To A Rich Text Format (RTF), ThisIs What You Get When You Open It In MS Word

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    83/118

    v3.0

    Is What You Get When You Open It In MS Word

    Printing To HTML Will Generate Images WhichCan Be Cut and Pasted Into MS PowerPoint

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    84/118

    v3.0

    Can Be Cut and Pasted Into MS PowerPoint

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    85/118

    Back To Agenda

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    86/118

    Base Operations

    Time in Base is Time

    Not Earning Points

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    87/118

    Back To Agenda

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    88/118

    Master Programs

    or Sequencers

    A Sequencer Program Can Help With Speeding UpYour Pitstops In Base

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    89/118

    v3.0

    Your Pitstops In Base

    97

    00-MasterProgram.rbt

    Author: RobotBillMDRevision: 02

    Required Sensors:

    None (NXT Buttons Used)

    This program is used to execute a set of

    three programs in rapid sequence. Prior to

    each program, this master program waits for

    the orange button to be pressed.

    Credits: This program is adapted from the

    program provided by Cougar Robotics

    http://www.cougarrobot.com/index.php?optio

    n=com_content&view=category&layout=blog

    &id=78&Itemid=118

    http://www.cougarrobot.com

    There are many differentways to implement asequencing program

    Have your team generatetheir own!

    Consider an initial motor reset and a final coast foryour last motor/move blocks when using sequencers

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    90/118

    Back To Agenda

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    91/118

    Other References

    (Books, Websites, etc.)

    The FIRST Forum Is A Good Way To Discuss AndGet UNOFFICIAL Advice On FIRST LEGO League

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    92/118

    v3.0

    Get UNOFFICIAL Advice On FIRST LEGO League

    10

    http://forums.usfirst.org/forumdisplay.php?f=24

    The MD FIRST Website Has Many Great Resources

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    93/118

    v3.010

    http://www.mdfirst.org/programs/first-lego-league/fll-team-resources.html

    Make Sure You Sign Up For TheFLL Coaches List Service (listserv)

    http://www.mdfirst.org/programs/first-lego-league/fll-team-resources.htmlhttp://www.mdfirst.org/programs/first-lego-league/fll-team-resources.html
  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    94/118

    v3.0

    FLL Coaches List Service (listserv)

    10

    https://lists.umbc.edu/lists/info/FLL_Maryland_Coaches

    Our Own Techbrick Provides Resources That AreUsed Worldwide Thanks Marco!

    https://lists.umbc.edu/lists/info/FLL_Maryland_Coacheshttps://lists.umbc.edu/lists/info/FLL_Maryland_Coaches
  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    95/118

    v3.0

    Used Worldwide Thanks Marco!

    10

    http://www.techbrick.com/Lego/Lego2011/Resources/index.html

    Training Is Available Via Carnegie Mellon

    http://www.techbrick.com/Lego/Lego2011/Resources/index.htmlhttp://www.techbrick.com/Lego/Lego2011/Resources/index.html
  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    96/118

    v3.010 LEGO, FIRST and FLL Do Not Endorse Any Specific Tutorial Software

    In Addition To All Of The Other Lists OfResources, Consider Some Of These

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    97/118

    v3.0

    Resources, Consider Some Of These

    Dave Parkers Website A Frequent World Festival Judge

    http://www.nxtprograms.com - Well documented NXT-G code!

    NXT-G Tips & Tricks on Team Hassenplug Website and CodeExamples

    http://www.teamhassenplug.org/NXT/NXTGTips/

    http://www.teamhassenplug.org/NXT/NXT-GCodeIndex.html

    Minnesota FLL High Tech Kids

    http://www.hightechkids.org/

    Northern California FLL - Playing at Learning

    http://www.playingatlearning.org/NCaFLL

    FLL Freak Skye Sweeny

    http://www.fll-freak.com/

    Cougar Robotics (former high performing FLL team)

    http://www.cougarrobot.com/10

    In Addition To All Of The Other Lists OfResources, Consider Some Of These (Continued)

    http://www.nxtprograms.com/http://www.teamhassenplug.org/NXT/NXTGTips/http://www.teamhassenplug.org/NXT/NXT-GCodeIndex.htmlhttp://www.hightechkids.org/http://www.playingatlearning.org/NCaFLLhttp://www.fll-freak.com/http://www.cougarrobot.com/http://www.cougarrobot.com/http://www.fll-freak.com/http://www.playingatlearning.org/NCaFLLhttp://www.hightechkids.org/http://www.teamhassenplug.org/NXT/NXT-GCodeIndex.htmlhttp://www.teamhassenplug.org/NXT/NXTGTips/http://www.nxtprograms.com/
  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    98/118

    v3.0

    esou ces, Co s de So e O ese (Co t ued)

    Oregon State Robotics

    http://www.ortop.org/fll/

    The NXT Step http://www.thenxtstep.blogspot.com/

    10

    Telephone Support Is Available For Technical StuffThey Dont Answer FLL-Specific Questions

    http://www.ortop.org/fll/http://www.thenxtstep.blogspot.com/http://www.thenxtstep.blogspot.com/http://www.ortop.org/fll/
  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    99/118

    v3.0

    y p Q

    LEGO Education

    866-349-5346

    7:30AM to 5:30PM CST

    LEGO Retail

    800-838-9647

    7:30AM to 5:30PM CST

    10

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    100/118

    Popular

    Reference Books

    Jim Kellys Book On FIRST LEGO League Has BeenPretty Popular

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    101/118

    v3.0

    y p

    10

    This book is a bitdated, so rememberthat the officialrulestake precedence

    Programming References In Print

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    102/118

    v3.011

    Additional Print References

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    103/118

    v3.0111

    The LETS GO Boys and Girls Manual Provides ACurriculum and Instructional Exercises For FLL

    http://www.amazon.com/gp/reader/1430229640/ref=sib_dp_pt
  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    104/118

    v3.011

    The Help Provided With The NXT-G Software IsWell Documented and Very Helpful

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    105/118

    v3.0

    y p

    11

    Programming References In Print

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    106/118

    v3.011

    A Very Good (and Free) NXT-G and EV3 Tutorial IsAvailable at STEMcentric.com

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    107/118

    v3.011

    http://www.stemcentric.com/nxt-tutorial/ http://www.stemcentric.com/ev3-tutorial/

    EV3 Tutorial

    LEGO, FIRST and FLL Do Not Endorse Any Specific Tutorial Software

    NXT Tutorial:

    Training Is Available Via Carnegie Mellon

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    108/118

    v3.011 LEGO, FIRST and FLL Do Not Endorse Any Specific Tutorial Software

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    109/118

    Back To Agenda

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    110/118

    Generic Tips and

    Recommendations

    The NXT-G Software Has Default Ports ForVarious Outputs and Sensors

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    111/118

    v3.0

    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)

    3 Light Sensor

    3 Color Sensor4 Ultrasonic Sensor

    11

    While you can reprogram each port for a different device, it is easier to staywith the default outputs and sensors for each port

    If You Have A Block That You Would Like ToReuse, Use Mouse Drag To Replicate

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    112/118

    v3.012

    AB/C 1 2 3 4

    Tip

    3

    For FLL, you should use port 2for the second sensor, if you usemore than one of a certain type

    When Debugging Software, Here Are Some Tips

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    113/118

    v3.0

    Annotate your software so you know where to make any changes

    If you think you have several changes

    Change only one thing at a time

    Start with the changes closest to the beginning of the program

    You can put sound blocks in to have the robot give you audible

    signals when the robot does something Drawback: the soundblocks will take up extra memory in the NXT

    You can put breaks in the code by inserting a motor stop blockfollowed by a wait for block (one possible example provided below)

    12 This could be made into a myblock

    Highly Recommended!File Naming Convention and Regular Backups

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    114/118

    v3.0

    Tell the team to use a standard naming convention

    One I like is For example: wbaPickupMeat_v2

    Create an online backup of the programs every day

    Create an online back up of the profile directory by just copying this folderpasting it to the same folder:

    C:\Documents and Settings\\My Documents\LEGOCreations\MINDSTORMS Projects\Profiles\Default

    I usually do not use different profile names with NXT-G; I use the defaultprofile for the entire team

    This ensures any myblocks etc. are all shared by the team

    See naming convention above to prevent overwriting myblocks

    Periodically, create an offline backup by copying this folder to a USBthumbdrive or equivalent

    12

    Bluetooth Is Disallowed By FLL At The CompetitionBluetooth Can Be Used During Your Practice

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    115/118

    v3.0

    Bluetooth communications are not allowed at the competitions

    Bluetooth can be very helpful during practices

    The NXT Brick has Bluetooth built-in

    You either need a computer with built-in

    Bluetooth or you need a Bluetooth dongle

    Tip

    How To Connect Via Bluetooth to NXT Robots

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    116/118

    v3.0

    Turn on the computer

    Slide in the Bluetooth dongle (some computers do not boot with the dongle installed)

    On the computer, open the Bluetooth Devices window

    If any NXT device is listed in the Devices list, Remove it (otherwise, a 'Line Busy' error will pop uplater). Make sure 'Turn discovery on' is selected. Close the Bluetooth Devices window.

    Switch on the NXT, and select 'Search' from the Bluetooth menu, then 'Connect' to the foundcomputer. Accept the passcode [1234].

    On the PC, a window comes up mentioning that a Bluetooth device is requesting to connect,asking if you want to allow connection. Click on the message to allow connection. A new windowpops up, asking for the passcode. Type in the passcode and click Next. Again, the NXT beeps toverify the passcode; press the orange button on NXT to accept.

    Open the Bluetooth Devices window. Select the NXT device and press 'Properties'. In the new

    window that opens, click the 'Services' tab. Now, Windows starts searching for services that NXTsupports. Select all available services (in my case, two serial ports) and press OK. Windows nowinstalls some new drivers. After that, close the Bluetooth Devices window.

    Now, start the Mindstorms software on the PC, and open the NXT window. Scan for NXT devices,and after finding NXT, click "Connect" (if not already connected during scanning).

    12

    Thanks to Andy Traiger of Vienna Robotics

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    117/118

    Back To Agenda

    Here Is A Way To Detect How Many TouchSensors Are Pressed

  • 7/25/2019 70 AdvancedProgrammingAndBestPractices2013!10!05

    118/118

    Connect all of the touch sensors together using RCX to NXTconversion wires and plug them into one port