Commit | Line | Data |
---|---|---|
33141cdd KZ |
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 | /** | |
1c94f230 | 8 | * Runs throughout teleop and listens for joystick inputs and drives the |
571a0e2a | 9 | * driveTrain Never finishes until teleop ends |
33141cdd KZ |
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() { | |
571a0e2a | 23 | double k = (Robot.driveTrain.isFlipped() ? -1 : 1); |
33141cdd KZ |
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(); | |
571a0e2a | 27 | Robot.driveTrain.drive(left * k, right * k); |
33141cdd KZ |
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() { | |
33141cdd KZ |
42 | } |
43 | } |