// RobotBuilder Version: 0.0.2
//
// This file was generated by RobotBuilder. It contains sections of
// code that are automatically generated and assigned by robotbuilder.
// These sections will be updated in the future when you export to
// Java from RobotBuilder. Do not put any code or make any change in
// the blocks indicating autogenerated code or it will be lost on an
// update. Deleting the comments indicating the section will prevent
// it from being updated in th future.
package org.usfirst.frc330.Beachbot2013Java.commands;
import edu.wpi.first.wpilibj.command.AutoSpreadsheetCommand;
import edu.wpi.first.wpilibj.command.Command;
import org.usfirst.frc330.Beachbot2013Java.Robot;
import org.usfirst.frc330.Beachbot2013Java.subsystems.Chassis;
/*
 * $Log$
 */
 
/**
 *
 */
public class  TurnGyroAbs extends Command implements AutoSpreadsheetCommand {
    double angle, tolerance;
    boolean stopAtEnd = false;
    
    public TurnGyroAbs(double angle) {
        // Use requires() here to declare subsystem dependencies
        // eg. requires(chassis);
        this(angle, 0, 15, false);
    }
    
    public TurnGyroAbs(double angle, double tolerance)
    {
        this(angle, tolerance, 15, false);
    
    }
    public TurnGyroAbs(double angle, double tolerance, double timeout, boolean stopAtEnd) {
        // Use requires() here to declare subsystem dependencies
        // eg. requires(chassis);
	
        // BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=REQUIRES
        requires(Robot.chassis);
    // END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=REQUIRES
        this.angle = angle;
        this.tolerance = tolerance;
        setTimeout(timeout);
        this.stopAtEnd = stopAtEnd;
    }
    // Called just before this Command runs the first time
    protected void initialize() {
        Robot.chassis.leftDrivePID.disable();
        Robot.chassis.rightDrivePID.disable();  
        Robot.chassis.gyroPID.setAbsoluteTolerance(tolerance);
        if (!Robot.chassis.getShiftState())
        {
            Robot.chassis.gyroPID.setGainName(Chassis.TURNLOW);
        }
        else
        {
            Robot.chassis.gyroPID.setGainName(Chassis.TURNHIGH);
        }
        Robot.chassis.gyroPID.setSetpoint(angle);
        Robot.chassis.gyroPID.enable();
    }
    // Called repeatedly when this Command is scheduled to run
    protected void execute() {
    }
    // Make this return true when this Command no longer needs to run execute()
    protected boolean isFinished() {
        if (Robot.chassis.gyroPID.onTarget() || isTimedOut())
        {
            return true;
        }
        return false;
    }
    // Called once after isFinished returns true
    protected void end() {
        if (stopAtEnd)
        {
            Robot.chassis.stopDrive();
        }
    }
    // Called when another command which requires one or more of the same
    // subsystems is scheduled to run
    protected void interrupted() {
        stopAtEnd = true;
        end();
    }
    public void setParam1(double angle) {
        this.angle = angle;
    }
    public void setParam2(double tolerance) {
        this.tolerance = tolerance;
    }
    public void setParam3(double param3) {
    }
    public void setStopAtEnd(boolean stopAtEnd) {
        this.stopAtEnd = stopAtEnd;
    }
    public Command copy() {
        return new TurnGyroAbs(0);
    }
}

@@ -767,22 +767,311 @@
 $Log
-$%0A */%0A %0A/**%0A *
+: TurnGyroAbs.java,v $%0A * Revision 1.9  2013-03-15 02:51:17  echan%0A * added cvs log comments%0A *%0A */%0A %0A/**%0A * Turn the robot to the specified angle using the gyro. %7B@link #setParam1(double) %7D%0A * defines the angle to  turn to relative to the starting position of the robot.%0A * %7B@link #setParam2(double) %7D 
 %0A */

add description