Fix ports and unusuable code to make shooter test work harel/temp-shooting
authorHarel Dor <hareldor@gmail.com>
Tue, 23 Feb 2016 06:08:54 +0000 (22:08 -0800)
committerHarel Dor <hareldor@gmail.com>
Tue, 23 Feb 2016 06:08:54 +0000 (22:08 -0800)
src/org/usfirst/frc/team3501/robot/Constants.java
src/org/usfirst/frc/team3501/robot/OI.java
src/org/usfirst/frc/team3501/robot/Robot.java
src/org/usfirst/frc/team3501/robot/commands/shooter/Shoot.java
src/org/usfirst/frc/team3501/robot/commands/shooter/StartShooter.java [new file with mode: 0644]
src/org/usfirst/frc/team3501/robot/commands/shooter/StopShooter.java [new file with mode: 0644]
src/org/usfirst/frc/team3501/robot/commands/shooter/runShooter.java [deleted file]

index 657fc2854790160b9591389f0d624d745f35f1e5..520959a9de46a7c37728923b06244a7f21491abe 100644 (file)
@@ -106,12 +106,12 @@ public class Constants {
     public static final int PUNCH_REVERSE = 1;
     public static final int ANGLE_ADJUSTER_PORT = 0;
 
-    public static final DoubleSolenoid.Value punch = DoubleSolenoid.Value.kForward;
-    public static final DoubleSolenoid.Value retract = DoubleSolenoid.Value.kReverse;
+    public static final DoubleSolenoid.Value punch = DoubleSolenoid.Value.kReverse;
+    public static final DoubleSolenoid.Value retract = DoubleSolenoid.Value.kForward;
 
     // Encoder port
-    public static final int ENCODER_PORT_A = 0;
-    public static final int ENCODER_PORT_B = 0;
+    public static final int ENCODER_PORT_A = 4;
+    public static final int ENCODER_PORT_B = 5;
     public static final int RIGHT_HOOD_FORWARD = 2;
     public static final int RIGHT_HOOD_REVERSE = 4;
     public static final int LEFT_HOOD_FORWARD = 4;
@@ -119,8 +119,8 @@ public class Constants {
 
     public static final double DEFAULT_SHOOTER_SPEED = 0.5;
 
-    public static final Value open = Value.kReverse;
-    public static final Value closed = Value.kForward;
+    public static final Value open = Value.kForward;
+    public static final Value closed = Value.kReverse;
 
     public static final Port LIDAR_I2C_PORT = I2C.Port.kMXP;
 
index bde311bd3147356a90d92129557a340b7f134bc7..07c47e8405422f77149aa54fabaf7c0cc81b0559 100644 (file)
@@ -1,6 +1,7 @@
 package org.usfirst.frc.team3501.robot;
 
 import org.usfirst.frc.team3501.robot.commands.driving.ChangeGear;
+import org.usfirst.frc.team3501.robot.commands.shooter.Shoot;
 
 import edu.wpi.first.wpilibj.Joystick;
 import edu.wpi.first.wpilibj.buttons.Button;
@@ -43,9 +44,13 @@ public class OI {
     rightJoystick = new Joystick(Constants.OI.RIGHT_STICK_PORT);
 
     toggleGear = new JoystickButton(leftJoystick,
-        Constants.OI.LEFT_JOYSTICK_TRIGGER_PORT);
+        Constants.OI.LEFT_JOYSTICK_TOP_CENTER_PORT);
     toggleGear.toggleWhenPressed(new ChangeGear());
 
+    shootBoulder = new JoystickButton(leftJoystick,
+        Constants.OI.LEFT_JOYSTICK_TRIGGER_PORT);
+    shootBoulder.whenPressed(new Shoot());
+
     // passPortcullis = new DigitalButton(
     // new DigitalInput(Constants.OI.PASS_PORTCULLIS_PORT));
     // passPortcullis.whenPressed(new PassPortcullis());
index d0516b8e040ec23fc93c84fd3fa3ca5817ea4e42..71e156b6988aec38d24e6a40a9f4edcf6fb0fac1 100644 (file)
@@ -32,6 +32,8 @@ public class Robot extends IterativeRobot {
     driveTrain = new DriveTrain();
     oi = new OI();
 
+    shooter = new Shooter();
+
     // shooter = new Shooter();
     // scaler = new Scaler();
     // intakeArm = new IntakeArm();
@@ -95,8 +97,6 @@ public class Robot extends IterativeRobot {
     SmartDashboard
         .putData("Position Five Defense Chooser", positionFiveDefense);
 
-    shooter = new Shooter();
-
   }
 
   @Override
@@ -121,16 +121,23 @@ public class Robot extends IterativeRobot {
   @Override
   public void teleopInit() {
     Robot.driveTrain.setLowGear();
+    Robot.shooter.raiseHood();
   }
 
   @Override
   public void teleopPeriodic() {
     Scheduler.getInstance().run();
     if (OI.rightJoystick.getTrigger()) {
-      Robot.shooter.setSpeed(1);
+      Robot.shooter.setSpeed(.8);
     } else {
       Robot.shooter.setSpeed(0);
     }
+    if (OI.rightJoystick.getRawButton(2)) {
+      Robot.shooter.extendPunch();
+    } else {
+      Robot.shooter.retractPunch();
+
+    }
   }
 
 }
index 31fb261e576f0a9748769a1bfa7dd3d5f94b1aee..df25ac13dcdcd96a145c19ae3924d7d15de86547 100755 (executable)
@@ -1,7 +1,5 @@
 package org.usfirst.frc.team3501.robot.commands.shooter;
 
-import org.usfirst.frc.team3501.robot.Robot;
-
 import edu.wpi.first.wpilibj.command.CommandGroup;
 import edu.wpi.first.wpilibj.command.WaitCommand;
 
@@ -10,20 +8,21 @@ public class Shoot extends CommandGroup {
   public boolean usePhotogate;
 
   public Shoot() {
+    addSequential(new StartShooter());
     addSequential(new WaitCommand(3.0));
-    addSequential(new runShooter());
-    addSequential(new WaitCommand(3.0));
-    if (Robot.shooter.usePhotogate()) {
-      if (Robot.shooter.isBallInside()) {
-        addSequential(new ExtendPunch());
-        addSequential(new WaitCommand(5.0));
-        addSequential(new RetractPunch());
-      }
-    } else {
-      addSequential(new ExtendPunch());
-      addSequential(new WaitCommand(5.0));
-      addSequential(new RetractPunch());
-    }
+    // if (Robot.shooter.usePhotogate()) {
+    // if (Robot.shooter.isBallInside()) {
+    // addSequential(new ExtendPunch());
+    // addSequential(new WaitCommand(5.0));
+    // addSequential(new RetractPunch());
+    // addSequential(new StopShooter());
+    // }
+    // } else {
+    addSequential(new ExtendPunch());
+    addSequential(new WaitCommand(5.0));
+    addSequential(new RetractPunch());
+    addSequential(new StopShooter());
+    // }
 
   }
 }
diff --git a/src/org/usfirst/frc/team3501/robot/commands/shooter/StartShooter.java b/src/org/usfirst/frc/team3501/robot/commands/shooter/StartShooter.java
new file mode 100644 (file)
index 0000000..45e1263
--- /dev/null
@@ -0,0 +1,38 @@
+package org.usfirst.frc.team3501.robot.commands.shooter;
+
+import org.usfirst.frc.team3501.robot.Robot;
+
+import edu.wpi.first.wpilibj.command.Command;
+
+/**
+ *
+ */
+public class StartShooter extends Command {
+
+  public StartShooter() {
+
+  }
+
+  // default shooter speed is used to shoot when in front of the batter
+  @Override
+  protected void initialize() {
+    Robot.shooter.setSpeed(0.5);
+  }
+
+  @Override
+  protected void execute() {
+  }
+
+  @Override
+  protected boolean isFinished() {
+    return true;
+  }
+
+  @Override
+  protected void end() {
+  }
+
+  @Override
+  protected void interrupted() {
+  }
+}
diff --git a/src/org/usfirst/frc/team3501/robot/commands/shooter/StopShooter.java b/src/org/usfirst/frc/team3501/robot/commands/shooter/StopShooter.java
new file mode 100644 (file)
index 0000000..7488a49
--- /dev/null
@@ -0,0 +1,38 @@
+package org.usfirst.frc.team3501.robot.commands.shooter;
+
+import org.usfirst.frc.team3501.robot.Robot;
+
+import edu.wpi.first.wpilibj.command.Command;
+
+/**
+ *
+ */
+public class StopShooter extends Command {
+
+  public StopShooter() {
+
+  }
+
+  // default shooter speed is used to shoot when in front of the batter
+  @Override
+  protected void initialize() {
+    Robot.shooter.setSpeed(0);
+  }
+
+  @Override
+  protected void execute() {
+  }
+
+  @Override
+  protected boolean isFinished() {
+    return true;
+  }
+
+  @Override
+  protected void end() {
+  }
+
+  @Override
+  protected void interrupted() {
+  }
+}
diff --git a/src/org/usfirst/frc/team3501/robot/commands/shooter/runShooter.java b/src/org/usfirst/frc/team3501/robot/commands/shooter/runShooter.java
deleted file mode 100644 (file)
index b4e8057..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-package org.usfirst.frc.team3501.robot.commands.shooter;
-
-import org.usfirst.frc.team3501.robot.Robot;
-
-import edu.wpi.first.wpilibj.command.Command;
-
-/**
- *
- */
-public class runShooter extends Command {
-
-  public runShooter() {
-
-  }
-
-  // default shooter speed is used to shoot when in front of the batter
-  @Override
-  protected void initialize() {
-    Robot.shooter.setSpeed(0.5);
-  }
-
-  @Override
-  protected void execute() {
-  }
-
-  @Override
-  protected boolean isFinished() {
-    return true;
-  }
-
-  @Override
-  protected void end() {
-    Robot.shooter.stop();
-  }
-
-  @Override
-  protected void interrupted() {
-  }
-}