fll advanced programming and best practices · to program their lego® nxt robots: whenever you use...

118
Bill Aucoin Maryland State FLL Committee University of Maryland, Baltimore County (UMBC) October 5, 2013 FLL Advanced Programming & Best Practices Workshop

Upload: trinhhuong

Post on 05-Oct-2018

212 views

Category:

Documents


0 download

TRANSCRIPT

Bill Aucoin Maryland State FLL Committee

University of Maryland, Baltimore

County (UMBC) October 5, 2013

FLL Advanced Programming & Best Practices Workshop

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 year’s challenge and strategies for each mission – Feel free to discuss that outside of this clinic

3

Introductions and Administrivia

v3.0

Don’t Be Worried If You Feel That You Don’t Know Everything About FLL and Robotics!

• We are a team.

• We do the work to find solutions with guidance from our coaches and mentors.

• We know our coaches and mentors don't have all the answers; we learn 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 Professionalism® and Coopertition ® in everything we do.

• We have FUN!

7

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

v3.0

In The Spirit Of Coopertition ®, Please Consider Helping Other Teams…

• Coopertition ® is displaying unqualified kindness and respect in the face of fierce competition

• Coopertition ® is founded on the concept and a philosophy that teams can and should help and cooperate with each other even as they compete

• Coopertition ® involves learning from teammates – It is teaching teammates – It is learning from mentors – And it is managing and being managed

• Coopertition ® means competing always, but assisting and enabling others when you can

8

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

v3.0

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

9

• We are a team.

• We do the work to find solutions with guidance from our coaches and mentors.

• We know our coaches and mentors don't have all the answers; we learn 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 Professionalism and Coopertition™ in everything we do.

• We have FUN!

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

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

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

You make the choice!

Regional Qualifier !

State Tournament !!

World Festival !!!

v3.0 10

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

Please try to make FLL a learning experience for your teams!

v3.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.)

Sensors

(including Wait For Blocks and Sensor Calibration)

v3.0

Cougar Robotics Has Offered What They Consider To 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: RobotBillMD Revision: 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 of these programming styles work

better for you

v3.0

Wait For NXT Buttons: Can Be Used For Operator Interaction

Back To Agenda

Program Flow Control

(including Loops and Switch Blocks)

Repeated Code Execution

Loop Blocks

v3.0

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

v3.0

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

v3.0

Here Is A Way To “Ramp Up” Your Speed

20

Use the value of the “loop counter” to control the motor power

Conditional Program Execution

Switch Blocks

v3.0

Switch Block: Executes Different Sequence Beams Depending On A Condition/Sensor

v3.0

You Can “Nest” Switch Blocks For Extra Logic

23

v3.0

You Can Use Data Wires And “Values” To Control The Switch Block

24

Three Values and the default condition is 2 (value = 20)

Set default button

Add or remove conditions

Flat view turned off

Note: This would NOT work since I never connected the sensor to the switch block! Oops

Back To Agenda

MyBlocks

v3.0

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

v3.0

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

28

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

v3.0

Ensure You Know The “Issues” Associated With MyBlocks When Using Them

• When you edit a MyBlock, you can affect every program that uses that MyBlock – You need to re-download each program that uses the MyBlock to the robot

to ensure each program is refreshed • Downloading the MyBlock does not update the robot

• Deleting or renaming a MyBlock will break any program that uses the MyBlock – You need to edit each program that uses the MyBlock with the newly

renamed Block

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

• 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 and

give it a different name

29

v3.0

MyBlocks Are Stored In Their Own Folder

• Moving a file to a different folder with break any program that is using that block – Use Pack and Go to transfer programs

30

v3.0

MyBlocks Can Be “Broken”

• A MyBlock will be broken if it has two data plugs with the same name

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

31

Back To Agenda

Moving and Turning

(including Motor Blocks and Move Blocks)

v3.0

Differences Between Move and Motor Blocks

Move Block Motor Block Number of motors controlled • 1, 2 or 3 • Only 1 motor per block

Motor Synchronization? • Synchronization & Steering *

