# Ena Trokic's Web Page

## Meet My Robot

This is my robot, Robby. He can move really fast and is very useful. I can also program the robot to draw different pictures!

My name is Ena and I am a freshman at USC studying Computer Science and Business Administration. I chose computer science because I think it is a really interesting field that allows one to work in a wide variety of places. I want to be a part of a team that is developing the next 'big thing' in the tech world.

I have many hobbies that I like to do in my spare time.

• I love traveling. I enjoy visiting my family in Europe whenever I get the chance.
• I am a very avid reader.
• I also love being outside in the sun, which is another reason why coming to school in Southern California is perfect.

Lab 1

Today during class, i worked with my fellow classmates to program the robot to beep and draw shapes. We succeeded making Row Bowe draw a star and a triangle!

I worked with Cathy to do this project, you can see her webpage here:

Cathy's Website,

Lab 1: part 2

Today we worked with the different sensors on the robot. There are two line sensors on the bottom of the robot. When the sensor shows up as a 0, that means that there is no line sensed at it is on a light surface. When a 1 shows up, then it is on a dark surface and it senses a line. All four of us got these results for the robots.

I worked with Victoria Dea, Ryan Stack, and Basil Sunier. You can view their webpages here:

Victoria's Website, Ryan's Website, Basil's Website,

Lab 1: Part 3

Today we tested the other sensors on the robot.

My Robot: Robby's Results

The IR sensors on my robot came back as 1 for both sensed and not sensed. The Obstacles Sensor came back as 0 for no obstacle and 6400 for an obstacle. The light sensor came back as 65403 for the left, 65110 for the center, and 65159 for the right. The battery sensor came back as 7.33987.

Ryan's Robot: Awesom-o

The IR sensors on my robot came back as 1 for sensed and 0 not sensed. The Obstacles Sensor came back as 0 for no obstacle and 6400 for an obstacle. The light sensor came back as 64530 for the left, 64777 for the center, and 64509 for the right. The battery sensor came back as 7.24455.

Basil's Robot: Blimpie

The IR sensors on my robot came back as 1 for both sensed and not sensed. The Obstacles Sensor came back as 0 for no obstacle. For obstacle he got 6400 for left and center and 5760 or the right. The light sensor came back as 65408 for the left, 65408 for the center, and 65408 for the right. The battery sensor came back as 7.24455.

Victoria's Robot: Stormy

The IR sensors on my robot came back as 1 for sensed and 0 not sensed. The Obstacles Sensor came back as 0 for no obstacle. For obstacle she got 6400 right in front of the sensor. The light sensor came back as 0,0, and 0 for full light. The battery sensor came back as 7.33987.

Victoria's Website, Ryan's Website, Basil's Website,

### Lab 3: Fibonacci Sequence

For this lab we were tasked with creating a spiral using a Fibonacci Sequence. We did this using two different methods. One spiral we made used the Fibonacci numbers to create a smooth spiral while the other was more measured.

This is what the spiral looked like when we used the first algorithm.

` `
``````
#include Myro.h
#include math.h
#include stdio.h
#include iostream

using namespace std;

int getFib(int n)
{
int result=0;
if(n>=2)
{
result= getFib(n-2)+getFib(n-1);
}
else
{
result=n;
}
return result;
}

int main()
{
connect("/dev/rfcomm0");
cout << "Waiting..." << endl;
wait(2);

cout << "Battery status: " << robot.getBattery() << endl;

for (int i=0; i<6; i++)
{

robot.motors(getFib(i)*.1,1);
wait(1);
cout << getFib(i) << endl;
}

cout << "Waiting to disconnect..." << endl;
wait(5);

cout << "Disconnecting. Goodbye." << endl;
disconnect();

return 0;
}
``` ```

This is what the spiral looked like when we used an algorithm that was more measured.

` `
``````#include Myro.h
#include math.h
#include stdio.h
#include iostream
using namespace std;

int fibonacciSequence(int round)
{
double numbers[round];

numbers[0] = 0;
numbers[1] = 1;

for(int i = 2; i <= round; i++)
{
numbers[i] = numbers[i - 1] + numbers[i - 2];
}
for (int n = 1; n <= round; n++)
{
robot.forward(1,numbers[n]/10.0);
robot.turnLeft(1,.733/3);
robot.forward(1,numbers[n]/10.0);
robot.turnLeft(1,.733/3);
robot.forward(1,numbers[n]/10.0);
robot.turnLeft(1,.733/3);
}
}
int main(int argc, char ** argv)
{
int round = 0;
connect("/dev/tty.Fluke2-01FB-Fluke2");
cout << "enter how many numbers you want in the sequence" <> round;
fibonacciSequence(round);
disconnect();

return 0;
}
``` ```

## My Robot's Got Talent!

As part of our first homework assignment, I had to create a program for Robby to show off all his talents to the rest of the class.

1. My robot sings Twinkle Twinkle Little Star as a part of his talent. For the song, he uses the battery and light sensors to know when to sing while in a 'while' loop to know when to sing.

2. My robot will draw a star while in a for loop that ensures he is on the white board with the line sensors. He will use the obstacle sensors, and if they read that there is no obstacle, Robby will proceed to draw a star.

3. My robot's surprise ability is either trace the star that he already drew, or to sing another song- Hot Crossed Buns. This occurs using the random number feature and not any particular sensors. Depending on what random number is generated, my robot will reveal a different talent.

4. My robot uses all of his sensors during his performance. His acts are done through the for, while and if commands. He will first draw a star, then sing Twinkle, Twinkle Little Star, and then reveal a third, surprise, talent.

If you would like to try out this performance on your own robot, you can use this code!

Robot's Got Talent Code!

