73
LEGO Mindstorms NXT Programming

LEGO Mindstorms NXT Programming

Embed Size (px)

DESCRIPTION

LEGO Mindstorms NXT Programming. 다양한 프로그램 언어와 인터페이스 가능. LabVIEW. C 언어. JAVA. Visual Basic. MS Robot Studio. Robolab. NXT-G. About Bluetooth. Bluetooth 는 근거리 통신 규약으로 약 10m 정도의 거리까지 통신이 가능하다 . 장비별 식별 코드를 사용하므로 장비간 인증 , 데이터 보안 등의 특징과 네트워크 , 시리얼 , 오디오 등 다양한 서비스를 제공한다. - PowerPoint PPT Presentation

Citation preview

  • LEGO Mindstorms NXTProgramming

  • CJAVALabVIEWVisual Basic MSRobot StudioRobolabNXT-G

  • About BluetoothBluetooth 10m . , , , .NXT PC to NXT, NXT to NXT .

  • About Bluetooth Bluetooth . 3 . . . on/off .

  • Programming LanguagesNXT-G codeNXC (and NBC)Robot CpbLuaJava and others

  • NXT-G codeLEGOs development environmentGraphical programmingBased on National Instruments LabViewGreat for quick programsWonderful for kids to use but a real pain for old geezers like me who grew up with text programming languages

  • NXT-G NXT-GNational Instruments , . NXT-G .

  • LabVIEW ROBOLABLabVIEWROBOLAB=Robolab LabVIEW ( ) LEGO Robolab

  • ROBOLABROBOLAB Tufts University Lego RCX NXT . NXT-G ROBOLAB National Instruments LabVIEW LabVIEW NXT-G ROBOLAB integer floating

  • ROBOTCROBOTCNXT C Carnegie Mellon University Robotics Academy : www.robotc.netROBOTC Not free (free trial, $30 download)

  • NXC ... NOT EXACTLY CNXC(Not eXactly C)C NXT (Free)C , C RCX NQC , NXT NXC NXC NXT-G NXC NXT-G interger floating LCD NXC ROBOTC

  • C base Programming(NXC) NXT C NXC C .

    , C

  • PBLUAPBLUA Lua pbLua NXT Lua pbLua ROBOTC NXC

  • NXJNXJ NXT JAVA Class

  • Other languagesJava and several other languages are reportedly in the works as wellMS Robotic Studio also supports the NXTDownload a small client program to NXTActual control is on a PChttp://www.teamhassenplug.org/NXT/NXTSoftware.html

  • Microsoft Robot Studio : (MS) , (Roomba), NXT(LEGO Mindstorms NXT) .

    JAVA on NXT : LeJOS LEGO JAVA JDK 1.5 LeJOS .

  • S/W

  • ROBOLAB

  • NXT V

  • (PC )

    20

  • RoboLab Work SpaceRemember to use Context Sensitive Help!

  • Programming LevelsPilot LevelUses basic interface where programs are built using a click-and-choose interfaceInventor LevelProvides a more open-ended, icon-based environmentInvestigator LevelUses Pilot and Inventor programming to incorporate data collection into projects

  • StoryboardingAdvantages of using a storyboard:Makes it easier for younger studentsGives students a concrete plan to use at the computerChecks individual understandingComes in handy when there is a lack of computersForces students to plan ahead and think objectively

  • Elements of a ProgramBeginning and end of program MotionDurationSpeedSensing the environment

  • ProgrammingAlways start an Inventor program with this command. (Change BeginNXT icon)Always end an Inventor program with this command.

  • MotionChoosing the correct icon:Look at the arrowsLook at the port the motor is connected to on the RCXMotor A ForwardMotor A ReverseMotor B ForwardMotor B ReverseMotor C ForwardMotor C Reverse

  • DurationThe icons used to assign duration are called Wait Fors.Wait Fors:Wait for 1 secondWait for 2 secondsWait for 4 secondsWait for 6 seconds

  • Checkpoint

  • Checkpoint

  • Stop IconsBecause we want to stop both A and C motors, we will choose the stop A, B, C icon and place it at the end of our program. Stop AStop BStop CStop A, B, C

  • A Complete ProgramCongratulations!You have now storyboarded your first robotics program.

  • From Storyboard to ComputerLets go back to our computer.

  • Writing a new programClick on the Programmer button.You should then see the Inventor login screen.

  • ROBOLAB Environment Set up your screen in Inventor 4 so that it looks like the screen to the right.

  • ROBOLAB EnvironmentThere are two major pallets that contain most of the icons and commands you need to build a program. If you cannot see these pallets, you can find them under the Show drop down list.

    Tools

    Functions

  • WaitFor Palette

  • ROBOLAB EnvironmentClick and drag the icons from the Function pallets to the blue screen space.

  • Tool Pallet ()VI , , (Space Key )

    VI VI (Space Key )

    (Tab Key )

  • ROBOLAB EnvironmentOn the tools pallet, find the button that looks like a spool of wire.

  • Downloading the ProgramClick the white arrow on the ROBOLAB screen.

  • Testing the ProgramPut your NXT on the floor and press the Orange Button.

  • TroubleshootingQuestion:Why wont this program work?

  • TroubleshootingAnswer:The wiring is not correct. Always check for bad wires or missing wires.

    Bad WireMissing Wire

  • TroubleshootingQuestion:This program is supposed to turn on Motor A for four seconds, then turn off the motor. Whats wrong?

  • TroubleshootingAnswer:There was no Stop Motor icon.

  • RoboLab Class Mission 1: To drive using a TimerWith power level 3, Go straight for 2.5 seconds and stop 3 2.5 Broken arrow Just right button click Select (Error list)Ctrl+B Delete Broken arrows

  • VI (Visible Item)Visible Item Terminal: : : : ():

  • (VI) :

    : /

    : ()

    : ()

    : ()

  • Modifiers Palette

  • ModifiersSelect CommandClick in Diagram Window to Place CommandWire Command Connections

  • Context HelpJust point an icon in question

  • Touch sensors

  • RoboLab Mission 2: Bumper CarStoryboardGoes straight and stops when the bumper is hitProgramTurn motors B and CTurn off motors B and C, when a touch sensor (Input 1) is pressed

    NXT (1,2,3) Wait for pushWait for Lets GoNXT Click Fork (default: 10)NXT Touch and Release Fork

  • Answer

  • Example B, C 2

  • Light SensorsThe photo-transistor acts like a valve for electricity.

    The more light energy it senses, the more electricityflows.Photo-transistor

  • Light SensorsLight sensors are found under the Wait For icon in the Functions PaletteWait for light default: 55 range: 1~100Wait for darkdefault: 55 range: 1~100Wait for lighter (Default: 5% increase)Wait for darker (Default: 5% decrease)Light SensorFork Default: 55

  • RoboLab Mission 3: Board Edge DetectionRobot must stop when it detects the edge of the white boardTesting Light SensorsUse Black View Button to read data from the light sensorMeasures the level of light as a number between 0% (total darkness) and 100% (very bright)

  • AnswerDarker than 30Brighter than 60

  • Sound SensorRobot must stop when it detects the volume to increase by the cutoff valueWait for LouderDefault value : an increase of 30%Wait for QuieterDefault value : an decrease of 30%Wait for LoudDefault value : 70db Wait for QuietDefault value : 70db

    Sound Sensor Fork Default: 55Range: 1(quiet)~100(loud)

  • Sound Sensor Example 40%

  • Ultrasonic SensorRobot must stop when it detects the distance that is less than a start valueForward Distance xDefault: 20cm (1cm~200cm)Reverse Distance xDefault: 20cm (1cm~200cm) Distance Sensor Fork (default: 20cm)

  • Ultrasonic Sensor Example 30cm

  • RoboLab Mission 4: Making TurnsStoryboardGo straight for 1 seconds and turn right 90 degrees and go straight for 2 seconds and stopProgram ??Is it easy to make 90 degree turns?Mark the stop location and rerunDoes it stop at the same point?Why not?How do we make our robots go straight?Very important for many missions

  • Tips: Making Right TurnsMethod 2:Left motorRight motor

  • Making TurnsTurn left:

    Spin left: (point turn)

    Face left:

  • Answer??

  • Ex 4-1: Go forward 1.5 seconds and come back by spinning leftSpinning 180 degrees?Is it accurate?

  • Advanced Bumper CarNXT B, C Bumper Car . Bumper 1 B, C 1 Bumper Car .

  • ReferenceReferencehttp://utah4h.org/htm/featured-programs/robotics/robolab-tutorial/http://www.robofest.net/http://inside.catlin.edu/site/msrobotics/html/downloads.html

    () () ROBOLAB .() Run Robolab .() RCX . .() , , NI .() . RCX , , , , .

    ()() . 9794 USB . . ()() Administrator . Space .()Administrator . Administrator . () USB USB #1 . 3~4 .() Test RCX .() RCX LCD, RCX LCD.()() .()() Programmer .() vi . . .() VI . Lev 4 . ()

    () () . VI . VI .() , , . . () VI .() . VI .()

    Define goalOn your notepad, write down what needs to happen in order for your robot to move forward and backward before stopping.Find the Begin and End command magnets or stamps and set them apartFind your motor icons

    Choose the correct icons to make your robot move forward and place them after your begin icon.

    How long do we want it to move?What do you think will happen if you dont assign a duration to an activity?

    If you do not assign a duration to the activity, it will continue without stopping.

    Find the Wait For 2s icon and place it after your motor icons.What should the rest of the program look like to ensure that your robot makes it back to its starting position?

    Find those icons and place them into position.

    Now we need to add our stop and end program icons.stop the motion or activity

    We then need to add our end programming icon.

    Restate reasons for storyboardingArrange the icons as you did in your groups.

    () . (VI) , .

    VI Space / Tab . .Now that we have our program set up we need to connect the commands with wire.

    VI . VI vi .

    . vi begin vi end . begin() end, end() begin . vi begin end 1 .

    . . begin vi end vi .

    task begin 1 end 2 . begin .

    vi begin end . / vi modifier vi . vi . vi . vi RCX 1,2,3 a,b,c .

    . , . () . vi , numeric constance . vi nc vi 0 tab AI . , () . vi vi begin / end nc . jump jump jump id . C .

    vi . . .

    vi (end to begin) modifier . broken . vi .

    Touch sensor is just a simple switchFeedback loop controlWhat is method 3?