Josh DiGiovanni's CS101 Robot Webpage

Wheatley the robot

About My Robot

This is Wheatley. He can follow movement commands, follow objects, play music, draw rectangles, make jokes, hack, act like a moron, and imitate an American accent.

About Me

My name is Josh DiGiovanni, and I'm from St. Louis. I am a CS Games major. I have always loved art and creativity, and since I also enjoy video games I thought designing them would be a great way to express my creativity. I like computer science and especially game designing because I simply enjoy creating things, be it artwork, games, or simple programs or webpages like this one. It really gives me a sense of accomplishment. In addition to drawing and of course playing games in my free time, I also like to listen to music and play guitar.




Lab 1


Part 1

Members: Josh DiGiovanni, Brian Chen, Matt Pohlmann, Maggi Yang

Robots: Wheatley, PikaChen, George, MYBot

Our group got each of our robots connected. George drew a square and Wheatley drew the rest of this beautiful piece of art.

Lab 1

"Could a moron do THAT?"


Part 2

Members: Josh DiGiovanni, Brian Chen, Matt Pholmann, Wayne Chi

Robots: Wheatley, PikaChen, George, Turtlehead

Wheatley

Line sensor: White - 0,0 ; Black - 1,1
IR sensor: 1=nothing ; 0=something
IR sensor distance: farthest=~16" ; closest=~1"
Obstacle sensor: 0=nothing ; 6400=something
Light sensor: indoors=~65000 ; flashlight=~1300

PikaChen

Line sensor: White - 0,0 ; Black - 1,1
IR sensor: 1=nothing ; 0=something
IR sensor distance: farthest=~12" ; closest=~1"
Obstacle sensor: 0=nothing ; 6400=something
Light sensor: indoors=~63000 ; flashlight=~1500

George

Line sensor: White - 0,0 ; Black - 1,1
IR sensor: 1=nothing ; 0=something
IR sensor distance: farthest=~15" ; closest=~2"
Obstacle sensor: 0=nothing ; 6400=something
Light sensor: indoors=~65000 ; flashlight=~1400

Turtlehead

Line sensor: White - 0,0 ; Black - 1,1
IR sensor: 1=nothing ; 0=something
IR sensor distance: farthest=~16" ; closest=~2"
Obstacle sensor: 0=nothing ; 6400=something
Light sensor: indoors=~65000 ; flashlight=~1300




Lab 2


Today Wheatley had to use all of his sensors. Twice he moved forward until he detected an obstacle, then moved backward until he detected an obstacle behind him. Afterward he asked me to shine some light on him so that he could play the Lost Woods song from the Legend of Zelda.

Myrotest.cpp File

LostWoods Header File




Lab 3


Members: Josh DiGiovanni, Brian Chen, Matt Pholmann, Richard Phillips

Robots: Wheatley, PikaChen, George, Swaggawagon

Our group wrote a code to draw the Fibonnaci spiral based on angular velocity.

Fibonacci Spiral

Fibonacci Spiral CPP File




Homework 1: Robot's Got Talent


Pre-Lab Answers

1. My robot will "sing" the Lost Woods song from the Legend of Zelda series. This will be done by assigning values to different variables depending on the frequency of the corresponding note, and arranging the beeps and wait times so as to imitate the song. To trigger this, the robot will say "Now that I have an ocarina, I can play a song for you!" and ask for someone to shine some light, so if a light is flashed in any one of the light sensors, the robot will call upon a header file to play the song.

2. My robot will draw the Triforce symbol from the Legend of Zelda series. It will do this by drawing three lines of equal length, and in between each one, it will turn 120 degrees left by calling upon a function from a header file. After the last line, it will go backwards halfway, turn 60 degrees left, then repeat the first step but with lines of half the length. To trigger this event, the robot will make sure that the battery level is above 6.5 and that it is not on a dark surface or in the air (using the Line sensors).

