Here you will find all you need to know about
my journey through the Computer Science program
at the University of Southern California.
Hello and welcome! I am currently a freshman studying CSCI
at the best school in the world: USC! I am fairly new to programming, but
am enjoying it so far. I am from Palo Alto, California, the home of entrepreneurship
and innovation. I love being outdoors, eating In 'n Out burgers and spending
time with friends. Fight on!
Sally, a scribbler robot, is my newest and most technologically
advanced friend. She is capable of moving forward, backward, turning spinning,
playing sounds and recognizing visual signals. She even has an HD camera
that allows her to perform a variety of tasks.
Homework 4 Prelab Questions: Mars Rover
1. The search funtion in the code checks the RGB values of the image to see if they fall within a specific range. The function tests for 3 different ranges, depending on the different RGB values of the alien colors. It marks each pixel with a 1, 2 or 3 depending on their color range. These markers are stored in a 2-D array that is the size of the image as each pizel contains a marked value. If the pixel does not fall within one of the 3 categories, it is marked as a background pixel and the function returns it as false.
2. The class alien stores information about each alien that the main function tests. It stores the location of the alien with an x and y data member. It stores the size of the alien by measuring the area of pixels occupied, as well as the maximum and minimum acceptable RGB values depending on the range of the values. Its member functions set and get the data members, size and x and y. These functions allow the user to view and edit the private data.
3. The object recognition algorithm finds the size of the connected pieces of pixels that are of the same type as described before, either type 2, 2 or 3 depdnding on the color of the pixel. The algorithm recursively checks each pixels value by checking one pixel and then all the pixels around that one pixel if it falls within type 1 2 or 3. This recursive function eventually checks all the area that the alien would encompass, only continuing to check the pixels if they fall within category 1, 2, or 3. After the function returns a value that does not fall within the same cateogry, the function stops and returns the size of the alien, which would be the sum of all the pixels that it checked that returned the same type.
4. My code uses MARS4 because it included the different alien colors and sizes. This allowed all parts of the code to be used on the picture.
5. The code uses selection sort. It takes the maximum size out of the remaining items and puts that alien size in the front. This sorts the list from largest size to smallest size.
6. I sorted the aliens closest to the rover by sorting the x coordinate of the location x and y. This algorithm was the same algorithm used to sort for size, but the comparisons were done using the x coordinate rather than the size attribute.
7. Selection sort has a big O of n^2, where n is the number of items to be sorted. It takes O(n) comparisons to find the maximum item, which has to be done n times.
This week in class my teammates Eamon Barkhordarian, Gabriel Mel, Greg Grabare and I programmed our robots to draw pictures as well as
explored the visual and audio sensors on the robot.
We programmed Sally to draw this circle on a white board earlier this week.
Sally has a light sensor with two modes, 0 and 1. 0 is light and 1 is dark.
This week we learned how to use the if, for and while loop in C++. We each wrote a piece of code that incorporated each of these loops in a way that also tested each of the sensors on the robot. The code I wrote tested Sally's visual, battery and IR sensors. Depending on certain conditions of the sensors, Sally would perform different actions. Below is the code I wrote that incorporated the loops and tested Sally's sensors.
This week in class we studied the mathematical sequence of the fibonacci spiral.
My team members Eamon Barkhordarian, Gabriel Mel, Greg Grabare and I
then translated the mathematical sequence into C++ code and programmed our
robots to draw the fibonacci spiral on a white board. Here is a picture
Here is the code we wrote to draw the fibonacci spiral.
Homework Assignment 1: Robot Talent Show
1. The song Sally will play is the chorus to "Call me Maybe."
Sally will use the robot.beep function and an equation that converts frequencies to
hertz to play the song. No sensors are triggered when playing the song.
2. Sally will draw my initials, AA, on the whiteboard. To do this, Sally
will perform a series of move commands. These commands will be in a for loop to draw the two AAs.
No sensors are triggered to draw the initials.
3. Sally will generate a random integer from 0-2. Each integer will have a task assigned to it.
The rand function will incorporate a series of if/else statements. If 0 is generated, Sally will spin
clockwise. If 1 is generated, Sally will spin counterclockwise. If 2 is generated, Sally will
play a series of musical tones. Sally's surprise is that she starts her performance only after a user
enters an answer to her question "Would you like me to start the talent show?" A picture of the code
terminal is beneath the video because the video does not show this.
4. Throughout the program, I test the battery sensor, the light sensor, the line sensor, the IR
sensors and the obstacle sensor. Many of these tests incorporate if/else statements and while statements.
Here is a video of Sally's performance. The terminal in the background has an explanation
of what Sally is doing as she is doing it.
Here is the link for the code for Sally's performance: http://www.mediafire.com/?fdcvadwh78bo97v
Here is the picture of terminal screen that requires a user to enter in an answer to Sally's question
"Would you like me to start the talent show?"
This week in lab we used user input to trigger four different behaviors on the robot. The three behaviors are "alive," "coward," and "aggressive" and "timid." The students I worked with were Eamon Barkhordarian, Gabriel Mel and Greg Grabare.
The function "alive" will cause Sally to move forward if she senses any light from the center sensor. The function "coward" will cause Sally to turn in the opposite direction of the light that is shining on her. The function "aggressive" will cause Sally to turn towards the direction that the light is shining. The function "timid" will cause Sally to move forward until she is under a shadow.
1. The code for the robot’s Opening Ceremony was created by group member Eamon.
It begins with a void function for the fight on song. The tempo is a flexible number that
can be manipulated in the terminal. The fight song uses robot.beep(second,hertz).
The user is allowed to input a character and a double for the movement of the robot.
WASD are the keys for movement and any number following that signifies the duration of
that movement in seconds. “cin” is used to allow the user to input characters and doubles
and a series of “if” statements using “robot.turnRight/left” and “robot.forward/backward”
for the movement.
2. Greg did the "Line Following" part of the robot Olympics. To do this, he defined four
variables, cruise, turn, left, and right. Left is equal to the value from the left Line
sensor, and right is equal to the value from the right Line sensor. The robot is oriented
backwards so left and right for motors and sensors are flipped. Cruise is used to set a speed
for the robot to move forwards and backwards while turn sets the speed for the turning robot.
The program then uses four while loops to decide how to follow the line. If both left and right
sensors detect a line, the robot moves forward. If the left sensor stops detecting a line, the
robot turns right. If the right sensor stops detecting a line, the robot turns left. I use a
wait function because this allows the robot to better follow the turns. If both sensors stop
detecting a line, the robot will move backwards. The program also outputs the Line sensor
values and tells the user what it is doing to make the program more user friendly.
3.The maze solving portion of the performance uses only the obstacle sensor. The robot will
continue forward until the obstacle sensor reports an obstacle in the front. When this
happens, the robot will turn 90 degrees to the left and take another obstacle reading.
If this reading indicates that there is still an obstacle in front of the robot, it will
then turn 180 degrees, or what would have been a right turn from the first obstacle sighting.
Then, because we’ve been told that the mazes will only include 90 degree left and right
turns, the robot will find a clear path either to the right or left, and continue forward
in that direction. This continues until the robot has found its way through the maze.
The maze traversal could be made considerably faster if one could take advantage of the
left and right obstacle sensors, choosing the clear direction first, but unfortunately,
the sensors do not provide valuable information (they are not really left and right
sensitive, as one might expect them to be). Therefore, the simple rule of always turning
left first has been used.
4. Anjali did the “Fastest drawing” part of the robot Olympics. To do this, she created
2 functions, T and R, standing for travel and rotation. These functions were created by
measuring the number of inches traveled in one second and the number of degrees rotated
in one second. It then compiled this information into an equation that allowed to enter
parameters for inches and degrees, incorporating the robot.forward commands and the
robot.turnRight commands. The robot can draw the sierpinski triangles without overlapping
any lines and without having a user pick up a pen out of the robot at any time. The entire
function was then placed in a new function called “Draw,” which can be triggered by
user input. This part of the program does not start unless the battery level is above 6.0,
thus incorporating an if/else loop.
5. The performance will be structured with a main menu allowing the user to decide on a
behavior by entering a certain number. This will be accomplished by using a while loop
that constantly takes input, and using if statements, executes the correct behavior.
There will also be an option to stop performance and disconnect from the robot.
Here is the link to download the code: http://www.mediafire.com/?os639jqpj98f3wt
HW3: URBAN SEARCH AND RESCUE TRAINING EXERCISE
1. Our team's strategy is to cover as much ground as possible in the 10 minutes we have. After each move, our robot will take a picture and assess the surrounding situation. Although our main tool to map out the area is the camera, we will also be using the other robot sensors in order to ensure our robot is in an environment that is safe before it starts mapping. The robot wil use a while loop that continually asks for the next behavior. We will be in control of telling it whether to move, take a picture or end the mission.
2. The robot will be told to move a short distance every few seconds. After each movement, it will stop and take a picture with the hopes of showing a 'lost' robot and also to inform the driver of its surroundings. This will involve using the while loop to input the behavior.
3. The primary sensor used will be the camera. A picture will be taken, and then pre-written code will be used to draw a box around the scribbler for ease of identification. The program will color rows and columns of pixels green in such an order that it will produce a box shape surrounding the scribbler robot.
Using the data from the slideshow, our team will place together the map of the room, incorporating all the available information from each picture before moving onto the next. We will integrate different picture data with our recorded movement commands to increase confidence and accuracy.
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