1 package org
.usfirst
.frc
.team3501
.robot
.commands
.driving
;
3 import org
.usfirst
.frc
.team3501
.robot
.OI
;
4 import org
.usfirst
.frc
.team3501
.robot
.Robot
;
6 import edu
.wpi
.first
.wpilibj
.Joystick
.AxisType
;
7 import edu
.wpi
.first
.wpilibj
.command
.Command
;
10 * This command will run throughout teleop and listens for joystick inputs to
11 * drive the driveTrain. This never finishes until teleop ends. - works in
12 * conjunction with OI.java
14 public class JoystickDrive
extends Command
{
16 double previousThrust
= 0;
17 double previousTwist
= 0;
19 public JoystickDrive() {
20 requires(Robot
.getDriveTrain());
24 protected void initialize() {
28 protected void execute() {
29 double thrust
= OI
.xboxController
.getY();
30 double twist
= OI
.xboxController
.getAxis(AxisType
.kZ
);
32 thrust
= (6 * previousThrust
+ thrust
) / 7;
33 twist
= (6 * previousTwist
+ twist
) / 7;
35 previousThrust
= thrust
;
36 previousTwist
= twist
;
38 Robot
.getDriveTrain().joystickDrive(-thrust
, -twist
);
42 protected boolean isFinished() {
47 protected void end() {
48 Robot
.getDriveTrain().stop();
52 protected void interrupted() {