3. For the surprise ability, my robot will move backward in a random path until it detects an obstacle behind it (using the robot's IR sensors), wiggle a random number of times, say, "Wheatley got a Small Key!", and play a jingle from the Legend of Zelda series. Then it will move forward in a random path until it detects an obstacle in front (using the Fluke's center IR sensor), wiggle again, say, "Wheatley got the Fairy Ocarina!", and play a different jingle from Zelda. The number of times it wiggles each time can range from 1 to 4, based on the rand() function. To trigger this event, the user must input "Yes!" once the robot asks, "Are you ready for a surprise? (Not like you have a choice...)".

4. My robot's performance will consist of the drawing first, then the surprise, then the song. The drawing (and hence, the whole performance) will be triggered if the battery is above 6.5 and the robot is not on a dark surface or in the air. After the drawing, the robot will say, "You have 5 seconds to remove the pen!" and wait 5 seconds before moving forward to reveal the drawing. It will then ask the user the question to trigger the surprise. After the surprise, the robot will say that it can play a song because it acquired the Fairy Ocarina. Once the user flashes light in one of the light sensors, the robot will play the song and its performance will end once the song is over.

Video of the Performance

Wheatley starts by drawing the Triforce. Then he asks for user input to initiate a surprise. In the surprise, Wheatley moves backward in a random path until he detects an obstacle, then wiggles from 1 to 4 times and plays a short sequence of notes. He then does the same thing, except this time moving forward. Finally he asks for the user to shine a light into one of the sensors and plays the Lost Woods theme from the Legend of Zelda series.

Code Used

Performance CPP File, LostWoods Header File, turnRightDegrees Header File, turnRightDegrees Header File




Lab 5


Members: Josh DiGiovanni, Brian Chen, Matt Pholmann

Robots: Wheatley, PikaChen, George

We each had to write 4 Braitenberg vehicle functions: alive, coward, aggressive, and one of our choice. George chose to be indecisive, and PikaChen chose to be paranoid. Wheatley chose to be timid, meaning he moved forward until he detected a shadow. This was done by detecting light greater than the ambient light threshold, with a buffer of 350. First, he asked for user input to determine which of the 4 actions to take. Depending on which number the user entered, Wheatley exhibited the corresponding behavior.

Braitenberg Vehicle Code




Homework 2: The Robot Games!


Group Members: Josh DiGiovanni, Brian Chen, Matt Pohlmann, Ken Chang

Pre-Lab Answers

