1 package org
.usfirst
.frc
.team3501
.robot
.commands
.driving
;
3 import org
.usfirst
.frc
.team3501
.robot
.Constants
;
4 import org
.usfirst
.frc
.team3501
.robot
.Robot
;
6 import edu
.wpi
.first
.wpilibj
.command
.Command
;
10 * is the setpoint we want to turn for
11 * maxTimeOut catch just in case robot malfunctions and never reaches
13 * @initialize resets the Gyro and prints the current mode
14 * @code repeatedly sets a new setpoint angle to the motor
15 * @end ends when the setpoint is reached.
17 public class TurnForAngle
extends Command
{
18 private double maxTimeOut
;
21 public TurnForAngle(double angle
, double maxTimeOut
) {
22 requires(Robot
.driveTrain
);
23 this.maxTimeOut
= maxTimeOut
;
28 protected void initialize() {
29 Robot
.driveTrain
.resetGyro();
30 System
.out
.println(Robot
.driveTrain
.getMode());
34 protected void execute() {
35 Robot
.driveTrain
.turnAngle(angle
);
36 Robot
.driveTrain
.printGyroOutput();
37 Robot
.driveTrain
.printOutput();
42 protected boolean isFinished() {
43 if (timeSinceInitialized() >= maxTimeOut
45 .reachedTarget() || Robot
.driveTrain
.getError() < 8) {
46 System
.out
.println("time: " + timeSinceInitialized());
47 Constants
.DriveTrain
.time
= timeSinceInitialized();
54 protected void end() {
55 Robot
.driveTrain
.disable();
59 protected void interrupted() {