the scribbler gui
DESCRIPTION
The Scribbler GUI. Looping forever Reading/observing sensors (inputs) Reacting to sensors Obstacle sensors. Learning objectives:. Introduce the forever loop. Introduce if s. Looping forever. Looping forever. Repeats whatever is inside of the loop forever. - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: The Scribbler GUI](https://reader033.vdocuments.mx/reader033/viewer/2022052414/56813a60550346895da258ac/html5/thumbnails/1.jpg)
Looping foreverReading/observing sensors (inputs)
Reacting to sensorsObstacle sensors
![Page 2: The Scribbler GUI](https://reader033.vdocuments.mx/reader033/viewer/2022052414/56813a60550346895da258ac/html5/thumbnails/2.jpg)
Learning objectives:
1. Introduce the forever loop.
2. Introduce ifs.
![Page 3: The Scribbler GUI](https://reader033.vdocuments.mx/reader033/viewer/2022052414/56813a60550346895da258ac/html5/thumbnails/3.jpg)
![Page 4: The Scribbler GUI](https://reader033.vdocuments.mx/reader033/viewer/2022052414/56813a60550346895da258ac/html5/thumbnails/4.jpg)
Looping foreverRepeats
whatever is inside of the loop forever.
(It can also optionally repeat something a specific number of times.)
![Page 5: The Scribbler GUI](https://reader033.vdocuments.mx/reader033/viewer/2022052414/56813a60550346895da258ac/html5/thumbnails/5.jpg)
Looping foreverWhat does this program do?
![Page 6: The Scribbler GUI](https://reader033.vdocuments.mx/reader033/viewer/2022052414/56813a60550346895da258ac/html5/thumbnails/6.jpg)
Looping forever1. Remove the first pause and run it.
Q1: What do you observe?
2. Put the first pause back in and remove the second one. Run it.Q2: What do you observe?
3. Remove all pauses. Run it.Q3: What do you observe?
4. Using the Scribbler programming GUI, remove the start of the forever loop. Don’t run it!Q4: What happened (when you removed the start
of the forever loop)?
![Page 7: The Scribbler GUI](https://reader033.vdocuments.mx/reader033/viewer/2022052414/56813a60550346895da258ac/html5/thumbnails/7.jpg)
![Page 8: The Scribbler GUI](https://reader033.vdocuments.mx/reader033/viewer/2022052414/56813a60550346895da258ac/html5/thumbnails/8.jpg)
Program P1: Artificial Life
Program P1 artificial life (?)
Write a Scribbler program that does the following:1. Move the Scribbler forward for about ¼ second.2. Pause for about one second.
It should repeat this sequence of operations forever.You should also cause one or more of the LEDs to
turn on and off (sort of like a heartbeat) as well.Send a screen shot and the .scb file to me.
![Page 9: The Scribbler GUI](https://reader033.vdocuments.mx/reader033/viewer/2022052414/56813a60550346895da258ac/html5/thumbnails/9.jpg)
![Page 10: The Scribbler GUI](https://reader033.vdocuments.mx/reader033/viewer/2022052414/56813a60550346895da258ac/html5/thumbnails/10.jpg)
What can we read/observe?1. Line sensors
2.Obstacle sensors3. Crash (stall)4. Light sensors5. Coin toss
![Page 11: The Scribbler GUI](https://reader033.vdocuments.mx/reader033/viewer/2022052414/56813a60550346895da258ac/html5/thumbnails/11.jpg)
What can we read/observe?Obstacle sensors:
1. Left2. Right
![Page 12: The Scribbler GUI](https://reader033.vdocuments.mx/reader033/viewer/2022052414/56813a60550346895da258ac/html5/thumbnails/12.jpg)
![Page 13: The Scribbler GUI](https://reader033.vdocuments.mx/reader033/viewer/2022052414/56813a60550346895da258ac/html5/thumbnails/13.jpg)
IF - ELSE1. Observe a sensor.
2. Conditional tiles are used to create a fork in the road of your program's execution.
3. Depending on the outcome of the chosen condition, your program may continue in one of two different directions (but not both).
![Page 14: The Scribbler GUI](https://reader033.vdocuments.mx/reader033/viewer/2022052414/56813a60550346895da258ac/html5/thumbnails/14.jpg)
IF - ELSEThe simplest conditional is the IF-
THEN-ELSE tile (yellow).This tile checks for the presence of an
obstruction on the left and none on the right.
If this condition is met the path indicated by the green check mark is taken.
If not, the path indicated by the red "X" is taken.
So, overall, what this particular program does is turn the left LED on if there's a left obstruction and not a right one, and turns it off otherwise.
![Page 15: The Scribbler GUI](https://reader033.vdocuments.mx/reader033/viewer/2022052414/56813a60550346895da258ac/html5/thumbnails/15.jpg)
IF - ELSE
Conditionals are inserted into your program the same as other tiles. Just click on the conditional button and a cursor will appear as you mouse over the worksheet, showing you where the conditional can be inserted. When you click it into place, the conditional edit box will appear, as shown to the left.
![Page 16: The Scribbler GUI](https://reader033.vdocuments.mx/reader033/viewer/2022052414/56813a60550346895da258ac/html5/thumbnails/16.jpg)
IF - ELSE
Here you can select what condition you want to test by clicking one of the five multiple-choice boxes until that condition appears.
![Page 17: The Scribbler GUI](https://reader033.vdocuments.mx/reader033/viewer/2022052414/56813a60550346895da258ac/html5/thumbnails/17.jpg)
IF - ELSE
For most conditions, the slider at the bottom can be used to place further restrictions on when the condition is TRUE, such as a required number of consecutive observations of that condition.
![Page 18: The Scribbler GUI](https://reader033.vdocuments.mx/reader033/viewer/2022052414/56813a60550346895da258ac/html5/thumbnails/18.jpg)
IF - ELSE
The remaining button is used to switch the TRUE and FALSE directions.Notice that the reversed directions are
highlighted in black to make them more obvious in your program.
![Page 19: The Scribbler GUI](https://reader033.vdocuments.mx/reader033/viewer/2022052414/56813a60550346895da258ac/html5/thumbnails/19.jpg)
IF - ELSE
• When a conditional is placed, it creates several locations where additional tiles may be inserted.
![Page 20: The Scribbler GUI](https://reader033.vdocuments.mx/reader033/viewer/2022052414/56813a60550346895da258ac/html5/thumbnails/20.jpg)
IF - ELSE
• When a conditional is placed, it creates several locations where additional tiles may be inserted.• One is immediately to the bottom of the tile
and is normally the program fork corresponding to a TRUE condition.
![Page 21: The Scribbler GUI](https://reader033.vdocuments.mx/reader033/viewer/2022052414/56813a60550346895da258ac/html5/thumbnails/21.jpg)
IF - ELSE
• When a conditional is placed, it creates several locations where additional tiles may be inserted.• Another insertion point is the arrow to the
right of the tile. This is normally the path taken by the FALSE condition.
![Page 22: The Scribbler GUI](https://reader033.vdocuments.mx/reader033/viewer/2022052414/56813a60550346895da258ac/html5/thumbnails/22.jpg)
IF - ELSE
• When a conditional is placed, it creates several locations where additional tiles may be inserted.• A third insertion point is the arrow below the
conditional tile. This occurs where the forking program paths rejoin. A tile place here will execute regardless of whether the condition was TRUE or FALSE.
![Page 23: The Scribbler GUI](https://reader033.vdocuments.mx/reader033/viewer/2022052414/56813a60550346895da258ac/html5/thumbnails/23.jpg)
![Page 24: The Scribbler GUI](https://reader033.vdocuments.mx/reader033/viewer/2022052414/56813a60550346895da258ac/html5/thumbnails/24.jpg)
ELSE - IFThere is yet another insertion point available
only if you happen to be inserting another conditional tile. It's just to the right of the conditional tile and is indicated by a vertical cursor.
![Page 25: The Scribbler GUI](https://reader033.vdocuments.mx/reader033/viewer/2022052414/56813a60550346895da258ac/html5/thumbnails/25.jpg)
ELSE - IF
By inserting additional conditionals in this fashion, you can create multi-way branching in your program, as the example illustrates. Here, all possible obstruction conditions are being tested with a motion response for each one.
Notice that the last condition (no obstruction) doesn't need an explicit test, since it will be the one that's TRUE if, and only if, the other three are FALSE.
![Page 26: The Scribbler GUI](https://reader033.vdocuments.mx/reader033/viewer/2022052414/56813a60550346895da258ac/html5/thumbnails/26.jpg)
![Page 27: The Scribbler GUI](https://reader033.vdocuments.mx/reader033/viewer/2022052414/56813a60550346895da258ac/html5/thumbnails/27.jpg)
What can we read/observe?Obstacle sensors
![Page 28: The Scribbler GUI](https://reader033.vdocuments.mx/reader033/viewer/2022052414/56813a60550346895da258ac/html5/thumbnails/28.jpg)
Obstacle sensorcondition• The obstacle sensor uses the two infrared LEDs on the
left- and right-front of the Scribbler, along with the IR detector in the middle-front to detect light reflected from obstacles in its path. Each of the four possible combinations of left and right obstacles represents a separate condition. You can also restrict how many consecutive times the condition must be observed for it to be TRUE.
• In the example above, the condition of “left obstacle present and right obstacle absent” must hold for four or more successive observations for the condition to be TRUE.
![Page 29: The Scribbler GUI](https://reader033.vdocuments.mx/reader033/viewer/2022052414/56813a60550346895da258ac/html5/thumbnails/29.jpg)
![Page 30: The Scribbler GUI](https://reader033.vdocuments.mx/reader033/viewer/2022052414/56813a60550346895da258ac/html5/thumbnails/30.jpg)
Program P2: FearMake a copy of program P1, and use it as the basis for
P2.
Add the following functionality:Read the obstacle sensors.Program the robot to react by moving away from the
obstacle, if present (simulating fear).
Q5: Experiment and determine the range (closest and farthest) of the obstacle sensors. Describe your experiment in a paragraph and report your results.
![Page 31: The Scribbler GUI](https://reader033.vdocuments.mx/reader033/viewer/2022052414/56813a60550346895da258ac/html5/thumbnails/31.jpg)
![Page 32: The Scribbler GUI](https://reader033.vdocuments.mx/reader033/viewer/2022052414/56813a60550346895da258ac/html5/thumbnails/32.jpg)
Lab assignment deliverablesThe Subject of your single email must be:
CSC 120 IF lab <your name>(I will deduct points if you fail to do this.)
Include answers to questions Q1 through Q5.
Include the P1 .scb file and screen shot of P1.
Include the P2 .scb file and screen shot of P2.