Creates methods for setting speed, adding to speed, and subtracting from speed along...
authorEvanYap <evanyap.14@gmail.com>
Thu, 21 Jan 2016 04:23:14 +0000 (20:23 -0800)
committerKevin Zhang <icestormf1@gmail.com>
Sat, 23 Jan 2016 03:37:35 +0000 (19:37 -0800)
src/org/usfirst/frc/team3501/robot/Constants.java
src/org/usfirst/frc/team3501/robot/OI.java
src/org/usfirst/frc/team3501/robot/commands/ShooterTest.java
src/org/usfirst/frc/team3501/robot/subsystems/Shooter.java

index eaf8bc6293711cb715e551c66a902fca6d20c694..564f7a1467ea4ffc4edb94dd1d3bdb467b9dc0af 100644 (file)
@@ -11,6 +11,8 @@ public class Constants {
     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 {
index 997be71cdbe551afe2477d093f6172a28c1cfe26..0bf9e3a4db2b4d82807d79441f9f4c1d469336a0 100644 (file)
@@ -1,14 +1,27 @@
 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);
+    ;
+
   }
+
 }
index 216660717eda90407af2b7e82a014094869ef778..da1fc777575412d24769ccfadbbdeec00c8a8359 100644 (file)
@@ -1,7 +1,6 @@
 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;
 
@@ -9,24 +8,38 @@ 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()
index b916c044f9519a520bd0f408c1ed4524015c3fab..614fe059a9a31851d904a71f2c07c495ad2633ce 100755 (executable)
@@ -12,6 +12,40 @@ public class Shooter extends Subsystem {
     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