View unanswered posts | View active topics It is currently Thu Jul 28, 2016 6:20 pm






Reply to topic  [ 1 post ] 
First attempt at line following with green 
Author Message
Rookie

Joined: Mon May 16, 2016 6:59 am
Posts: 1
Post First attempt at line following with green
My grade 8 students have come up with a program that detects and follows a black line fairly fast and accurate. However implementing the detect green the program fails to detect green from lines 68-80. They are unsure why this is the case. The robot does not even play a noise like it should in that section. They set the robot to crawl slowly along at 15 degrees of rotation per detection of white/white scenario. So it hardly moves before it should check the color sensors again this is for testing so the robot can detect the state of each sensor often.

Our Algorithm Scenarios

W W - go forward
W B - turn right (right motor is set to 0 speed)
B W - turn left (left motor is set to 0 speed)
W G - longer version of the turn right case above as we have to move through the intersection
G W - longer version of the turn left case above as we have to move through the intersection
B B - creep forward

We suspect our turn on green may not be long enough to cross into the black line after a green box is detected that is still being tested in a simple program. The general behaviour when it crosses into a green square on a line following tile is that it may correct itself and go but I doubt we are getting green detection as there is no tone being played. It would be more a fluke of the robot facing the right way when it gets to the detect double black.

The program is as follows below

#pragma config(Sensor, S1, LeftS1, sensorEV3_Color, modeEV3Color_RGB_Raw)
#pragma config(Sensor, S2, MiddleS2, sensorEV3_Color, modeEV3Color_RGB_Raw)
#pragma config(Sensor, S3, RightS3, sensorEV3_Color, modeEV3Color_RGB_Raw)
#pragma config(Sensor, S4, sonarS4, sensorEV3_Ultrasonic)
#pragma config(Motor, motorA, leftMotor, tmotorEV3_Large, PIDControl, driveLeft, encoder)
#pragma config(Motor, motorC, rightMotor, tmotorEV3_Large, PIDControl, driveRight, encoder)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//

int maxMotorSpeed = 30;
int deg = 15;
int avgMotorSpeed = 10;
int minMotorSpeed = 0;


void rightTurn() // function left turn
{
moveMotorTarget(rightMotor, minMotorSpeed,0); //robot drives left
moveMotorTarget(leftMotor, maxMotorSpeed,deg);
}

void leftTurn() // function right turn
{
moveMotorTarget(leftMotor, minMotorSpeed,0); //robot drives straight
moveMotorTarget(rightMotor, maxMotorSpeed,deg);
}

void straight() //function drive straight
{
moveMotorTarget(rightMotor, maxMotorSpeed,deg);
moveMotorTarget(leftMotor, maxMotorSpeed,deg);

}

void detectgreenturnright() //function to turn on green detection right sensor **not tested on robot**
{
playTone(600,15); //audio tone to hear we are in this function
moveMotorTarget(rightMotor, avgMotorSpeed,90); //robot turns right
moveMotorTarget(leftMotor, maxMotorSpeed,360);
}

void detectgreenturnleft() //function to turn on green detection left sensor **not tested on robot**
{
playTone(300,15); // audio tone to hear we are in this function
moveMotorTarget(rightMotor, maxMotorSpeed,360); //robot turns left
moveMotorTarget(leftMotor, avgMotorSpeed,90);
}

void detect()
{
if (getColorName(LeftS1) == colorWhite) //If left sensor over white
{
if (getColorName(RightS3) == colorWhite) // and right sensor over white
{
straight(); //robot drives straight
}
else //right sensor over black
{
rightTurn(); //robot drives straight
}
}
else
{
if(getColorName(RightS3) == colorWhite)
{
leftTurn(); //robot turns left
}
else //green detection
{
if (getColorName(LeftS1) == colorGreen) // left sensor detects green
{
detectgreenturnleft();
}
else
{
if (getColorName(RightS3) == colorGreen) // right sensor detects green
{
detectgreenturnright();
}
else // double black detection
{
moveMotorTarget(rightMotor, maxMotorSpeed,deg);
moveMotorTarget(leftMotor, maxMotorSpeed,deg);
}
}
}
}
}
task main()
{

repeatUntil (getColorName(MiddleS2) == colorRed) //Repeat until Middle Sensor detects red on the mat
{
detect(); //call detect white/black function
}

}


Mon May 16, 2016 7:27 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 1 post ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.