Block to Block Error Correction? • Block to Block Error Correction • Block to Block Error Correction

Motor Power Control? • None • If selected, power control will increase/decrease power to maintain desired motor rotation

Motor Action • None • Ramp Up • Ramp Down • Constant

34

Only if the duration is degrees 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

v3.0

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

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

Recommendations Based on this battery-voltage experiment, we came up with the following recommendation for FLL teams when using NXT Software to program their LEGO® NXT robots: Whenever you use the MOVE block to control your robot, ensure both drive motors maintain the same power level (e.g. only use “steering” values of -100, 0, or +100).

Tip

Basic Robot Maneuverability

Move Blocks and

Motor Blocks

v3.0

Differences Between Move and Motor Blocks

Move Block Motor Block Number of motors controlled • 1, 2 or 3 • Only 1 motor per block

Motor Synchronization? • Synchronization & Steering *

Block to Block Error Correction? • Block to Block Error Correction • Block to Block Error Correction

Motor Power Control? • None • If selected, power control will increase/decrease power to maintain desired motor rotation

Motor Action • None • Ramp Up • Ramp Down • Constant

41

Only if the duration is degrees 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

v3.0

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

42

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

v3.0

Other Move and Motor Block Considerations

• Motor Blocks with its Next Action Parameter set to Constant will apply 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 duration

followed by a “Ramp Down Motor Block in this sense

43

Basic Robot Maneuverability

Driving Straight

v3.0

What Are Some Considerations For Making 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 wall 45

v3.0

Sometimes Features Are Used To Ride Along The Table Wall

46

• Be careful of the mounting location(s), because the robot might have a difficult time maneuvering away from the wall

Picture courtesy of Marco Ciavolino

Basic Robot Maneuverability

Robot Turns

v3.0

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

48

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

Recommendations Based on this battery-voltage experiment, we came up with the following recommendation for FLL teams when using NXT Software to program their LEGO® NXT robots: Whenever you use the MOVE block to control your robot, ensure both drive motors maintain the same power level (e.g. only use “steering” values of -100, 0, or +100).

Tip Experiment with different types of turns and see which one is more reliable for you!

Basic Robot Maneuverability

…am I there yet?

v3.0

Smooth Running by Dave Parker

50

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

Basic Robot Maneuverability

Navigation

v3.0

Where Possible, You Should Sense Your Outside Environment For Navigation

• Dead Reckoning – Maneuvering without using sensors to determine where you are relative to the positions of the mission models

• Fix – Using sensors to determine your position relative to the mat and mission 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 contacting the external environment (light, color, touch, ultrasonic, wall, mission model, strategic object) • Relatively insensitive to starting position and orientation • Sensitive to sensor performance and environment

v3.0

• Initial Guidance – When leaving the base, sometimes you can be pretty

loose with your navigation accuracy

• Midterm Guidance – While approaching the mission models, you should

tighten up your navigation accuracy

• Terminal Guidance – At the very end of your maneuvering, you must ensure

the accuracy and precision of your navigation are sufficient to get the job done

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

53

Some of the better teams can program some of their missions such that they 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

v3.0

If Your Robot Needs Accurate Alignment In The Base, Consider An Alignment Fixture

• The attachment needs to be made out of LEGO-manufactured pieces [Rule 4]

• The team member must not be touching the alignment fixture when the robot leaves base [Rule 16]

54

Picture courtesy of Marco Ciavolino

Back To Agenda

Motor Reset Blocks

Basic Robot Maneuverability

Motor Reset Blocks

v3.0

Move Block Error Correction and Motor Reset Blocks – 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.

v3.0

What Are These Motor Reset Blocks Actually Doing?

•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 a brake

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

•Setting direction to stop does not appear to reset accumulated move or motor errors

•This might be an error in the NXT-G help

•It is never necessary to use motor reset blocks at the beginning of a program

• All motors are automatically reset at the beginning of a program

•Motor reset blocks might be helpful at the beginning of code packaged in myblocks

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

59

v3.0

The Bottom Line: Expert’s 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 • It’s coasting that causes big errors to accumulate

