861432f5a975d08dfd4d2cd6cd7e48a33c1f6900
[3501/stronghold-2016] / src / org / usfirst / frc / team3501 / robot / commands / driving / JoystickDrive.java
1 package org.usfirst.frc.team3501.robot.commands.driving;
2
3 import org.usfirst.frc.team3501.robot.Robot;
4
5 import edu.wpi.first.wpilibj.command.Command;
6
7 /**
8 * Runs throughout teleop and listens for joystick inputs and drives the
9 * driveTrain Never finishes until teleop ends
10 */
11 public class JoystickDrive extends Command {
12
13 public JoystickDrive() {
14 requires(Robot.driveTrain);
15 }
16
17 @Override
18 protected void initialize() {
19 }
20
21 @Override
22 protected void execute() {
23 double k = (Robot.driveTrain.isFlipped() ? -1 : 1);
24 // IDK why but the joystick gives positive values for pulling backwards
25 double left = -Robot.oi.leftJoystick.getY();
26 double right = -Robot.oi.rightJoystick.getY();
27 Robot.driveTrain.drive(left * k, right * k);
28 }
29
30 @Override
31 protected boolean isFinished() {
32 return false;
33 }
34
35 @Override
36 protected void end() {
37 Robot.driveTrain.stop();
38 }
39
40 @Override
41 protected void interrupted() {
42 }
43 }