1 / 37

Robofest NXT Programming Workshop Aug. 24, 2006 CJ Chung Associate Professor of Computer Science Lawrence Tech Univer

Robofest NXT Programming Workshop Aug. 24, 2006 CJ Chung Associate Professor of Computer Science Lawrence Tech University CHUNG@LTU.edu www.Robofest.net. RoboLab, RCX code, and NXPL Follow a line and stop when the bumper is hit. Agenda. Intro to NXT Construction of NXT basic model

paul
Download Presentation

Robofest NXT Programming Workshop Aug. 24, 2006 CJ Chung Associate Professor of Computer Science Lawrence Tech Univer

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Robofest NXT Programming WorkshopAug. 24, 2006CJ ChungAssociate Professor of Computer ScienceLawrence Tech UniversityCHUNG@LTU.eduwww.Robofest.net chung

  2. RoboLab, RCX code, and NXPLFollow a line and stop when the bumper is hit chung

  3. Agenda • Intro to NXT • Construction of NXT basic model • Intro to NXT programming Language: Move, Loop, Sensors, Wait, Display and Switches • Advanced NXT Programming features: Advanced My Blocks, Multiple Tasks, and Variables • NXT Programming Tips • Intro to Thanksgiving RoboParade chung

  4. Robots to be used • TriBot Driving Base (Robo Center, Quick Start Vehicle) • Add a bumper • Add a light sensor facing down chung

  5. Go forward for 2 sec. and stop chung

  6. Go forward for 2 sec. and stop chung

  7. Exercises • Go forward 2 seconds and come back • Go forward 4 rotations and come back • Go forward 720 degrees and come back chung

  8. Spin Right 90 degrees 1.1 rotations What is wrong? chung

  9. Turn Right 90 degrees 1.1 rotations What is wrong? chung

  10. Turn Right (spin) 90 degrees How to connect beams? How to extend beams? chung

  11. Parallel Sequence Beam • Move the mouse point over the starting point (or over the wire stub), and pressing and holding your mouse button while you move the mouse upwards or downwards – not reliable… • Easier way chung

  12. My Blocks • Wrap a procedure into a package • To do the same thing from different places; to reuse code; to make code non-redundant • To divide a large task into smaller meaningful modules (provide structure) • To hide complex details chung

  13. How to create MyBlocks • Start with working code • Highlight blocks to include • Click the “Create My Block” button • Name the MyBlock • Describe the MyBlock • Build icon(s) • MyBlock replaces the selected Blocks chung

  14. How to reuse the MyBlock • Select it from the Custom Tab chung

  15. A loop with a MyBlock Square! chung

  16. Comments • Use balloon text tool • Add the following information • Author, when • Who made changes, when • How to use • Functions • Block descriptions • Assumptions • Expected results • Known bugs • Rooms to improve • Etc. chung

  17. Sensors • Touch • Light • Sound (microphone) • Ultrasound (Distance measurement) • Rotation – embedded in the motors • Timer – Internal sensor • NXT buttons • Received messages chung

  18. Touch Sensor • Pressed • Released • Bumped - (pressed and released) or (released and pressed) chung

  19. If touch sensor is bumped, say “Good Job!” chung

  20. Ex. If touch sensor is pressed, make two squares chung

  21. Light Sensor • Percent mode • 5% - lowest dark • 100% - very bright • Shines a red light • The light can be turned off – detecting ambient (surrounding light) • Live updates: See lower left corner!!!! chung

  22. Go until the edge of the table is detected chung

  23. If light sensor is on the black line, the robot says “Black”; otherwise “White” – Sensor Switch chung

  24. Ex. Modify the previous program to repeat the function endlessly when a touch sensor is pressed chung

  25. Loop until a touch sensor is pressed Display seconds until touch sensor is pressed. Cf. RCX code Repeat Until Cf. RCX code Repeat While chung

  26. Line following - Zigzag methods chung

  27. Follow a line and stop when the bumper is hit chung

  28. Rotation Sensor • Each motor has an embedded rotation sensor • 360 counts per rotation • The counter can be incremented or decremented • Distance traveled can be calculated: Circumference = 2 x radius x π chung

  29. Ex. Rotation Sensor Wait: Stop when Motor B has turned 370 degrees chung

  30. Variable • Variables are memory containers that hold numeric values • They enable the NXT to collect and store information • You can change the value during your program • Useful to pass values to MyBlocks!!! chung

  31. Creating a Variable • EDIT | Define Variables • Create • Name the variable (as meaningful as possible) • Select a data type • Number • Text • Logic (True / False) chung

  32. Move forward until the robot reaches a black line (area) orhit a wall (detected by a touch sensor) Exercise: chung

  33. To pass values to MyBlocks chung

  34. How to make parameterized MyBlocks • Introduce variables to the working code • Highlight blocks to include only the working code part without variables • Click the “Create My Block” button • … chung

  35. Not covered advanced topics • Cascading Switches • Data Hubs, and • synchronization of multiple tasks • … chung

  36. NXT Programming Tips (Known Bugs) • Do not update firmware - freeze • “Out of Memory” problem • Do not use sound to much • Do not display graphics • Minimize number of programs on NXT • Delete unnecessary programs • Some small bugs chung

  37. Personal Comments on NXT • Looks not stable yet • Some concepts of RCX code programming may be better • Hard to read small texts • Do not forget to add comments! • No separate NXT division in Robofest 2007 chung

More Related