•The main “good” use of motor reset blocks in FLL is when teams combine more than one 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 attachment between 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 possible application for the “making sure a new motion starts from a fresh measurement” would be the first movement after pushing into a stationary object with the intent to stall into it, such as having the robot push into a wall until it stalls

• At 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 don’t know any better

Back To Agenda

Multiple Sequence Beams

v3.0

You Can Use Multiple Sequence Beams For Concurrent Robot Operations

63

Move Forward

While Moving Forward (move block on other sequence beam), move Motor A

Note: Can do the same thing with a motor block in series with a Move Block as long as you uncheck the “Wait for Completion” option

v3.0

“Branch” Sequence Beams Can Be Added In The Middle Of The Main Sequence Beam

64

v3.0

NXT Program Flow Rules

• The program runs until it reaches the end of all sequence beams or a “stop block” whichever comes first

• A Block can only start when there are values on all of the input data wires

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

• A data wire that starts inside a Loop Block will have a value only when the Loop Block finishes

• A data wire that starts inside a Switch Block will have a value only when the Switch Block finishes

65

v3.0

Be Careful Of Multiple Sequence Beams Know The Issues With Them!

• Use multiple sequence beams only when you think you really need them

• Avoid “busy loops” where one sequence beam is hogging the CPU

• Don’t 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 Blocks and 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 My

Block, then run the second instance once the first one completes – Copy and rename the My Block if you need to run multiple copies

concurrently

66

Back To Agenda

Data Wires

