ROBOTC.net forums
http://www.robotc.net/forums/

line tracker
http://www.robotc.net/forums/viewtopic.php?f=11&t=8190
Page 1 of 1

Author:  nat1666 [ Wed Mar 12, 2014 12:34 pm ]
Post subject:  line tracker

I am just starting to learn ROBOTC computer code. I am supposed to program a robot to follow a circular course using three line trackers. The middle line tracker is supposed to follow the white tape and the left and right line trackers are supposed to follow a dark surface. I'm sure anyone with just a month of learning ROBOTC can pick out a million errors on my part. Can someone tell me what i am doing wrong?
task main()
{
untilBump(bump);
while (1==1)
{

if (SensorValue (MiddleSensor) <2300)
{
startMotor(RightFront,-25);
startMotor(RightRear,-25);
startMotor(LeftRear,25);
startMotor(LeftFront,25);

}
else
{
if ((SensorValue(RightSensor) < 2600) || (SensorValue(LeftSensor) < 2600))
{
if (SensorValue(RightSensor) < 2600)
{
startMotor(LeftFront, -25);
startMotor(LeftRear, -25);
stopMotor(RightFront);
stopMotor(RightRear);
}
else
{
startMotor(RightFront, 25);
startMotor(RightRear, 25);
stopMotor(LeftRear);
stopMotor(LeftFront);
}
}
else
{
startMotor(RightFront, 25);
startMotor(RightRear, 25);
startMotor(LeftRear, -25);
startMotor(LeftFront, -25);
}
}
}
}

Author:  JohnWatson [ Wed Mar 12, 2014 12:40 pm ]
Post subject:  Re: line tracker

You're off to a good start, but let's break this problem down a bit (as this will make the coding process easier). Remember that line tracking has three basic movements that get repeated; move forward, turn left, and turn right. The questions we need to answer are:

- When do I want the robot to move forward?
- When do I want the robot to turn left?
- When do I want the robot to turn right?

These questions can be broken down further by asking "What do we want each line tracking sensor to see (light or dark) when we make these movements?"

- When do I want the robot to move forward?
- What should the left line tracker see?
- What should the middle line tracker see?
- What should the right line tracker see?

- When do I want the robot to turn left?
- What should the left line tracker see?
- What should the middle line tracker see?
- What should the right line tracker see?

- When do I want the robot to turn right?
- What should the left line tracker see?
- What should the middle line tracker see?
- What should the right line tracker see?

Once we have this information, we can start to implement this into the code :)

Author:  nat1666 [ Fri Mar 14, 2014 11:31 am ]
Post subject:  Re: line tracker

I think this is what I want it to do. I need my robot to readjust itself if it goes off course.
Moving Forward
- I need the middle sensor to see the light colored tape.
-I need the left sensor to see a dark surface.
-I need the right sensor to see a dark surface.

Turning to the Left
-I need the middle sensor to see dark.
-I need the left sensor to see dark.
-I need the right sensor to see light colored tape.

Turning to the Right
-I need the middle sensor to see dark.
-I need the left sensor to see light colored tape.
-I need the right sensor to see dark.

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/