Wednesday, February 16, 2011

Day 19: The End?

Today was our last day of class.. a sad day for all of us who really enjoyed this class. I personally would like to thank professor mason for taking part in this class and teaching it for the first time! I especially appreciate all the things he did for us that were actually not part of the class (directly), but instead was just him going out of his way being the great professor he is~ Thanks mason!

Anyways, TC and I presented today and we received a B grade on our presentation due to lacking enough detail on conclusion and lack of sufficient testing on our robot.


Also, while the other groups were presenting everyone packed up their stuff and got their toolboxes sorted. We all packed everything up nicely how we received it and waited for mason to come around and check off our stuff.



It was kind of sad putting everything away, knowing that we weren't going to be using it anymore, but we (or at least I ) were (was) glad that we (I) took this class because it taught us so much and really was fun. Even though it was a hectic schedule which i do not recommend and there was a lot of rushing on several days, it was a good experience and I am glad i had the opportunity to take this class.

Day 18: (Tuesday of the last week of class)

We were given a presentation on giving presentations & asked to start planning our presentations for presenting wednesday.

We split our PowerPoint slides between each other & got 2 work!



Tuesday, February 15, 2011

Day 16 & 17: COMPETITION

Friday we had extra time to work on some things. We spent most of the time programming again and spent a little bit of the time working on our final build.

Saturday was the competition and TC and I were worried because our design had been working about 80% as much as we wanted it to and saturday morning it was about 70%.
We decided to go to the competition earlier-arriving at 11am.
We started working on it as soon as we got to Cal State Fullerton. We eventually decided to go with the less complex code from the day before because all of the new changes that came into our build only slowed us down and reduced the robot's total performance.
We decided to go with a name chosen by one of our classmates with respect to the robot's appearance.
Name: BABY SCORPION.

SUCCESS (LOL by luck!)
We placed 2nd in the championship being 1 of the 2 only robots to succesfully get a can to the end. Our robot was, at this point, working to 85% efficiency, but it still had some grave bugs to be worked out.


here is the video:



This is the latest code I have.. which is 95% similar to the code we used on the day of the competition... Minor changes were made by my partner TC and I did not get a chance to get that from him.


#pragma config(Sensor, in1, linesensor, sensorLineFollower)
#pragma config(Sensor, in2, colorsensor, sensorReflection)
#pragma config(Sensor, in3, encoder, sensorRotation)
#pragma config(Sensor, in4, sonar, sensorSONAR, int1)
#pragma config(Motor, port2, leftmotor, tmotorNormal, openLoop)
#pragma config(Motor, port3, rightmotor, tmotorNormal, openLoop, reversed)
#pragma config(Motor, port4, rightarm, tmotorServoStandard, openLoop)
#pragma config(Motor, port5, leftarm, tmotorServoStandard, openLoop)
#pragma config(Motor, port8, platform, tmotorNormal, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//

void checkline()
{
if (SensorValue[linesensor] > 450)
{
motor[leftmotor]=-40;
motor[rightmotor]=-40;
wait1Msec(1000);
motor[leftmotor]=40;
motor[rightmotor]=-40;
wait1Msec(1000);
motor[leftmotor]=0;
motor[rightmotor]=0;
wait1Msec(50);
}
}
void goforward(int gotime) //go forward function
{
motor[rightmotor]=45;
motor[leftmotor]=45;
checkline();
wait1Msec(gotime);
checkline();
motor[rightmotor]=0;
motor[leftmotor]=0;
checkline();
}
void pause(int gotime) //pause function
{
motor[rightmotor]=0;
motor[leftmotor]=0;
checkline();
wait1Msec(gotime);
}
void goback(int gotime)
{
motor[rightmotor]=-40;
motor[leftmotor]=-40;
checkline();
wait10Msec(gotime);
pause(100);
}
void turn(int gotime) //turn function
{
motor[rightmotor]=35;
motor[leftmotor]=-35;
checkline();
wait1Msec(gotime);
checkline();
motor[leftmotor]=0;
motor[rightmotor]=0;
}
void tilt(int gotime) //tilt color sensor function
{
motor[platform]=35;
wait10Msec(gotime);
motor[platform]=0;
wait10Msec(20);
motor[platform]=-25;
wait10Msec(gotime);
motor[platform]=0;
}

short given1=0; //variable for first given color
short given2=0; //variable for second given color
short mission=0; //variable for defining what mission robot is on
int count=0; //counter for loop assigning colors to givens
short carry=0;
bool go;
bool finish;


void closeclaw()
{
motor[leftarm]=10;
motor[rightarm]=10;
wait10Msec(200);
}

void openclaw()
{
motor[leftarm]=160;
motor[rightarm]=160;
wait10Msec(20);
}

void check(int gotime1,int gotime2,int gotime3)
{
pause(gotime1);
tilt(gotime2);//tilt color sensor
pause(gotime3);
count ++;
}

void rightcolor()
{
//Move to color zone that matches color of can
finish=true;
carry=1;
}

void wrongcolor()
{
//Get rid of can
openclaw();
goback(200);
turn(100);
finish=false;
}

