Thursday, February 17, 2011

DAY 18

Today we clean up.

Thank you Professor Mason for your guidance and inspiration.

Furthermore, we would like to thank John Davis for all his help on our series of projects.

Cheers Everyone!!!

Wednesday, February 16, 2011

DAY 17

Check out our presentation!!!

We all had a terrific time!!!

...well we try posting it but not sure how to post a powerpoint presentation.

Tuesday, February 15, 2011

DAY 16

The days after the competition was a huge relief but at the same a huge revelation of sort.

Testing is never ending.

Reprogramming is never ending.

Tweaking is never ending.

Now we start work on our presentation for the project and tell our story and lessons learn.

Thursday, February 10, 2011

DAY 15

Programming we found is the most complex aspect of all our task.

Our mechanics and sensors can work 100%, but without competent programming codes; nothing works.

As I have mentioned before. The robot can seek out and find the can. What about the rest?

It turns out the rest is a lot more work than we have time for.

The scan for can finds the can but we still need an approach the can routine. The robot can't just rush to the can and hope to hold it in upright. The robot needs to cautiously creep up to the can so it maybe able to capture or contain it in the upright position for color reading.

Even if it was able to approach the can close enough for containment, the arm needs to capture or secure the can gently so it doesn't knock over. A lower the arm subroutine was needed to actuate a competent secure the can routine that will always capture the can upright and not knock it over. Once the color is read, the robot needs to make decision base on the result of the reading. If it is not the correct color of choice, the can needs to be rejected and kept out of the robot's way. The ferris wheel will flip the other way and knock the top of the can from behind and push it out and knocking it down at the same time. If it is the correct color of choice, the robot keeps the can and work the subroutine for placing the can in its proper color region. We have a subroutine that does a random 90 degree turns when it lines up with any black lines. When ever we hit the black line, we use the ground color scan routine to check for the correct color over the black line--our arm is made to do such scan at convenience. No matter what can or what can color spot, we will find the place the can.

