|Problems with while statements for turning?
|Page 1 of 1|
|Author:||inn0v4t3 [ Thu Aug 20, 2009 5:33 pm ]|
|Post subject:||Problems with while statements for turning?|
Currently building a robot that can navigate around a course to rescue a can (this is for a robotics competition). I have chosen RobotC over NXT-G, and I must say it is better software. However, I'm having a few issues...
1) I want the robot to follow a black line (it does this fine) however when it reaches an intersection, there will be a green square. I wish to have the robot turn the direction it sees the square. The one exception of this is where it sees black on both sensors, which means I want it to go straight forward.
I have come up with the following code*:
*Note: S1 is the left light sensor, S2 the right light sensor, motorA the left motor, motorB the right motor.
greenleft/greenrightmax are the maximum readings for green. As black is darker, I use if less than or equal to statements.
Normal line following looks like this:
The problem is when the robot comes up to an intersection, it just starts spinning around (as though executing motor[motorA] = -20; motor[motorB] = 25;) forever. It also doesn't go straight when hitting two black lines; it spins around in a circle. Hopefully this logic will complete the course (can't find how to do it properly anywhere, and have no mentor for this). I would love to do well in this competition and get others to use RobotC rather than NXT-G (which everyone seems to use).
Here is what I am working with:
Any help with these issues would be greatly appreciated.
|Page 1 of 1||All times are UTC - 5 hours [ DST ]|
|Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group