Below is a video of Robby's performance:

## Lab 4: Behaviors

In this lab our group worked with declaring functions to make the robot act on various behaviors.

We made the robot perform the Alive vehicle, which made the robot move when it picked up a change in the light sensors.

The Coward vehicle made the robot turn away from the light source and the Agressive behavior made the robot turn toward the light source.

For the fourth behavior, I made my robot perform the Explorer vehicle, which basically made it move away from a light source and keep moving depending on other lights it picked up.

This is the code I used for the four behaviors.

I worked with these four group members:

Victoria's Website, Ryan's Website, Basil's Website,

## Robot Games!

### TEAM BREV

These are my teammates!

Victoria's Website, Ryan's Website, Basil's Website,

Prelab Questions:

1. During the Opening Ceremony of the Robot Games, the code we wrote allowed the robot to be able to be moved according to user Input on the computer and then to sing the Fight On! song. Using the while and if loops, we declared different variables to mean different actions to the robot. A "w" was to move forward, a "s" to move backward, an "a" to turn left, and a "d" to turn right. According to these commands, we are able to nave our robots into the correct formation for the opening ceremony. Then the robot will sing the Fight song. There are no sensors used for the functions in this event.

2. For the Line Drawing behavior, the main sensors used are the two line sensors on the bottom of the robot. Using these sensors allows us to control the robot by making it of forward when both sense a line, and backward when there is no line until it finds a line again. If the right sensor is on a line, and the left is not, then the robot will slowly turn to the right until the line is centered again, and vice-versa.

3. The main sensors used in the Maze Solving ability are the two IR sensors. Depending on whether these sensors sense an obstacle or not, the robot will either move forward or turn until there is a clear path for it to move again.

4. The Fastest Drawer behavior does not use any of the robot's specific sensors. It simply turns and moves forward according to the pattern described in the code in order for it to draw the triangular shapes.

5. In order to put all these behaviors together for our team, we wrote a code which first declares all the functions. In the int main() portion of the code, we allowed for user input to choose what function to use to make the robot perform a certain behavior.

This is the code we used for the robot games:

## Urban Search and Rescue

### Team VERB

These are my teammates!

Victoria's Website, Ryan's Website, Basil's Website,

PreLab Questions:

1. The strategy that Team Verb is planning on using for the USAR is to divide the search area into quadrants. When we enter the disaster area, each robot will take a picture of its surroundings. and then decide in which direction to move. The robot will also use its sensors to see if there are any obstacles in front or behind it so it can better judge its surroundings.

2. For navigating the maze, the robot uses user input to determine how to move. Based on what the user inputs, the robot will then either move forward or backward, or turn left or right. The Obstacle sensors are also in a continuous loop after each input to ensure that the robot can continue to search for victims without anything getting in its way. During navigation, the user will also to be able to choose when to take a picture of the surrounding in order to search and find the other robots.

3. When the robot takes a picture of the disaster area, the pictures all get put into arrays. My code then takes each picture and goes through the pixels looking for the first and last red pixels. Based on these two coordinates, the robot is then able to draw a a green square around the robot in the pictures because that is where the red pixels are concentrated.There are not any specific sensors used for this subproblem.

4. After our first 10 minutes of searching the disaster area are up, our team will then use the next 10 minutes to map out where we found the robots. We will do this by again, dividing the map into quadrants. Each member of the team will be responsible for mapping out any scribblers found in that area. We will do this by playing our slideshow of pictures, both the original and modified versions that have the located robots boxed, in order to analyze them and then convey this data onto our maps.

This is the code I used for the robot games:

## Mars Rover

PreLab Questions

1. In order to find pictures of the aliens in the different mars rovers pictures, my algorithm is to scan the pictures like a bar code. First, I will scan through all the pixels, turning all the pixels of the aliens to red and making everything else white through two nested for loops. Then, my function will scan through the pixels again, this time looking for red-which indicates an alien. In a while loop, i will scan through the image and find the coordinate of the first red pixel a well as the last and make that into an array of aliens. After it finds the end coordinate of the first alien the code will continue to search the picture through the same process for the other aliens, and store their locations as well.

2. In my Aliens class, I have several data members which include set and set width, get and set height, and get and set size. They take as input the first and last x coordinate and the first and last y coordinate in order to perform. The member functions of my class show what each data member does. The getWidth returns width and setWidth subtracts the max x from the min x in order to find the width. My getHeight returns the height of the alien and the setHeight subtracts the max y value from the min y value to get the height of the alien. The getSize function multiplies the width by the height of the alien to get the aliens size.

3. My Object Recognition algorithm works by scanning for red pixels in the image, first vertically and then horizontally because i approach the image like a barcode. Because o reset the colors in all the images to either be red, for the alien, or white, my function recognizes an alien when it finds red pixels.

4. The first picture that i started testing my code with was MARS1 because it has 1 robot in it and I needed to see if my code was functioning correctly in finding the ending and starting points. Then I tested MARS2 to ensure that my code could find one alien and save its size and location and then continue scanning the picture to find other aliens and store there info as well.

5. The sorting algorithm that I am using to compare the Aliens by size is selection sort. It works by finding the smallest size of alien that it calculated and moving it to the from of the list. It then proceeds to scan the rest of the list to find the smallest of the remaining sizes until it has sorted everything and reached the end.

6. In order to find alien closeness, I used the selection sorting algorithm again. Looking at a list of the second y coordinate for each robot, the the selection sort code brought the smallest coordinate to the front, which corresponded to an Alien that was the closest to the front of the picture. The code then went on to compare all the numbers and organize the rest of the list by pulling out the minimum of the remaining numbers.

7. The Big O of my sorting algorithm is n^2.