We did not have the arena to test this until the competition. ( we hadn't tweek and finish this part of the program in class ) but here's what we got the day before the competition along with post dated competition video.

We must admit that though we have much help from our professor concerning programming, we still have lots of work to do.


#pragma config(Sensor, in1, LeftLineSensor, sensorLineFollower)
#pragma config(Sensor, in2, RightLineSensor, sensorLineFollower)
#pragma config(Sensor, in3, Range, sensorReflection)
#pragma config(Sensor, in4, Color, sensorReflection)
#pragma config(Sensor, in5, Switch, sensorTouch)
#pragma config(Sensor, in6, LeftWheel, sensorRotation)
#pragma config(Sensor, in7, RightWheel, sensorRotation)
#pragma config(Motor, port1, LeftMotor, tmotorNormal, openLoop)
#pragma config(Motor, port2, RightMotor, tmotorNormal, openLoop, reversed)
#pragma config(Motor, port3, Servo, tmotorServoStandard, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//

int can_color = 3; //1 = RED,2 = Green, 3 = Blue
int foundcolor = 0; //This is the color found by the color sensor

void goforward(int time)
{
motor[port2] = 50;
motor[port1] = 50;
wait1Msec(time);
}

void gobackward(int time)
{
motor[port2] = -50;
motor[port1] = -50;
wait1Msec(time);
}

void TurnLeft(int time)
{
motor[port2] = 55;
motor[port1] = -53;
wait10Msec(time);
}

void TurnRight(int time)
{
motor[port2] = -55;
motor[port1] = 55;
wait10Msec(time);
}

void StopBot(int time)
{
motor[port2] = 0;
motor[port1] = 0;
wait10Msec(time);
}

void SlowArmDown ()
{
motor[port3] = -60;
wait10Msec(50);
motor[port3] = -40;
wait10Msec(50);
motor[port3] = -30;
wait10Msec(50);
motor[port3] = -20;
wait10Msec(50);
motor[port3] = -10;
wait10Msec(50);
motor[port3] = -0;
wait10Msec(50);
motor[port3] = -10;
wait10Msec(50);
motor[port3] = -20;
wait10Msec(50);
motor[port3] = -30;
wait10Msec(50);
motor[port3] = -40;
wait10Msec(50);
motor[port3] = -50;
wait10Msec(50);
motor[port3] = -60;
wait10Msec(50);
motor[port3] = -70;
wait10Msec(50);
motor[port3] = -80;
wait10Msec(50);

}

void gotocolor(int destcolor) //1 is red, 2 is blue, 3 is green
{ //Go to a line
while ((SensorValue[RightLineSensor] <>
{
goforward(1);
}
//Now we are on a line
if (SensorValue[RightLineSensor]>800)
{
StopBot(100);
while(SensorValue[LeftLineSensor] <>
{

TurnLeft(1);
}
StopBot(1000);
motor[port3] = -60;
wait10Msec(20);
motor[port3] = 0;
wait10Msec(20);

//Now the other sensor is over the line so the cart is straight on the line
// Now turn 90 degrees
TurnLeft(150);
StopBot(100);
motor[port3] = -60;
wait10Msec(20);
motor[port3] = 0;
wait10Msec(20);
}
else if (SensorValue[LeftLineSensor]>800)
StopBot(100);

{ while(SensorValue[RightLineSensor] <>
{
TurnRight(1);
}
StopBot(100);
motor[port3] = -60;
wait10Msec(20);
motor[port3] = 0;
wait10Msec(20);
//Now the other sensor is over the line so the cart is straight on the line
// Now turn 90 degrees
TurnRight(150);
StopBot(100);
motor[port3] = -60;
wait10Msec(20);
motor[port3] = 0;
wait10Msec(20);
}

}

//Check the color of the can. Right now there is just signalling IE pecking to indicate the color found
//for debugging purposes.
void colorscan()
{
foundcolor = SensorValue[Color];
if (foundcolor <>
{
StopBot(10);
motor[port3] = -60;
wait10Msec(20);
motor[port3] = -50;
wait10Msec(20);
motor[port3] = -60;
wait10Msec(20);
motor[port3] = -50;
wait10Msec(20);
motor[port3] = -60;
wait10Msec(20);
motor[port3] = -50;
wait10Msec(20);
gotocolor(1);
}
if (foundcolor > 500 && foundcolor <>
{
StopBot(10);
motor[port3] = -60;
wait10Msec(100);
motor[port3] = -50;
wait10Msec(100);
motor[port3] = -60;
wait10Msec(100);
motor[port3] = -50;
wait10Msec(50);
gotocolor(2);
}

if (foundcolor <> 100) //Green Peck 1 times
{
StopBot(10);
motor[port3] = -60;
wait10Msec(20);
motor[port3] = -50;
wait10Msec(20);
gotocolor(3);
}
}




//Check the color of the GROUND. Right now there is just signalling IE pecking to indicate the color found
//for debugging purposes.
void Groundcolorscan()
{
foundcolor = SensorValue[Color];
if (foundcolor <>
{
StopBot(10);
motor[port3] = -60;
wait10Msec(20);
motor[port3] = -50;
wait10Msec(20);
motor[port3] = -60;
wait10Msec(20);
motor[port3] = -50;
wait10Msec(20);
motor[port3] = -60;
wait10Msec(20);
motor[port3] = -50;
wait10Msec(20);

}
if (foundcolor > 500 && foundcolor <>
{
StopBot(10);
motor[port3] = -60;
wait10Msec(100);
motor[port3] = -50;
wait10Msec(100);
motor[port3] = -60;
wait10Msec(100);
motor[port3] = -50;
wait10Msec(50);

}

if (foundcolor <> 100) //Green Peck 1 times
{
StopBot(10);
motor[port3] = -60;
wait10Msec(20);
motor[port3] = -50;
wait10Msec(20);

}
}


void approachCan()
{
while (SensorValue[Range]>50 && SensorValue[Range]<200)
{
//CheckLine();
goforward(10);
StopBot(1);
//colorscan();
}
while (SensorValue[Range]>200 && SensorValue[Range]<400)
{
//CheckLine();
goforward(10);
StopBot(1);
//colorscan();

}
if (SensorValue[Range]>400) //If the can is close bring it all the way in.
{ //Bring the can all the way in

SlowArmDown ();
}
//colorscan();
gotocolor(1);

}


// First stop the robot, then move the sensor arm up and down to indicate that a can is found.
//Next call approach can to move toward the can
void grabcan()
{
StopBot(100);
motor[port3] = -50;
wait10Msec(100);
motor[port3] = -60;
wait10Msec(100);
approachCan();
}




//Approach the can until it is close, continually checking the color of the can.
//Once the can is close, move the sensor arm to bring the can into the robot.
void ScanforCanDelay(int times)
{
for (int i=0;i <>
{
wait10Msec(1);
if (SensorValue(Range) > 100)
{
grabcan();
}
}
}


void ScanforCan()
{
if (SensorValue(Range) > 100)
{
grabcan();
}
}



void CheckLine()
{
if (SensorValue[RightLineSensor] > 800) //If we see the line on the right then go back turn and scan
{
gobackward(1000);
TurnLeft(1);
ScanforCanDelay(150);

}

else if (SensorValue[LeftLineSensor] > 800) //If we see the line on the left then go back turn and scan
{
gobackward(1000);
TurnRight(1);
ScanforCanDelay(150);
}
}







/*
void candetection //
{
motor[port3] = 50;
if ((abs((sensorvalue(ColorSensor)-FloorColor))) > 100)
{
do
{
motor[port2] = 30;
motor[port1] = 30;
while (sensorvalue(Switch)=0)
stopbot(100);
motor[port2] = 50;
motor[port1] = 50;

if (SensorValue(Rightv
do
{
motor[port1] = 40;
motor[port2] = 0;
while (SensorValue(LefttLineSensor) <>
motor(port3) = 50
motor[port1] = -40;
motor[port2] = -40;
wait10Msec(150)
goto maingoal;
}

else if (SensorValue(LefttLineSensor) > 800)
{
stopbot(100);
do
{
motor[port1] = 0;
motor[port2] = 40;
while (SensorValue(RighttLineSensor) <>
motor(port3) = 50
motor[port1] = -40;
motor[port2] = -40;
wait10Msec(150)
goto maingoal;
}
else if ((abs((sensorvalue(ColorSensor)-FloorColor))) <>
}

}

void CanMission
{
motor[port3] = 30; //Close the arm
do
{
goforward(10);
while ((sensorvalue(LeftLineSensor) <>
}
if (sensorvalue(LeftLineSensor) > 800)
{
do
{motor[port2] = 30;
motor[port1] = 00;
while (sensorvalue(RightLineSensor) <>
}
stopbot(100);
goforward(50);
if sensorvalue
if
}
}

*/

task main()
{
motor[port3] = 10;

int FloorColor = SensorValue(Color); //First find the color of the floor
wait1Msec(3000);
Groundcolorscan();

// TurnRight(1000);
// StopBot(100);;

goforward(800); //ON startup move forward to get out of gate

//In the main loop, the robot moves forward 1 cm, checks to see if it hit the black line.(CheckLine)
//If it hit the line, it moves backward and turns.
//The the robot scans for the can. If it finds the can, it runs grab can
//If it doesn't find the can it repeats this process of moving forward, checking for the line and scanning for the can.


while (true)
{
//Maneuver Code
goforward(1);
CheckLine(); //If the the bot does not hit a black line
ScanforCan(); //This scans for the can one time
}

Wednesday, February 9, 2011

DAY 14

Today is furthering what we need to do to make the robot competition ready.

Here are the list of accomplishments:

Sensor Integrations:

2 IRs at front edge of robot
long range sensors
switch sensors
optical encoders
ground sensor readings

Mechanicals:

drive train change to rear wheel drive only
strengthen U-channel docking port with H-bridge and side bracing.
change rear wheel to larger wheel for tilt effect, allowing the sensor arm to dip closer to ground.
add rubber bands to secure wirings
add zip-tie whiskers to fan out and cover sensor blind spots

Programming:

modularize and tested the following:

forward
reverse
stop
left turn 90 degrees
right turn 90 degrees
line detection
scan for can


Needs further work:

RGB can color sensor readings: too erratic for blue and green, often reading are 330 and above.
Needed to work on angles and placements.

All mechanicals functionings--no further tweaking required

More in depth programming:
once can is found, what do you do?




Tuesday, February 8, 2011

DAY 13

As we work on modularizing our algorithm, we worked on modularizing our testing.


Here we worked on subroutine on can capture and secure containment


Here are side views of the robot chassis--battery, cables, and microcontroller unit are place specifically to accomodate the U-channel can containment. The gears has been reduced to a rear wheel drive simplicity of straight drive control.




Here's the frontal and perspective view of the robot:


Now, we have a up close of view of all the senor integerations:




From left to right: arm down to scan for can color, a close look of the long range sensor, and then the switch.



Top view of the robot and it's ground color scan module--set at motor servo value of 10.



Further testing of ground color scan and can color scan--servo module value of 90.


Finally, we solve the troublesome problem of the sensor and servo connections by hot gluing the pin units temporarily. It worked great!!!



Thursday, February 3, 2011

DAY 12

I neglected to mention but we started work on our GANNT Chart and PERT chart. Previously, we completed our RGB LED/sensor and our 2 IR sensors. Now we begin our work of design and planning on the works of our competition robot. The name of the game is color can grabber competition. The robot will autonomously, using sensors, locate the correct color can and place it in its corresponding color area.

We know of 2 possible design-grab a can or contain a can. Majority of the design uses a arm to grab the can. We decided that containment is th best. Less moving parts and that leaves us more motors to play with. The can is light so grabbing it increase the potential of knocking it over, i.e. in order to grab the can, the robot would have to be well align with the can for grabbing, if off by any degrees, the potentialities of knocking or rolling the cans over would increase as well.

Our design is based on the docking port or rather a moving docking port. We figure that if the robot can dock and secure the can, then reading the color would be considerably easier. The U shape docking came to mind. Just driving the robot up slowly to it would cause the can to place near point of reading. We added the ferris wheel arm to securely contain the can or reject the can if the sensor finds it to be the incorrect color. An added feature of the ferris wheel is the RGB col0r sensor. We had the intention of securing it near the docking point, near the base of our long range sensor, that tracks or detects the direction and distance of the cans. Since we discover that the RGB combo ferris wheel can detect cans at a arms distance, we thought that might be a fine pre-scan options for the robot. The IR sensors are place at the Left and Right leading edge of the front wheels. This will better the robot detection of initial left and right lines and help the robot line itself up for 90 degrees left or right turns. We had decided to remove the front gearing for the front wheels to add structural improvements as well as redesigning our manueverability. We also added a switch near the docking area as a checker for color scan.

We found that the GANNT chart helped us organize or manage what we do as a team timeline wise. I was initially in charge of mechanics and building of the robot and Bardia was focus on working out the programming algorithms. The IR, infrared subroutines, long range sensors, and the switch work well. Each functional subroutines from movements to sensors was rechecked and recalibrated for can seeking. Getting the robot to the can has been fairly successful, no matter what, the robot eventually finds the can. Reading the correct can color and securing the can needed more work.

The PERT chart helped us see the flow of our task. We were able to hit each point of our task.

Now it's up to figuring out how consistently work the RGB sensors to read the can color and the ground color accurately.