Craig



Craig moves pretty fast like really fast.
The coolest thing it can do is draw!

I love computer science because it calms me (kind of have a little ADHD) but I love that there is an unlimited number of possibilities that can arise from this field of work.

This summer I went on a Eurotrip with 5 of my closest friends. We went to Spain, Switzerland, and Italy. Definitely my favorite activity was running with the bulls in Pamplona.

My hobbies include snowboarding, cliff diving, and wakeboarding.

I am passionate about the programs that I have or am creating and I hope to be able to discover so much more in the field of computer science at USC.


My first drawing:
(click to enlarge)

Teammates: Joey David Maggi


Testing out all of the sensors. Teammates: Zach David Eric

Name Robot Name Line Sensor (Light Surface) Line Sensor (Dark Surface) IR Sensor (All Clear) Left/Right IR Sensor (Obstacle) Left/Right Light Sensor (Cover) Left/Center/Right Light Sensor (Bright Light) Left/Center/Right Obstacle Sensor (All Clear) Left/Center/Right Obstacle Sensor (Obstacle 1' Distance) Left/Center/Right Battery
Eric Rastabot 0 1 1/1 0/0 65296/65161/65148 57865/51111/52450 0/0/0 6400/6400/6400 7.10156
Brendon (ME) Craig 0 1 1/1 0/0 64658/65257/64933 63725/64763/64587 0/0/0 6400/6400/6400 7.19688
Zach Doug 0 1 1/1 0/0 64752/65289/64908 64388/65194/64698 0/0/0 6400/6400/6400 7.57818
David Furiosity 0 1 1/1 0/0 64909/65064/65023 58987/50356/60934 0/0/0 1280/640/3200 7.24455

Lab 9/14/12 - Using For Loops, While Loops, and More

 #include Myro.h #include math.h #include stdio.h #include iostream using namespace std; int main() { connect("/dev/rfcomm0"); cout << "Waiting..." << endl; robot.setName("Batman"); //While loop that makes the scribbler never stop moving while avoiding obstacles while(robot.getObstacle("center")<= 6400) { if(robot.getObstacle("center") != 6400) { robot.forward(1,1); } if(robot.getIR()[0] == 1 && robot.getObstacle("center")== 6400) { robot.turnRight(1, .7); } if(robot.getIR()[1] == 1 && robot.getObstacle("center")== 6400) { robot.turnLeft(1,.7); } if(robot.getIR()[0] == 0 && robot.getIR()[1] == 0 && robot.getObstacle("center")== 6400) { robot.turnRight(1,1.4); } } //For loop that draws a shape :) cout << "Enter # of Sides: "; int sides; cin >> sides; for(int k=0; k< sides; ++k) { if(robot.getLine()[0] == 0 && robot.getLine()[1] == 0) { if(sides == 3) { if(robot.getObstacle("right") == 6400) { robot.beep(.2, 990); robot.beep(.2, 970); cout << "Obstacle on the right" << endl; break; } robot.turnRight(1,1); robot.forward(1,.7); } if(sides == 4) { if(robot.getObstacle("center") < 6400) { robot.forward(1,1); if(robot.getObstacle("right") < 6400) { robot.turnRight(1,.7); } else { robot.beep(.2, 990); robot.beep(.2, 970); cout << "obstacle on right" << endl; } } else { robot.beep(.2, 990); robot.beep(.2, 970); cout << "obstacle in center" << endl; break; } } } } double batteryLife = robot.getBattery(); cout << "Battery: " << batteryLife << endl; string message = "Justice is served!"; cout << message << endl; cout << "Disconnecting" << endl; disconnect(); }


Fibonacci Spiral

#include Myro.h #include math.h #include stdio.h #include iostream using namespace std; int main() { connect("/dev/rfcomm0"); double times; cout << "Times: (between 0 & 6)"; cin >> times; int oldNumber = 1; int newNumber = 0; double displayNumber; double speed = 0; for(int k=0; k < times; ++k) { displayNumber = oldNumber + newNumber; oldNumber = newNumber; newNumber = displayNumber; speed = displayNumber/10; if(displayNumber == 1) { speed = 0; } cout << displayNumber << endl; robot.motors(speed, 1); wait(displayNumber); } robot.stop(); disconnect(); }

Teammate:
Nicky
Parker
Skyler


Video of the Talent:

Download Program: Talent


Pre Lab
1. Write a description of the song(s) your robot will sing and what is your algorithm and sensors for triggering the song.
My robot will sing the batman theme song and my algorithm will check to make sure that the line sensors read a dark surface and there are no obstacles around.

2. Write a description of what your robot will draw and what is your algorithm and sensors for triggering the drawing(s).
My robot will draw the batman logo using a for loop to make sure that it is always on a light surface (ie the white board). To ensure that the scribbler is on a light surface, I will use the line sensors.

3. Write a description of your robot’s surprise ability what is your algorithm and sensors for triggering the surprise ability.
My robot’s surprise ability is spinning while singing based on the rand() function. If the resulting number is less than 300 it will spin to the right and if it is greater than 300 it will spin to the left.

4. Write a description of what is your algorithm and sensors for triggering the structuring your robot’s performance.
My algorithm first checks to see that the battery level is at the performance level that I designed it to be at. Then a for loop runs to draw the batman logo with each loop it performs the next step in drawing the batman sign: while always checking the line sensors. After, the robot checks for obstacles and uses the getObstacle and getIR functions to make sure it is clear and moves forward off of the white surface. Then a rand() function is used to determine which way to spin while singing.



INSECT ASSIGNMENT

using namespace std;
double Ambient;
double normalize(int v)
{
	if(v > Ambient)
	{
		v = Ambient;
	}
	return 1.0 - v/Ambient;
}

void coward() {
	Ambient = (robot.getLight("left") +
	robot.getLight("center") +
	robot.getLight("right")) / 3.0; 
	while (true) {
		int L = robot.getLight("left");
		int R = robot.getLight("right"); 
		robot.motors(normalize(L), normalize(R));
	}
	
}



void alive() {
	Ambient = robot.getLight("center"); 
	while (true) {
		int L = robot.getLight("center");
		robot.forward(normalize(L)); 
		
	}
}

void aggressive() {
	Ambient = (robot.getLight("left") +
	robot.getLight("center") +
	robot.getLight("right")) / 3.0; 
	while (true) {
		int L = robot.getLight("left");
		int R = robot.getLight("right"); 
		robot.motors( -normalize(L), -normalize(R));
	}
}

double normaLove(int v)
{
	double mean = Ambient/2;
	double stddev = Ambient/6;
	if(v >= Ambient)
	{
		v = Ambient;
	}
	return exp(-((v-mean)*(v-mean))/(2*(stddev)*(stddev)));
}

void love() {
	Ambient = (robot.getLight("left") + 
		robot.getLight("center") +
		robot.getLight("right"))/3.0;
	while(true)
	{
	int L = robot.getLight("left");
	int R = robot.getLight("right");
	if(robot.getLight("center") < robot.getLight("right") && robot.getLight("center") < L)
	{
		robot.stop();
	}
	else
	{
	robot.motors(-normaLove(L), -normaLove(R));
	}
	}
}

int main()
{
connect("/dev/rfcomm0");

// Braitenberg vehicle#1: Alive
string choice;
cout << "What would you like to see? \n Alive? \n Coward? \n Agressive? \n Love?" << endl;
cin >> choice;
if(choice == "Alive")
{
alive();


}

if(choice == "Coward")
{
coward();
}

if(choice == "Agressive")
{
aggressive();
}

if(choice == "Love")
{
love();
}
else
{
disconnect();
}

disconnect();
}

TEAMMATES:
Nicky
Parker
Skyler

Description of Love:
"When the love function is run, the scribbler uses the light sensors and the motor functions along with the exponential function
provided in the book. The scribbler determines which direction the light source is coming from
and turns toward it. Once the scribbler is facing the light source it then stops and embraces the light: therby showing its love. :)"

