Chung for Robofest 05 1 Introduction to RoboLab CJ Chung Lawrence Technological University.

49
Chung for Robofest 05 1 Introduction to RoboLab CJ Chung Lawrence Technological University

Transcript of Chung for Robofest 05 1 Introduction to RoboLab CJ Chung Lawrence Technological University.

Page 1: Chung for Robofest 05 1 Introduction to RoboLab CJ Chung Lawrence Technological University.

Chung for Robofest 05

1

Introduction to RoboLab

CJ ChungLawrence Technological

University

Page 2: Chung for Robofest 05 1 Introduction to RoboLab CJ Chung Lawrence Technological University.

Chung for Robofest 05

2

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

Page 3: Chung for Robofest 05 1 Introduction to RoboLab CJ Chung Lawrence Technological University.

Chung for Robofest 05

3

Pros to Using RoboLab

• Easy to see control structure• Visual interface is simple• Exactly like LabVIEW• Data gathering and visualization

(investigator)

Page 4: Chung for Robofest 05 1 Introduction to RoboLab CJ Chung Lawrence Technological University.

Chung for Robofest 05

4

Cons to Using RoboLab

• Spaghetti code• Hard to wire icons…

• No edge triggering supported. See Line Counter program in this slide

Page 5: Chung for Robofest 05 1 Introduction to RoboLab CJ Chung Lawrence Technological University.

Chung for Robofest 05

5

For More Information

• Lego’s Pagewww.lego.com/dacta/robolab

• National Instruments Pagewww.ni.com/robolab

• Tufts Universitywww.ceeo.tufts.edu/graphics/robolab

• www.lego.com/education/mindstorms/images/eng/downloads/compare.doc

Page 6: Chung for Robofest 05 1 Introduction to RoboLab CJ Chung Lawrence Technological University.

Chung for Robofest 05

6

Before Getting Started Programming

RCX Firmware Download: Administrator

Page 7: Chung for Robofest 05 1 Introduction to RoboLab CJ Chung Lawrence Technological University.

Chung for Robofest 05

7

“Investigator” for data gathering and visualization

Page 8: Chung for Robofest 05 1 Introduction to RoboLab CJ Chung Lawrence Technological University.

Chung for Robofest 05

8

Getting Started

Programmer | double click “Inventor Level 4”

Page 9: Chung for Robofest 05 1 Introduction to RoboLab CJ Chung Lawrence Technological University.

Chung for Robofest 05

9

RoboLab Class Mission 1: To drive using a Timer• “Go straight for 2.5 seconds and

stop”

Page 10: Chung for Robofest 05 1 Introduction to RoboLab CJ Chung Lawrence Technological University.

Chung for Robofest 05

10

Page 11: Chung for Robofest 05 1 Introduction to RoboLab CJ Chung Lawrence Technological University.

Chung for Robofest 05

11

Save the file!

Page 12: Chung for Robofest 05 1 Introduction to RoboLab CJ Chung Lawrence Technological University.

Chung for Robofest 05

12

Page 13: Chung for Robofest 05 1 Introduction to RoboLab CJ Chung Lawrence Technological University.

Chung for Robofest 05

13

Just clickBroken arrow

Page 14: Chung for Robofest 05 1 Introduction to RoboLab CJ Chung Lawrence Technological University.

Chung for Robofest 05

14

Modifiers

Page 15: Chung for Robofest 05 1 Introduction to RoboLab CJ Chung Lawrence Technological University.

Chung for Robofest 05

15

Context Help• Just point an icon in question

Page 16: Chung for Robofest 05 1 Introduction to RoboLab CJ Chung Lawrence Technological University.

Chung for Robofest 05

16

To replace an icon• Use right click and replace (for

Macs, use the Apple key)

Page 17: Chung for Robofest 05 1 Introduction to RoboLab CJ Chung Lawrence Technological University.

Chung for Robofest 05

17

Windows| Show Tools Palette• The space bar • The tab key

Page 18: Chung for Robofest 05 1 Introduction to RoboLab CJ Chung Lawrence Technological University.

Chung for Robofest 05

18

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”

Page 19: Chung for Robofest 05 1 Introduction to RoboLab CJ Chung Lawrence Technological University.

Chung for Robofest 05

19

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

Page 20: Chung for Robofest 05 1 Introduction to RoboLab CJ Chung Lawrence Technological University.

Chung for Robofest 05

20

Page 21: Chung for Robofest 05 1 Introduction to RoboLab CJ Chung Lawrence Technological University.

Chung for Robofest 05

21

What is wrong?

Page 22: Chung for Robofest 05 1 Introduction to RoboLab CJ Chung Lawrence Technological University.

Chung for Robofest 05

22

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

Page 23: Chung for Robofest 05 1 Introduction to RoboLab CJ Chung Lawrence Technological University.

Chung for Robofest 05

23

Darker than 40

Brighter than 50

