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