Robot Games


#include 
#include 
#include 
#include 
#include 
using namespace std;
//Line Sensors: 0=Left, 1=Right
// Maze function used getline for the while b/c my carpet is black
		void maze() {
			while (robot.getLine()[1]==1) 
			{
			robot.forward(1);
			int obstacleleft = robot.getObstacle("left");
		 	int obstaclecenter = robot.getObstacle("center");
			int obstacleright = robot.getObstacle("right");
		if ( obstaclecenter >= 6400 && obstacleright >= 6400 ) 
				{
				robot.beep (1,950);
				robot.turnLeft(1, 1.75);
				robot.forward(1, 1);
				maze();
				} 	
		if ( obstaclecenter >= 6400 && obstacleleft >= 6400 ) 
				{
				robot.beep(1,950);
				robot.turnRight(1, 1.75);
				robot.forward(1, 1);
				maze();
				}
if ( robot.getObstacle("center") >=6400 && obstacleleft >= 6400 && obstacleright >= 6400) 
				{ 
				robot.forward(-1);
				robot.motors(-1,1);
				wait(3); 
				maze();
				}
		}		
		}
//AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
void line_cross(double Left , double Right)
{
	robot.motors(Left,Right);
}
 //Performs a 60 degree turn to the right
void turnRight()
{
robot.turnRight(1, .5);
}
 
//performs a 120 degree turn to the right
void right() {
robot.turnRight(1, 1);
}
 
//moves the robot forward 3 inches
void onward()
{
robot.forward(1,.385);
}
 