1. Robot will play the fight song using the beep() command located in a header file. To allow user input and help spell out 'USC', the robot will accept user input such as w, s, a, and d to continuously move forward, back, turn left, and turn right. Inputting q or e will turn the robot a small, fixed amount and pressing space will stop the robot. Entering ` will end this segment and return to the behaviors menu.

2. This process uses multi-threaded processes to accomplish its task. In the first thread, the robot moves forward checking both Line Sensors continuously and at the same time using a vector. This saves time (~0.25 seconds) getting the values instead of checking each individually (~0.5 seconds). Robot moves forward while both sensors detect a line; if the left sensor leaves the line, the robot turns to the right and vica versa. The second thread waits for user input; when the user inputs "stop" the program will terminate both threads and return to the behaviors menu.

3. The robot will move forward while the center obstacle sensor reports 0. Once it doesn't, the robot turns left or right depending on which obstacle sensor reports the lower value. If both values are equal, the robot chooses which way to turn depending on the result from rand () % 1 (seed based on time). All of this is done in a while loop that repeats as long as the battery is greater than 6.5. Each time it starts moving forward, an integer variable starting at 0 is incremented to keep track of how many times it moves forward. Once the variable = 7 (the number of times it should move forward according to the example maze), it waits 2 seconds to allow the robot to exit the maze, then stops and breaks the while loop, returning to the behaviors menu.

4. The robot utilizes multiple functions to draw the Sierpinski Triangles in the most efficient way possible: draw each third of the largest triangle, simultaneously forming the outter triangle. When finished, the robot will beep to say that it is done until a user shines at light in the light sensors to end this behavior and return to the main menu.

5. The algorithm that decides how the entire program procedes is as follows. The program parses user integer input into a switch statement that calls the appropriate function.

Code Used

Code Zip File




Homework 3: Urban Search and Rescue


Group Members: Josh DiGiovanni, Brian Chen, Matt Pohlmann, Cherys Fair

Pre-Lab Questions

1. Write a description of your team's USAR strategy. What is your algorithm and sensors used for this task?

2. Write a description of your robot's performance for navigating through the mock disaster area. What is your algorithm and sensors used for this sub-problem?

3. Write a description of your robot's locating lost scribblers behavior. What is your algorithm and sensors used for this sub-problem?

4. Write a description of your team's mapping strategy. What is your algorithm for this task?

Pre-Lab Answers

1. For Wheatley's individual role in this, if the battery is greater than 6.5, a menu will be printed. This will give the user the option to navigate the area, show slideshows, print movements (for mapping), edit pictures, or exit the program. To start off, all the robots will take pictures at slightly different angles (so we know where we started and have a good view of the area). Then they will all move in different directions and take as many pictures as possible. Whenever Wheatley detects an object, I will tell him to take a picture.

2. A function used to manually navigate the area will be called if the user chooses to do this. The program takes WASD user input to move around (a separate function is called to turn left or right based on degrees), using a switch statement. If there is an object in front or an object behind (determined using the obstacle and IR sensors) the user will be told that the robot is unable to move forward or backward respectively, and the robot won't move. Q is used to exit the function.

3. As part of the function used to navigate the area, E is used to take a picture, which is stored in an array, the index of which is then incremented. If the user chooses to edit pictures, they will be asked which picture to edit. For loops will be used to edit this picture so that a grid is drawn on it. This picture will also be stored in an array of edited pictures, and the user will be asked to input the x and y coordinates of the top left and bottom right corners of the bounding box. A function to edit the picture is then called. In this function, 2 separate for loops are used to change the color of pixels, based on the x and y coordinates, to green, so that a bounding box is formed. After this, the index of the array of edited pictures is incremented.

4. Mapping will be based on the movements of the robot as it navigated the area. In the WASD function, each action by the robot assigns a different integer value to the index of an array keeping track of the movements (1 for forward, 2 for backward, 3 for left, 4 for right, 5 for picture). After this value is assigned, the index is incremented. A separate function (called if the user chooses to print movements) uses this array to print the robot's actions in the order in which they occurred, using a switch statement. Looking at these actions, it will be easier to determine where pictures were taken relative to each other, so that the Scribblers' locations can be mapped.

Code Used

USAR-jmdigiov




Homework 4: MARS Rover


Pre-Lab Questions:

1. Write a description of your search algorithm for finding aliens in pictures for MARS.

Using nested for-loops, it iterates through the width and height of the picture. Beforehand, x1 and y1 are declared as the width and height, respectively, and x2 and y2 are declared as 0. If a pixel falls within the predetermined RGB range, x1 and y1 are set equal to the pixel's x and y values (only if these values are initially smaller than x1 and y1), and x2 and y2 are set equal to the pixel's x and y values (only if these values are initially larger than x2 and y2). That pixel is also colored black so that the user can see where the program found aliens. Using boolean variables, the program keeps track of whether an alien has been found and whether there is a gap between aliens. If it iterates vertically through the picture and no pixels have been found within the RGB range, the gap variable is set to true. At the end of the first for-loop, if there is a gap and an alien has been found, an Alien object is dynamically created and its size is set to the dimensions, its location is set to the y2 value, and its number is set to a number integer that is then iterated. This object is stored in an array of pointers (alienPtrs), and then x1, y1, x2, and y2 are set to their original values.

2. Write a description of your class Alien. What are its data members? What are its member functions?

Its data members are the minimum and maximum RGB values, the size, the location, and the number (used to differentiate one alien from another). Its member functions are the constructor, the destructor, and the getters and setters for all of the data members.

3. Describe your process for developing your object recognition algorithm.

I realized that I had to first find pixels within an RGB range and then make sure there were no errors in getting the dimensions (this is why I initially declared the x1, y1, x2, and y2 values - so that I could make sure x1 and y1 were the smallest possible values and x2 and y2 were the largest). Then I had to focus on creating individual Alien objects, which could only be done by detecting gaps between aliens. I realized the best way to do this was detecting vertical gaps and using boolean variables so that the program knew when an alien was found and when a gap was found.

4. Which picture did you start testing your algorithm with first? Why did you choose to start with that picture?

When I was just focusing on getting the RGB detection right, I used mars1.jpeg to test the algorithm. This is because it was the most simple picture with an alien, so I could just focus on making sure the program detected the green pixels. When I modified my algorithm to create distinct Alien objects, I used mars2.jpeg because there were 2 aliens.

5. Write a description of your sorting algorithm for aliens by size.

It uses bubble sort, which iterates through each value in the array n times and swaps adjacent values if they are not in the correct order. In this case, the getSize member function is used to compare the sizes of the elements in alienPtrs. The elements are sorted from largest to smallest.

6. Write a description of your sorting algorithm for aliens by closeness to the rover.

This also uses bubble sort. The getLocation member function is used to compare the locations of the elements in alienPtrs. The elements are sorted from closest (largest integer value) to farthest (smallest integer value).

7. What is the Big O of your sorting algorithms?

Each of the sorting algorithms is bubble sort, which has nested for-loops, so the Big O is n^2.




Final Project: What is Computer Science?

Pre-Lab Questions:

1. Write a description of your CS topic that you are trying to teach/demonstrate.

My CS topic is algorithms and their importance in the field of computer science. I will briefly go through my algorithm for the demo to show the importance of problem-solving in computer science, and specifically game development.

2. Write a description of how your program will engage the user.

My demo will include a game that directly engages the user in the problem-solving process. The game challenges the user to defeat an enemy by bringing its health exactly to 0. This is meant to encourage the user to go through the problem step-by-step, and thus actively engage in the process of algorithm development.

3. Describe your process for developing your human-computer interface.

My HCI is the game itself. The program will take user input as the user participates in a turn-based battle. The user can attack, look at descriptions of the attacks, and plan a strategy.

4. Describe how you will evaluate your human-computer interface.

Mainly this will be evaluated by keeping track of the time it takes for users to complete the game. If it took them longer, it's possible they got stuck at some point (unless they chose the option to "plan a strategy", in which case it's possible they spent time going through the problem-solving process).

5. Describe how you will evaluate the user's interaction.

I will evaluate user interaction based on whether they beat the game, how much time they spent, and whether they chose to develop a strategy. If they chose to develop a strategy, that shows that they engaged in the algorithm-development process. For those who won, the amount of time they spent is a good indicator of how much thought they put into algorithm-development.

6. Write a description of how your program will collect user interaction information.

Using a Player class, the program will record for each user whether they won, how much time they spent, and whether they chose the option to plan a strategy. This information is then sent to an output.txt file.

7. How will you generate an evaluation report based on the user data collected?

Using file IO, the program will read the output.txt file and generate a report.txt file. This report will include a table of wins and losses, time spent, and strategy planning. This table will show if there is a correlation among these 3 variables. A greater amount of wins will indicate that the demo was successful (at least to some degree).




Valid XHTML 1.0 Transitional!Valid CSS!

The University of Southern California does not screen or control the content on this website and thus does not guarantee the accuracy, integrity, or quality of such content. All content on this website is provided by and is the sole responsibility of the person from which such content originated, and such content does not necessarily reflect the opinions of the University administration or the Board of Trustees