public final static int LEFT_STICK_PORT = 0;
public final static int RIGHT_STICK_PORT = 0;
public final static int RIGHT_STICK_TRIGGER = 0;
+ public final static int RIGHT_STICK_LEFT_SILVER_BUTTON = 0;
+ public final static int RIGHT_STICK_RIGHT_SILVER_BUTTON = 0;
}
public static class DriveTrain {
package org.usfirst.frc.team3501.robot;
import edu.wpi.first.wpilibj.Joystick;
+import edu.wpi.first.wpilibj.buttons.Button;
+import edu.wpi.first.wpilibj.buttons.JoystickButton;
public class OI {
public static Joystick leftJoystick;
public static Joystick rightJoystick;
+ public static Button leftSilverButton;
+ public static Button rightSilverButton;
public OI() {
leftJoystick = new Joystick(Constants.OI.LEFT_STICK_PORT);
rightJoystick = new Joystick(Constants.OI.RIGHT_STICK_PORT);
+ leftSilverButton = new JoystickButton(rightJoystick,
+ Constants.OI.RIGHT_STICK_LEFT_SILVER_BUTTON);
+ ;
+
+ rightSilverButton = new JoystickButton(rightJoystick,
+ Constants.OI.RIGHT_STICK_RIGHT_SILVER_BUTTON);
+ ;
+
}
+
}
package org.usfirst.frc.team3501.robot.commands;
-import org.usfirst.frc.team3501.robot.OI;
-import org.usfirst.frc.team3501.robot.subsystems.Shooter;
+import org.usfirst.frc.team3501.robot.Robot;
import edu.wpi.first.wpilibj.command.Command;
*
*/
public class ShooterTest extends Command {
- public static Shooter shooter;
- public static OI oi;
public ShooterTest() {
- // Use requires() here to declare subsystem dependencies
- // eg. requires(chassis);
- requires(shooter);
+
+ requires(Robot.shooter);
}
- // Called just before this Command runs the first time
@Override
protected void initialize() {
-
}
- // Called repeatedly when this Command is scheduled to run
@Override
protected void execute() {
+ boolean triggerPressed = Robot.oi.rightJoystick.getTrigger();
+ boolean leftSidePressed = Robot.oi.leftSilverButton.get();
+ boolean rightSidePressed = Robot.oi.rightSilverButton.get();
+
+ double currentWheelSpeed = Robot.shooter.getCurrentSpeed();
+
+ if (triggerPressed = true) {
+ Robot.shooter.setSpeed(currentWheelSpeed);
+ } else {
+ Robot.shooter.setSpeed(0.0);
+ }
+
+ if (leftSidePressed = true) {
+ Robot.shooter.setDecrementSpeed(0.1);
+ }
+
+ if (rightSidePressed = true) {
+ Robot.shooter.setIncrementSpeed(0.1);
+ }
+
}
// Make this return true when this Command no longer needs to run execute()
wheel = new CANTalon(Constants.Shooter.SHOOTER_WHEEL_PORT);\r
}\r
\r
+ public double getCurrentSpeed() {\r
+ return wheel.get();\r
+ }\r
+\r
+ public void setSpeed(double speed) {\r
+ wheel.set(speed);\r
+ }\r
+\r
+ public void setIncrementSpeed(double increment) {\r
+ double newSpeed = getCurrentSpeed() + increment;\r
+\r
+ if (getCurrentSpeed() >= 1.0) {\r
+ wheel.set(1.0);\r
+ } else if (getCurrentSpeed() <= -1.0) {\r
+ wheel.set(-1.0);\r
+ }\r
+\r
+ wheel.set(newSpeed);\r
+ }\r
+\r
+ // THIS DECREMENT METHOD TAKES ONLY POSITIVE VALUES SINCE IT ACCOUNTS FOR\r
+ // SUBTRACTING THE CURRENT MOTOR SPEED!\r
+ public void setDecrementSpeed(double decrement) {\r
+ double newSpeed = getCurrentSpeed() - decrement;\r
+\r
+ if (getCurrentSpeed() >= 1.0) {\r
+ wheel.set(1.0);\r
+ } else if (getCurrentSpeed() <= -1.0) {\r
+ wheel.set(-1.0);\r
+ }\r
+\r
+ wheel.set(newSpeed);\r
+ }\r
+\r
@Override\r
protected void initDefaultCommand() {\r
\r