//turns the robot 120 degrees to the left
void turnLeft()
{
robot.turnLeft(1, 1);
}
int main()
{
	connect("/dev/rfcomm0");
	robot.setName("Roberto");
	cout << "Waiting..." << endl;
	wait(2);
	int A;
	cout << robot.getBattery() << endl;
	cout << robot.getIR()[0] << endl;
	cout << robot.getIR()[1] << endl;
	cout << "Whatcha want?" << endl;
	cout << "1. Line Follow" << endl; //Nicky
	cout << "2. Triangles" << endl; // Brendon
	cout << "3. Maze" << endl; //skyler
	cin >> A;
	if( A ==3 )
	{
	maze();
	}
	else if( A == 2 )
	{
	while(timeRemaining(120))
{
	 onward();
turnRight();
onward();
right();
onward();
right();
onward();
turnRight(); // finish first triangle
onward();
onward();
turnRight();
onward();
right();
onward();
right();
onward();
turnRight();
onward();
robot.turnRight(1, 1); // tippy top
onward();
onward();
onward();
turnRight();
onward();
right();
onward();
right();
onward();
turnRight();
onward();
robot.turnRight(1, 1);
onward();
onward();
right();
robot.forward(1, .75);
robot.turnLeft(1, 1);
onward();
onward();
robot.turnLeft(1, 1);
onward();
onward();
right();
onward();
onward();
}
}
	else if( A == 1)
    {
	while(true)
	{
	//forward direction being side without scribbler
	bool L1 = robot.getLine()[1];
	bool L2 = robot.getLine()[0];
	if(robot.getLight("center") < 30000)//disconnect condition
	{
	cout << "Waiting..." << endl;
	wait(5);
	cout << "Disconnecting" << endl;
	disconnect();
	return 0;	
	}	
	else if(L1 && L2)
	{	robot.forward(-.2);	}
	else if( (L2) && !(L1))//turn right
	{	line_cross(-.2,0);	}
	else if( (L1) && !(L2))//turn left
	{	line_cross(0,-.2);	}
	else if(!(L1) && !(L2))//makes it go reverse
	{
	robot.forward(.2);
	}
	else//alarm for fail all conditions
	{	
	robot.stop();	
	robot.beep(1,440);	
	}
	}
     }
	else
	{
	cout << "Waiting..." << endl;
	wait(5);
	cout << "Disconnecting" << endl;
	disconnect();
	return 0;	
	}

}



PRE LAB

1. 	The robot will be controlled by our group’s control algorithm that allows us to move the robot remotely. We will sit on the stairs and move our robots into position from the stairs so we can form the USC letters. Once our class is in position, we will all perform the Fight On! song.

2. 	The line following behavior has conditions for both sensors being on the line and for each individual sensor being off the line, as well as both being off the line. By judging the true or false statements of the line sensor to indicate whether the robot is following the line, the algorithm has the robot moving forward when the line is under, right when the right sensor is false and left when the left sensor is false, and backwards when completely off the line. The sensors used in the event are the line and light sensors.

3. 	The robot will use the IR sensors after having adjusted the sensitivity of the sensors. It will check the surroundings of the robot to determine which direction is the best option to go.

4. 	The drawing behavior uses a function to turn at a 60 degree angle and a 120 degree angle as well as a function that moves the robot 3 inches at a time. The robot does not use any sensors for this task and it does not go over a single line twice.

5. 	A menu feature will be implemented for the most efficient way of structuring. That way we can easily choose between our programs.


HW 3 Pre lab
1. Write a description of your team’s USAR strategy. What is your algorithm and sensors used for this task?
	We are going in with our two working scribblers and if the scribbler comes across something in its path it returns a true value and takes a picture. After taking the picture
	we will examine it for proof of a scribbler. One team member may also use a camera connected to the computer to stream images faster than the scribbler.
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?
	I am going to use the getObstacle sensors and the get Light sensors to check obstacles and dark areas. The algorithm will check on area once and never check it again because we only have 10 minutes it will try and see as many places as it can.
3. Write a description of your robot’s locating lost scribblers behavior. What is your algorithm and sensors used for this sub-­‐problem?
	We will make a mapping of the environment using the scribbler and once we find scribblers it will store their location in an array.
4. Write a description of your team’s mapping strategy. What is your algorithm for this task?
	We will take pictures and the map array will hold values for found scribblers. The array will be 2 dimensional and reflect the actual map of the environment.

Final PRoject Pre Lab
1.	Write a description of your CS topic that you are trying to teach/demonstrate. 
	The CS topic that I am trying to teach is games. I created the classic game snake using c++ to accomplish this task.
2.	Write a description of how your program will engage the user. 
	The user will have to shine a light into the getLight sensors to turn the snake actor. The goal is to eat the X’s and gain length for the snake. The game will continue forever until the user hits a wall. 
3.	Describe your process for developing your human-­‐computer interface 
	The scribbler offers a various assortment of sensors. By using the light sensors on the scribbler, the human will control the computer activity.
4.	Describe how you will evaluate your human-­‐computer interface. 
	Based upon how many X’s the user eats, I will be able to evaluate how well the human performs.
5.	Describe how you will evaluate the user’s interaction. 
	If the user can successfully eat 3 X’s he or she will be average at playing the game. 5 or more X’s means he or she is adept. 7 or more means the user is a god at snake.
6.	Write a description of how your program will collect user interaction 
information 
	The program will store the time and how many X’s the user eats.
7.	How will you generate an evaluation report based on the user data 
collected? 
	At the end of the game, the program will see how long the user took and how many X’s he or she ate. If the user took too long to eat the X’s then his or her score will be impacted.


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