void checkcolor()
{
closeclaw();
wait10Msec(200);
int color1 = SensorValue[colorsensor];
if (color1 <> 18) //Is it red
{
if (given1==8) //red is the target color?
{
rightcolor();
}
else
{
wrongcolor();
}

}//check to see if color is green
if (color1 <> 328) //Is it green and is green the target color?
{
if (given1==6) //green is the target color?
{
rightcolor();
}
else
{
wrongcolor();
}

}//check to see if color is blue
if (color1 <> 628) //Is it blue and the target color is blue?
{
if (given1==7) //blue is the target color?
{
rightcolor();
}
else
{
wrongcolor();
}
}
if (color1 > 1000) //Not one of the above Maybe we should sense again
{
openclaw();
}
}

void search()
{
while(go==true)//search for can
{
openclaw();
if (SensorValue[sonar] <=-1 || SensorValue[sonar] >=20)
{
goforward(200);
pause(50);
checkline();
goforward(100);
pause(50);
checkline();
turn(100);
checkline();
pause(150);
}
if (SensorValue[sonar]>=3 && SensorValue[sonar]<20)>
{
goforward(150);
pause(50);
}
if (SensorValue[sonar] <3>=1) //if something is in close range
{
goforward(40);
pause(100);
go=false;
checkcolor();//closeclaw();

}
}
}

void end()
{
pause(200000);
}

void searchfloor()
{
if (SensorValue[colorsensor] >1000)
{
pause(1000);
goforward(20);
checkline();
pause(150);
int color2=SensorValue[colorsensor];
if (color2 <> 18) //Is it red
{
if (given1==8) //red is the target color?
{
openclaw();
end();
}
else
{
goforward(50);
}

}//check to see if color is green
if (color2 <> 328) //Is it green and is green the target color?
{
if (given1==6) //green is the target color?
{
openclaw();
end();
}
else
{
goforward(50);
}

}//check to see if color is blue
if (color2 <> 628) //Is it blue and the target color is blue?
{
if (given1==7) //blue is the target color?
{
openclaw();
end();
}
else
{
goforward(50);
}
}
pause(250);
}
}

void goforever()
{
while(true)
{
checkline();
motor[rightmotor]=40;
motor[leftmotor]=40;
wait1Msec(50);
checkline();
searchfloor();
}
}

task main()
{
bMotorReflected[leftarm]=1;
while(true)
{
if (carry==0)
{
openclaw();
}

do
{ //look forward for first color given1
//check to see if color is red
if (SensorValue[colorsensor] <> 18)
{
if (given1==0) //if given1 has not been set, set to red
{
given1=8;//red
check(500,30,750); //pause,tilt,pause,count++
}
else //else set given2 to red
{
given2=8;//red
check(500,0,0); //pause,no tilt, no 2nd pause, count++
}

}//check to see if color is green
if (SensorValue[colorsensor] <> 328)
{
if (given1==0) //if given1 has not been set, set to green
{
given1=6;//green
check(500,30,750); //pause,tilt,pause,count++
}
else //else set given2 to green
{
given2=6;
check(500,0,0);
}
}//check to see if color is blue
if (SensorValue[colorsensor] <> 628)
{
if (given1==0) //if given1 has not been set, set to blue
{
given1=7;//blue
check(500,30,750);
}
else //else set given2 to blue
{
given2=7;//blue
check(500,0,0);
}
}//end color sense
} while(count<=2);

pause(100);
motor[leftmotor]=40;
motor[rightmotor]=40;
wait10Msec(50);
pause(20);

if(count>=2 && count <=4)
{
go=true; //allow for next loop
count++;
}

search(); //search for can

if (finish==true)
{
motor[platform]=30;
wait10Msec(25);
motor[platform]=0;
wait10Msec(10);
pause(100);
goforever();
checkline();
}
if (finish==false)
{
search();
}
}
}

Friday, February 11, 2011

Day 15: Final Day before Competition

We got all of our building done and most of our testing done as well as a lot of the programming. We spent all day fine tuning our code and making sure we weren't leaving anything out. We kept having problems with running something infinitely and not running at all, but we got mostly everything sorted out. We did not completely finish, but we have something going on and that's what counts!

This is our robot being programmed:


Thursday, February 10, 2011

Day 14: Problems, Bugs, and Fixes

We finally got some work done. We successfully tested all of our sensors and got started on the final programming tasks and refining some code. Then, it all fell apart... the color sensor was not reading the right color thinking everything was green. Then, the light sensor completely failed on us, it was not working at all except for whenever it wanted to. Eventually we got some better code written and we jiggled the light sensor in the right way ( i guess) because it started to work.

We finally started testing on the arena and ran 1/5 successfully.

This is our robot during testing:

Wednesday, February 9, 2011

Day 13: Applying Ideas & Installing Sensors

We began implementing TC's idea of a claw and while he was installing it and modifying it, I was designing the platform for the color sensor & installing it on the robot.

This is what we started with:






We decided to use an encoder to more efficiently maneuver the Color sensor. And we had to do some modifications to the location of the sonar to make room for other parts.

These are the results of the claw modifications & the color sensor installation:

Monday, February 7, 2011

Day 12: Planning and Brainstorming

Since we were no longer going to receive a packet with instructions to follow per daily basis, we now have just one thing to do: work on our robots for the competition.

I am still having problems with my color sensor, but i decided that it would have to wait for further testing dates as my teammate and I have planned for later this week.

So far we modified the vehicle and started working on a manipulator.

My color sensor looks a lot better than before, but it still needs some work.

This is my color sensor's current state:
This coming week we have to start building the manipulator and testing it, which, thanks to saturday, we are already ahead on.