Class LineFollower

java.lang.Object
  extended by JavaRCX
      extended by LineFollower

public class LineFollower
extends JavaRCX

LineFollower.java Program for RCX that simply follows a black line on a white board. Robot is best started in CENTER_ONLY, a state where the center sensor is the only one on the black line. However, it may be able to handle starting in the LEFT_CENTER or RIGHT_CENTER positions. This is untested.

Improvements in Version 2.0 The only two things with any changes are the LEFT_CENTER and RIGHT_CENTER clauses. Since these clauses are very similar to eachother, only changes to one will be described. Together, these changes allow the robot to handle turns of as little as twenty-five degrees. Turns smaller than this are thought to be unrealistic. When the robot enters the LEFT_CENTER clause, the robot will first go to sleep for some period of time. This is actually a very poor way of handling the problem, since the sleep method is highly dependent on battary power. We suggest an improvement to this part of the problem. Please see the full web documentation for further suggestions on how to solve this problem. After entering sleep, the robot turns up the power for hte wheels on the outside edge of the turn. This allows the robot to bring the sensors back into the line in such a manner that it will trigger just center only. With the motors at the same power, when turning onto an acute angle turn, the state LEFT_CENTER will trigger again, and the robot will do bad things. At the start of the turn, the robot sleeps some more. We found this to be helpful in keeping the robot off the pointy part of the line on a turn. See the web documentation for more information on this. Finally, the motor powers are returned to the original values.

Improvements in Version 3.0 Robot functions from any position on a line - LEFT, LEFT_CENTER, etc. Rather than only functioning from CENTER_ONLY. We do still assume that the robot starts on a line The most remarkable modifications to the code are the integration in this line follower code of the following elements: (1) battery-voltage independent actions that replace previous attempts to use sleep threads to turn and letting while loops control the execution of the actions to get to a better state. (2) Improvement over challenge 2 & 3, where the robot interacts with intersections and acute angles very robustly. (3) The robot has the capacity of orienting itself when it finds the end of the line, turning around and going back to where it came from.

Since:
1.0

Field Summary
 
Fields inherited from class JavaRCX
ALL, CENTER_ONLY, CENTER_RIGHT, DARK, L_ROTATION, LEFT_CENTER, LEFT_ONLY, LEFT_RIGHT, NONE, POWER, R_ROTATION, RIGHT_ONLY, state, watcher
 
Constructor Summary
LineFollower()
           
 
Method Summary
static void main(java.lang.String[] args)
          Runs forever taking appropriate motor actions for each state it is in.
 
Methods inherited from class JavaRCX
initialize, lost, powerOff
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LineFollower

public LineFollower()
Method Detail

main

public static void main(java.lang.String[] args)
Runs forever taking appropriate motor actions for each state it is in.

Parameters:
args - a String[] value, command line arguments, none in this case