490 likes | 532 Vues
Introduction to RoboLab. CJ Chung Lawrence Technological University. What Is RoboLab?. A ‘Graphical’ programming language For the RCX based on LabVIEW In 1997, LabView was used for Sojourner project By designing a flow chart with given icons the programmer can program the RCX.
E N D
Introduction to RoboLab CJ Chung Lawrence Technological University Chung for Robofest 05
What Is RoboLab? • A ‘Graphical’ programming language For the RCX based on LabVIEW • In 1997, LabView was used for Sojourner project • By designing a flow chart with given icons the programmer can program the RCX Chung for Robofest 05
Pros to Using RoboLab • Easy to see control structure • Visual interface is simple • Exactly like LabVIEW • Data gathering and visualization (investigator) Chung for Robofest 05
Cons to Using RoboLab • Spaghetti code • Hard to wire icons… • No edge triggering supported. See Line Counter program in this slide Chung for Robofest 05
For More Information • Lego’s Page www.lego.com/dacta/robolab • National Instruments Page www.ni.com/robolab • Tufts University www.ceeo.tufts.edu/graphics/robolab • www.lego.com/education/mindstorms/images/eng/downloads/compare.doc Chung for Robofest 05
Before Getting Started Programming RCX Firmware Download: Administrator Chung for Robofest 05
“Investigator” for data gathering and visualization Chung for Robofest 05
Getting Started Programmer | double click “Inventor Level 4” Chung for Robofest 05
RoboLab Class Mission 1:To drive using a Timer • “Go straight for 2.5 seconds and stop” Chung for Robofest 05
Save the file! Chung for Robofest 05
Just click Broken arrow Chung for Robofest 05
Modifiers Chung for Robofest 05
Context Help • Just point an icon in question Chung for Robofest 05
To replace an icon • Use right click and replace (for Macs, use the Apple key) Chung for Robofest 05
Windows| Show Tools Palette • The space bar • The tab key Chung for Robofest 05
Tips • How to insert icons? • How delete icons? • Cover the tower and RCX when downloading, if more than one robot in a room! • Use Meaningful file names • Add Comments using “A: edit text” Chung for Robofest 05
RoboLab Mission 2: Bumper Car • Goes straight and stops when the bumper is hit or • Turn motors A and B; turn off motors A and B, when a touch sensor is pressed Chung for Robofest 05
What is wrong? Chung for Robofest 05
RoboLab Mission 3: Board Edge Detection • Robot must stop when it detects the edge of the white board • Testing Light Sensors • Use Black ‘View’ Button to read data from the light sensor Chung for Robofest 05
Darker than 40 Brighter than 50 Chung for Robofest 05
RoboLab Mission 4: Making Turns • Go straight for 2.5 seconds and turn right 90 degrees and go straight for 2 seconds and stop • Is it easy to make 90 degree turns? • Mark the stop location and rerun • Does it stop at the same point? • Why not? • How do we make our robots go straight? • Very important for many missions Chung for Robofest 05
Method 1: stop Left motor Right motor Tips: Making Right Turns Method 2: Left motor Right motor Chung for Robofest 05
Using a Rotation Sensor in RoboLab • Finding a good pair of motors using RoboLab • Use Black View Button to read data from the rotation sensor Chung for Robofest 05
RoboLab Control Structures • Sequence • Loop: • Decision: Fork • Subroutines: • Multitasking: Chung for Robofest 05
Loop with a counter Chung for Robofest 05
Loop while touch sensor is released Chung for Robofest 05
Mission 5: Detect Light and Beep • When the light sensor detects a bright light source, beep • Repeat until a touch sensor is pressed Chung for Robofest 05
A loop inside a loop? Chung for Robofest 05
Decision - Fork Chung for Robofest 05
Mission 6: Line Following (Zigzag method) Do forever until touch sensor is pressed: • If it sees black, turn right • If it sees white, turn left Which side of the line does this follow? Chung for Robofest 05
How to follow a line using one Light Sensor? - Zigzag methods Chung for Robofest 05
n n Subroutine – a set of commands • Create Subroutine No. n: • Run subroutine n: Chung for Robofest 05
Subroutine Example Chung for Robofest 05
Mission 7: Line Following Until the edge of the board • Do forever until light sensor detects the edge of the board: • If it sees black, turn right • If it sees white, turn left Chung for Robofest 05
RCX Communications - Send Chung for Robofest 05
RCX Communications - Receive Chung for Robofest 05
Containers to store values • Loop while container value is less than… Chung for Robofest 05
Mission 8: Line Counter • Go forward • Count each line as the robot crosses it • When the robot detects the 4th line, stop. • Uses a Container to count number of lines Chung for Robofest 05
Wait for Dark Wait for Dark Line Counter Solution Using RoverBot Style Gearing If no time to skip black line, a line can be counted more than once. Cf. RCX code, Wait Until, provides “Edge Triggering” Chung for Robofest 05
Sensor Stacking • Stack touch sensor on top of light sensor • Both Sensors must be thought of as light sensors. • Pressing the touch sensor will always read 100. • When the touch sensor is not pressed the value for the light sensor will be read. Chung for Robofest 05
Mission 9: Line following until stacked touch sensor is pressed Chung for Robofest 05
Multitasking Chung for Robofest 05
How to upload to different program slots • Select the slot number by pressing the gray Pgm button on the RCX • Click the (run) button Chung for Robofest 05