package org.usfirst.frc.team2506.robot;

import edu.wpi.first.wpilibj.ADXRS450_Gyro;
import edu.wpi.first.wpilibj.Ultrasonic;

public class AutonomousGear {
	static final double GEAR_RANGE_INCHES = 2.5;
	static final double ROBOT_SPEED = 0.5;
	
	private enum AutonomousStates {
		MovingForward,
		End
	}
	private static AutonomousStates autonomousState = AutonomousStates.MovingForward;
	private static ADXRS450_Gyro gyro;
	private static SwerveDrive driveTrain;
	private static Ultrasonic ultrasonic;
	
	public static void init(ADXRS450_Gyro gyro, SwerveDrive drive, Ultrasonic ultrasonic) {
		AutonomousGear.gyro = gyro;
		driveTrain = drive;
		AutonomousGear.ultrasonic = ultrasonic;
	}
	
	public static void run() {
		switch (autonomousState) {
			case MovingForward:
				if (ultrasonic.getRangeInches() > GEAR_RANGE_INCHES) {
					driveTrain.drive(gyro, ROBOT_SPEED, 0, 0);
				} else {
					driveTrain.drive(gyro, 0, 0, 0);
					autonomousState = AutonomousStates.End;
				}
				break;
		}
	}
}

@@ -150,16 +150,46 @@
 sGear %7B%0A
+%09// target distance from goal%0A
 %09static 
@@ -226,16 +226,38 @@
  = 2.5;%0A
+%09// robot motor speed%0A
 %09static 
@@ -549,16 +549,73 @@
 onic;%0A%09%0A
+%09// method that copies the funcionality of a constructor%0A
 %09public 
@@ -851,16 +851,16 @@
 tate) %7B%0A
-
 %09%09%09case 
@@ -874,16 +874,119 @@
 orward:%0A
+%09%09%09%09%0A%09%09%09%09// drives the robot while it is farther than GEAR_RANGE_INCHES away from the goal, then stops%0A
 %09%09%09%09if (

Update AutonomousGear.java