Page 24: Chung for Robofest 05 1 Introduction to RoboLab CJ Chung Lawrence Technological University.

Chung for Robofest 05

24

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

Page 25: Chung for Robofest 05 1 Introduction to RoboLab CJ Chung Lawrence Technological University.

Chung for Robofest 05

25

Tips: Making Right Turns

stop

Method 1:

Left motor Right motor

Method 2:

Left motor Right motor

Page 26: Chung for Robofest 05 1 Introduction to RoboLab CJ Chung Lawrence Technological University.

Chung for Robofest 05

26

Page 27: Chung for Robofest 05 1 Introduction to RoboLab CJ Chung Lawrence Technological University.

Chung for Robofest 05

27

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

Page 28: Chung for Robofest 05 1 Introduction to RoboLab CJ Chung Lawrence Technological University.

Chung for Robofest 05

28

Page 29: Chung for Robofest 05 1 Introduction to RoboLab CJ Chung Lawrence Technological University.

Chung for Robofest 05

29

RoboLab Control Structures

• Sequence• Loop: • Decision: Fork

• Subroutines:• Multitasking:

Page 30: Chung for Robofest 05 1 Introduction to RoboLab CJ Chung Lawrence Technological University.

Chung for Robofest 05

30

Loop with a counter

Page 31: Chung for Robofest 05 1 Introduction to RoboLab CJ Chung Lawrence Technological University.

Chung for Robofest 05

31

Loop while touch sensor is released

Page 32: Chung for Robofest 05 1 Introduction to RoboLab CJ Chung Lawrence Technological University.

Chung for Robofest 05

32

Mission 5: Detect Light and Beep• When the light sensor detects a

bright light source, beep• Repeat until a touch sensor is

pressed

Page 33: Chung for Robofest 05 1 Introduction to RoboLab CJ Chung Lawrence Technological University.

Chung for Robofest 05

33

A loop inside a loop?

Page 34: Chung for Robofest 05 1 Introduction to RoboLab CJ Chung Lawrence Technological University.

Chung for Robofest 05

34

Decision - Fork

Page 35: Chung for Robofest 05 1 Introduction to RoboLab CJ Chung Lawrence Technological University.

Chung for Robofest 05

35

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?

Page 36: Chung for Robofest 05 1 Introduction to RoboLab CJ Chung Lawrence Technological University.

Chung for Robofest 05

36How to follow a line using one Light Sensor? - Zigzag methods

Page 37: Chung for Robofest 05 1 Introduction to RoboLab CJ Chung Lawrence Technological University.

Chung for Robofest 05

37

Page 38: Chung for Robofest 05 1 Introduction to RoboLab CJ Chung Lawrence Technological University.

Chung for Robofest 05

38

Subroutine – a set of commands• Create Subroutine No. n:

• Run subroutine n:

n

n

Page 39: Chung for Robofest 05 1 Introduction to RoboLab CJ Chung Lawrence Technological University.

Chung for Robofest 05

39

Subroutine Example

Page 40: Chung for Robofest 05 1 Introduction to RoboLab CJ Chung Lawrence Technological University.

Chung for Robofest 05

40

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

Page 41: Chung for Robofest 05 1 Introduction to RoboLab CJ Chung Lawrence Technological University.

Chung for Robofest 05

41

RCX Communications - Send

Page 42: Chung for Robofest 05 1 Introduction to RoboLab CJ Chung Lawrence Technological University.

Chung for Robofest 05

42

RCX Communications - Receive

Page 43: Chung for Robofest 05 1 Introduction to RoboLab CJ Chung Lawrence Technological University.

Chung for Robofest 05

43

Containers to store values

• Loop while container value is less than…

Page 44: Chung for Robofest 05 1 Introduction to RoboLab CJ Chung Lawrence Technological University.

Chung for Robofest 05

44

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

Page 45: Chung for Robofest 05 1 Introduction to RoboLab CJ Chung Lawrence Technological University.

Chung for Robofest 05

45Line Counter Solution Using RoverBot Style Gearing

Wait for Dark

If no time to skip black line, a line can be counted more than once.

Wait for Dark

Cf. RCX code, Wait Until, provides “Edge Triggering”

Page 46: Chung for Robofest 05 1 Introduction to RoboLab CJ Chung Lawrence Technological University.

Chung for Robofest 05

46

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.

Page 47: Chung for Robofest 05 1 Introduction to RoboLab CJ Chung Lawrence Technological University.

Chung for Robofest 05

47Mission 9: Line following until stacked touch sensor is pressed

Page 48: Chung for Robofest 05 1 Introduction to RoboLab CJ Chung Lawrence Technological University.

Chung for Robofest 05

48

Multitasking

Page 49: Chung for Robofest 05 1 Introduction to RoboLab CJ Chung Lawrence Technological University.

Chung for Robofest 05

49

How to upload to different program slots• Select the slot number by pressing

the gray Pgm button on the RCX• Click the (run) button