## Lab 2

Kalevala, my robot, has recently learned how to sense the world around her!

Robot Owner Line (left, right) Light (left, center, right) IR (left, right) Obstacle (left, center, right) Battery
Kalevala Erik 0, 0 64896, 64851, 64746 1, 1 0, 0, 0 7.38753
Juliana Jack 1, 1 65120, 65044, 65002 1, 1 6400, 5760, 6400 7.19688
Otto Daria 1, 0 65148, 65287, 65279 1, 1 6400, 6400, 6400 7.24455
Killa Paige 1, 48 12336, 12336, 12336 1, 1 0, 0, 0 7.29221

## Lab 3

My robot's pretty awesome. I've written a remote control program, from which the user can choose whether the robot should wander around the room, sing a scale, or output the data from its sensors.

## Homework 1

### Talent Show

For the talent show, Kalevala sings Saria's Song from The Legend of Zelda, draws a randomly generated asterisk, and wanders around the room like a Roomba!

1. My robot sings Saria's Song from The Legend of Zelda. The algorithm is simple, I merely call robot.beep at the correct frequencies and note lengths in successive order.
2. My robot draws an asterisk. First, the number of points is generated using rand(), adjusted for the values to fall between 10 and 15. Then, the robot uses a for loop to draw each individual point by turning for a random amount of time between 0 and 2 seconds, then moving forward and back for a random amount of time between 0 and 1.5 seconds.
3. My robot moves around the room, avoiding obstacles. Using a while loop and timeRemaining, the robot wanders for 30 seconds. If there is any obstacle in front of the robot, the robot determines which obstacle sensor detects a closer object, turning away from that sensor. If there is no obstacle, the robot moves forward.
4. The performance is rigidly structured: song, followed by drawing, ending with a wander around the room.
Right click -> save link as to see a video of Kalevala's performance

Click to download the source and binary for the talent show Here's an easy header file to draw an Asterisk.

## Braitenberg Vehicle

Kalevala is capable of acting as many Braitenberg vehicles, including Explorer. When acting as such, to quote the textbook, she tends to "come to rest turned away from the source and may wander away depending on the presence of other light sources."

## THE ROBOT GAMES

### Prelab questions:

1. There will be an if loop with user input options for choices of movement, left, right, back, or forward. After the loop is broken by a stop command, the robot will play the USC fight song. 2. The line following behavior utilizes the line sensors to follow a line beneath the robot. To do this, the robot frequently checks the data returned by the line sensors. If both sensors detect a line, the robot is directly atop the line and so it continues forward. If only the right or left sensor detects a line, the robot is beginning to stray and so turns to position both sensors over the line. If neither sensor detects a line, the robot turns in place in a last-ditch effort to recover the line. 3. The robot drives forward until the obstacle sensor sees an obstacle, then it will continue going until it is up against the obstacle. It will then look left, check for an obstacle, and if there is one it will check right and go forward. 4. The robotâ€™s algorithm for the fastest drawer is first to figure out the most efficient way to draw the shape (without retracing any lines). We will then figure out the speed of the robot so we can know how long it takes to travel 3 inches (the length of a small triangle) and also the time it takes for the robot to turn 60 degrees. Then the robot will draw the figure using the robot.turnLeft and robot.turnRight commands as well as the robot.forward command to navigate the drawing. 5. The terminal will ask for the user to input a, b, c, or d and each letter will correspond to one of the functions mentioned above.

## Playlist

Kalevala asks you what songs (or drawings) you wish her to play (or draw) and in what order. She then iterates through the playlist you made, playing (or drawing) each item you selected!

Source and binary here!

## Homework 3

### Urban Search and Rescue

#### Prelab Questions:

1. Each team member handles one quadrant of the room. The robot movement is handled by user input; taking a picture is just one of the commands the user can initiate. 2. The robot movement is handled by user input; taking a picture is just one of the commands the user can initiate. 3. The robot movement is handled by user input; taking a picture is just one of the commands the user can initiate. 4. The team maps out the locations of the lost Scribblers on a piece of paper after the search and rescue robots have been used to locate them.

Daria's Website Jack's Website Paige's Website