Chapter 6 of the textbook discusses ways to make your robot exhibit different types of behavior. In this lab, you are asked to implement four different behaviors. You will work in teams of two, but each student should submit a copy of the program. You will work together on each behavior using an approach to programming called Pair Programming: “One, the driver, writes code while the other, the observer, pointer or navi- gator, reviews each line of code as it is typed in.” Each student should drive twice and navigate twice.
Before writing any code, you should write a paragraph or rough outline, sketching out the design of the behavior. After you have finished the code, you should write another paragraph commenting on how the behavior was implemented, reflecting on the differences between the design and the actual implementation.
Each behavior should be programmed as a function that runs for a specified amount of time in seconds. For each function, there should be a single outer for
or while
loop that does its thing for the specified amount of time. You should use each timing method (discussed in the "Back to Time" section of Ch. 4 of LCwR) at least once. Myro’s currentTime()
method is very useful for the while
loop based approach. (Extra credit if you can do it recursively without for or while!).
from Myro import *
init()
for t in timer(4):
if getLight("left") < 64000:
beep(.1, 880)
You are using: Simulated Fluke, version 1.0.0 Simulated Scribbler 2, version 1.0.0 Hello, my name is 'Scribby'!
from Myro import *
startTime = currentTime()
while currentTime() - startTime < 4:
if getLight("left") < 64000:
beep(.1, 880)
Submit an electronic copy of your lab using moodle. Your program should have your name, email, assignment description, the date, and collaboration statement at the top of the file as a comment. Your submission should be a zip file that expands to a folder with two files:
cmsc143-lab3-LASTNAME-FIRSTNAME/
lab3.py
lab3.pdf
or a single ipython notebook
cmsc143-lab3-LASTNAME-FIRSTNAME/
lab3.ipynb
lightSeeker(time)
¶A robot behavior that runs toward the light (getLight()
).
avoid(time)
¶A robot behavior that runs away from obstacles triggered by the infrared detectors (getIR()
or getObstacle()
).
securityGuard(time)
¶Do you have a feeling your roommate is snooping through your desk drawer? Write a program that detects if the drawer is opened and takes and saves a picture of the offender and then beeps loudly.
digitalCamera(time)
¶Write a function that takes and displays a picture when the light sensor is pressed. The left light sensor should take a color picture (takePicture()
) and the right sensor should take a gray-scale picture (takePicture(’gray’)
). Feel free to say “Cheese” before snapping the picture.