(including Constants and Variables

v3.0

Data Wires Carry Information Between Programming Blocks

• You create a data wire by “drawing it out” of a block’s data hub

• Nearly all of the programming blocks have data hubs and can support data wires.

• Open a block’s 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 data plug. If you then press the mouse button and drag to the right, a data wire will “unroll” that can be connected to a plug on another block’s data hub.

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

69

v3.0

Data Wires Carry Information Between Programming Blocks

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

70

v3.0

Data Wires Carry Information Between Programming Blocks

• You create a data wire by “drawing it out” of a block’s data hub

• Nearly all of the programming blocks have data hubs and can support data wires

• Open a block’s 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 data plug – If you then press the mouse button and drag to the right, a data wire will

“unroll” that can be connected to a plug on another block’s data hub.

• Deleting a data wire – To delete a data wire that stretches from left to right between two data

plugs, click on the right plug

71

v3.0

Data Wires Carry Specific Types Of Data

• Each data wire carries a specific type of data between blocks. For example, if a data wire is dragged from a logic plug on a block’s data hub, it can only be connected to a logic plug on another block’s data hub.

• Data wires are identified with specific colors: – wires carrying number data are colored yellow – wires carrying logic (true/false) data are colored green – wires carrying text data are colored orange.

72

Back To Agenda

Line Following

Follow The Yellow Brick Road Black Curvy Line…

v3.0

2 State Line Follower – Most Basic

76

http://www.nxtprograms.com/line_follower/steps.html Note: For FLL, these display blocks might be an unnecessary waste of the NXT memory You will not be able to read the display as it is running anyway!

Question: How long will this line follower program follow the line?

v3.0

3 State Line Follower – Adds “Go Straight”

77

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

Go straight if you are just over the edge of the line

v3.0

5 State Line Follower

78

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

v3.0

Proportional Line Follower

79

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

This is getting a bit advanced for most FLL teams My opinion: If the children don’t understand it, don’t use it

v3.0

This Line Follower Sets The “B” Motor Speed To A Constant and Throttles the “C” Motor Speed

80

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

v3.0

Proportional Integral Differential (PID) Controllers Are Overkill For Most FLL Applications (But They Show Up At The World Festival All The Time)

81

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

If your team members cannot understand it, DON’T use it.

v3.0

There Are Even Fuzzy Logic Line Followers

82

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

Back To Agenda

Squaring Up

v3.0

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

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

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

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

85

Back To Agenda

Commenting and Printing Your Programs

What the Heck Is This Program Telling Me?

v3.0

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

Tip

You can enter comments which are generic to the entire program by clicking

on the start icon

Printing Your Programs

v3.0

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

90

HTML will create both the HTML code as well as pictures of the code These pictures can be inserted into most document editing programs

Rich Text Format (RTF) can be opened with most common word

processing programs

v3.0

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

v3.0

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

Back To Agenda

Base Operations

Time in Base is Time Not Earning Points

Back To Agenda

Master Programs or Sequencers

v3.0

A Sequencer Program Can Help With Speeding Up Your “Pitstops” In Base

97

00-MasterProgram.rbt Author: RobotBillMD Revision: 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?option=com_content&view=category&layout=blog&id=78&Itemid=118

http://www.cougarrobot.com

There are many different ways to implement a sequencing program

Have your team generate their own!

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

Back To Agenda

Other References

(Books, Websites, etc.)

v3.0

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

100

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

v3.0

The MD FIRST Website Has Many Great Resources

101

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

v3.0

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

102

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

v3.0

Our Own Techbrick Provides Resources That Are Used Worldwide – Thanks Marco!

103

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

v3.0

Training Is Available Via Carnegie Mellon

104

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

v3.0

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

• Dave Parker’s Website – A Frequent World Festival Judge – http://www.nxtprograms.com - Well documented NXT-G code!

• NXT-G Tips & Tricks on Team Hassenplug Website and Code Examples – 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/

105

v3.0

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

• Oregon State Robotics – http://www.ortop.org/fll/

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

106

v3.0

Telephone Support Is Available For Technical Stuff They Don’t Answer FLL-Specific Questions

LEGO Education – 866-349-5346 – 7:30AM to 5:30PM CST

LEGO Retail – 800-838-9647 – 7:30AM to 5:30PM CST

107

Popular Reference Books

v3.0

Jim Kelly’s Book On FIRST LEGO League Has Been Pretty Popular

109

This book is a bit dated, so remember that the official rules take precedence

v3.0

Programming References In Print

110

v3.0

Additional Print References

111

v3.0

The LET’S GO Boys and Girls Manual Provides A Curriculum and Instructional Exercises For FLL

112

v3.0

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

113

v3.0

Programming References In Print

114

v3.0 115

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

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:

v3.0

Training Is Available Via Carnegie Mellon

116

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

Back To Agenda

Generic Tips and Recommendations

v3.0

The NXT-G Software Has Default Ports For Various Outputs and Sensors

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 Sensor

4 Ultrasonic Sensor

119

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

v3.0

If You Have A Block That You Would Like To Reuse, Use <Control> Mouse Drag To Replicate

120

A B/C 1 2 3 4

Tip

3

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

v3.0

When Debugging Software, Here Are Some Tips

• 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 block followed by a wait for block (one possible example provided below)

121

This could be made into a myblock

v3.0

Highly Recommended! File Naming Convention and Regular Backups

• Tell the team to use a standard naming convention – One I like is <Person’s Initials><Short Description><Version Number> – 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 folder

pasting it to the same folder: C:\Documents and Settings\<Username>\My Documents\LEGO Creations\MINDSTORMS Projects\Profiles\Default

– I usually do not use different profile names with NXT-G; I use the default profile 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 USB thumbdrive or equivalent

122

v3.0

Bluetooth Is Disallowed By FLL At The Competition Bluetooth 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-in – You either need a computer with built-in

Bluetooth or you need a Bluetooth dongle

Tip

v3.0

How To Connect Via Bluetooth to NXT Robots

• 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 up later). 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 found computer. 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 window pops up, asking for the passcode. Type in the passcode and click Next. Again, the NXT beeps to verify 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 NXT supports. Select all available services (in my case, two serial ports) and press OK. Windows now installs 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).

124

Thanks to Andy Traiger of Vienna Robotics

Back To Agenda

v3.0

Here Is A Way To Detect How Many Touch Sensors Are Pressed

126

Connect all of the touch sensors together using RCX to NXT conversion wires and plug them into one port Please give “RobotBill” credit for this within the comments of your program if you use this technique