Update ports to competition setup, minor bugfixes
authorHarel Dor <hareldor@gmail.com>
Thu, 10 Mar 2016 01:14:39 +0000 (17:14 -0800)
committerHarel Dor <hareldor@gmail.com>
Thu, 10 Mar 2016 01:14:39 +0000 (17:14 -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/intakearm/MoveIntakeArm.java
src/org/usfirst/frc/team3501/robot/commands/intakearm/RunIntake.java
src/org/usfirst/frc/team3501/robot/subsystems/DriveTrain.java

index 825ce7a3ca9d47c55d00371ff95aa106ef127f77..a703b0b9f849e6210b4be36fa256b16feb16f7a6 100644 (file)
@@ -18,20 +18,30 @@ public class Constants {
     public final static int LEFT_STICK_PORT = 0;
     public final static int RIGHT_STICK_PORT = 1;
 
-    public final static int LEFT_JOYSTICK_TRIGGER_PORT = 1;
-
-    public final static int RIGHT_JOYSTICK_TRIGGER_PORT = 1;
-    public final static int RIGHT_JOYSTICK_THUMB_PORT = 2;
-    public final static int RIGHT_JOYSTICK_SHOOT_PORT = 3;
+    // Left Joystick
+    public final static int LEFT_JOYSTICK_GEAR_SHIFT_PORT = 1;
+    public final static int LEFT_JOYSTICK_EXTEND_INTAKE_1_PORT = 3;
+    public final static int LEFT_JOYSTICK_EXTEND_INTAKE_2_PORT = 5;
+    public final static int LEFT_JOYSTICK_RETRACT_INTAKE_1_PORT = 4;
+    public final static int LEFT_JOYSTICK_RETRACT_INTAKE_2_PORT = 6;
+    public final static int LEFT_JOYSTICK_TOGGLE_FRONT_PORT = 7;
+
+    // Right Joystick
+    public final static int RIGHT_JOYSTICK_INTAKE_PORT = 1;
+    public final static int RIGHT_JOYSTICK_OUTTAKE_1_PORT = 3;
+    public final static int RIGHT_JOYSTICK_OUTTAKE_2_PORT = 4;
+    public final static int RIGHT_JOYSTICK_SHOOTER_UP_PORT = 2;
+    public final static int RIGHT_JOYSTICK_SHOOTER_DOWN_1_PORT = 5;
+    public final static int RIGHT_JOYSTICK_SHOOTER_DOWN_2_PORT = 6;
 
   }
 
   public static class DriveTrain {
     // Drivetrain Motor Related Ports
-    public static final int FRONT_LEFT = 1;
-    public static final int FRONT_RIGHT = 6;
-    public static final int REAR_LEFT = 2;
-    public static final int REAR_RIGHT = 5;
+    public static final int DRIVE_FRONT_LEFT = 1;
+    public static final int DRIVE_REAR_LEFT = 2;
+    public static final int DRIVE_FRONT_RIGHT = 6;
+    public static final int DRIVE_REAR_RIGHT = 5;
 
     // Encoder related ports
     public final static int ENCODER_LEFT_A = 0;
@@ -39,10 +49,12 @@ public class Constants {
     public final static int ENCODER_RIGHT_A = 3;
     public final static int ENCODER_RIGHT_B = 4;
 
-    public static final int LEFT_MODULE = PCM_MODULE_B;
-    public static final int LEFT_FORWARD = 1, LEFT_REVERSE = 6;
-    public static final int RIGHT_MODULE = PCM_MODULE_B;
-    public static final int RIGHT_FORWARD = 0, RIGHT_REVERSE = 7;
+    public static final int LEFT_SHIFT_MODULE = PCM_MODULE_B;
+    public static final int LEFT_SHIFT_FORWARD = 3;
+    public static final int LEFT_SHIFT_REVERSE = 6;
+    public static final int RIGHT_SHIFT_MODULE = PCM_MODULE_B;
+    public static final int RIGHT_SHIFT_FORWARD = 2;
+    public static final int RIGHT_SHIFT_REVERSE = 7;
 
     public static final double INCHES_PER_PULSE = ((3.66 / 5.14) * 6 * Math.PI) / 256;
 
@@ -55,13 +67,12 @@ public class Constants {
   }
 
   public static class Shooter {
-    public static final int CATAPULT1_MODULE = PCM_MODULE_A;
-    public static final int CATAPULT1_FORWARD = 0;
+    public static final int CATAPULT1_MODULE = PCM_MODULE_B;
+    public static final int CATAPULT1_FORWARD = 4;
     public static final int CATAPULT1_REVERSE = 1;
     public static final int CATAPULT2_MODULE = PCM_MODULE_A;
-    public static final int CATAPULT2_FORWARD = 2;
-    public static final int CATAPULT2_REVERSE = 3;
-    // TODO Determine actual shooter ports
+    public static final int CATAPULT2_FORWARD = 0;
+    public static final int CATAPULT2_REVERSE = 1;
 
     public static final Value shoot = Value.kForward;
     public static final Value reset = Value.kReverse;
@@ -69,20 +80,22 @@ public class Constants {
   }
 
   public static class IntakeArm {
-    public static final int INTAKE_ROLLER_PORT = 3;
+    public static final int INTAKE_ROLLER_PORT = 8;
 
     // for pistons
     public static final int LEFT_INTAKE_MODULE = PCM_MODULE_A;
-    public static final int LEFT_INTAKE_FORWARD = 4;
-    public static final int LEFT_INTAKE_REVERSE = 5;
-    public static final int RIGHT_INTAKE_MODULE = PCM_MODULE_A;
-    public static final int RIGHT_INTAKE_FORWARD = 6;
-    public static final int RIGHT_INTAKE_REVERSE = 7;
-    // TODO Determine actual intake ports
+    public static final int LEFT_INTAKE_FORWARD = 5;
+    public static final int LEFT_INTAKE_REVERSE = 2;
+    public static final int RIGHT_INTAKE_MODULE = PCM_MODULE_B;
+    public static final int RIGHT_INTAKE_FORWARD = 5;
+    public static final int RIGHT_INTAKE_REVERSE = 0;
 
     public static final Value EXTEND = DoubleSolenoid.Value.kForward;
     public static final Value RETRACT = DoubleSolenoid.Value.kReverse;
 
+    public static final int IN = 1;
+    public static final int OUT = -1;
+
     // for roller
     public static final double INTAKE_SPEED = 0.5;
     public static final double OUTPUT_SPEED = -0.5;
index fdb91263fd289b31569a5b0f69285aed64803b7e..07352f8787161fe5f47dcb614322a0e50cde57a0 100644 (file)
@@ -3,9 +3,10 @@ package org.usfirst.frc.team3501.robot;
 import org.usfirst.frc.team3501.robot.commands.driving.SetHighGear;
 import org.usfirst.frc.team3501.robot.commands.driving.SetLowGear;
 import org.usfirst.frc.team3501.robot.commands.driving.ToggleFront;
+import org.usfirst.frc.team3501.robot.commands.intakearm.MoveIntakeArm;
 import org.usfirst.frc.team3501.robot.commands.intakearm.RunIntake;
-import org.usfirst.frc.team3501.robot.commands.intakearm.StopIntake;
-import org.usfirst.frc.team3501.robot.commands.shooter.Shoot;
+import org.usfirst.frc.team3501.robot.commands.shooter.FireCatapult;
+import org.usfirst.frc.team3501.robot.commands.shooter.ResetCatapult;
 
 import edu.wpi.first.wpilibj.Joystick;
 import edu.wpi.first.wpilibj.buttons.Button;
@@ -16,35 +17,74 @@ public class OI {
   public static Joystick rightJoystick;
 
   // left joystick buttons
-  public static Button gearTrigger;
+  public static Button gearShift;
+  public static Button extendIntake1;
+  public static Button extendIntake2;
+  public static Button retractIntake1;
+  public static Button retractIntake2;
+  public static Button toggleFront;
 
   // right joystick buttons
-  public static Button intakeTrigger;
-  public static Button shootBoulder;
-  public static Button toggleFront;
+  public static Button intake;
+  public static Button outtake1;
+  public static Button outtake2;
+  public static Button shooterUp;
+  public static Button shooterDown1;
+  public static Button shooterDown2;
 
   public OI() {
     leftJoystick = new Joystick(Constants.OI.LEFT_STICK_PORT);
     rightJoystick = new Joystick(Constants.OI.RIGHT_STICK_PORT);
 
     // Left joystick
-    gearTrigger = new JoystickButton(leftJoystick,
-        Constants.OI.LEFT_JOYSTICK_TRIGGER_PORT);
-    gearTrigger.whenPressed(new SetHighGear());
-    gearTrigger.whenReleased(new SetLowGear());
+    gearShift = new JoystickButton(leftJoystick,
+        Constants.OI.LEFT_JOYSTICK_GEAR_SHIFT_PORT);
+    gearShift.whenPressed(new SetLowGear());
+    gearShift.whenReleased(new SetHighGear());
 
-    // Right joystick
-    intakeTrigger = new JoystickButton(rightJoystick,
-        Constants.OI.RIGHT_JOYSTICK_TRIGGER_PORT);
-    intakeTrigger.whenPressed(new RunIntake());
-    intakeTrigger.whenReleased(new StopIntake());
+    extendIntake1 = new JoystickButton(leftJoystick,
+        Constants.OI.LEFT_JOYSTICK_EXTEND_INTAKE_1_PORT);
+    extendIntake1.whenPressed(new MoveIntakeArm(Constants.IntakeArm.EXTEND));
 
-    shootBoulder = new JoystickButton(rightJoystick,
-        Constants.OI.RIGHT_JOYSTICK_SHOOT_PORT);
-    shootBoulder.whenPressed(new Shoot());
+    extendIntake2 = new JoystickButton(leftJoystick,
+        Constants.OI.LEFT_JOYSTICK_EXTEND_INTAKE_2_PORT);
+    extendIntake2.whenPressed(new MoveIntakeArm(Constants.IntakeArm.EXTEND));
 
-    toggleFront = new JoystickButton(rightJoystick,
-        Constants.OI.RIGHT_JOYSTICK_THUMB_PORT);
+    retractIntake1 = new JoystickButton(leftJoystick,
+        Constants.OI.LEFT_JOYSTICK_RETRACT_INTAKE_1_PORT);
+    retractIntake1.whenPressed(new MoveIntakeArm(Constants.IntakeArm.RETRACT));
+
+    retractIntake2 = new JoystickButton(leftJoystick,
+        Constants.OI.LEFT_JOYSTICK_RETRACT_INTAKE_2_PORT);
+    retractIntake2.whenPressed(new MoveIntakeArm(Constants.IntakeArm.RETRACT));
+
+    toggleFront = new JoystickButton(leftJoystick,
+        Constants.OI.LEFT_JOYSTICK_TOGGLE_FRONT_PORT);
     toggleFront.whenPressed(new ToggleFront());
+
+    // Right joystick
+    intake = new JoystickButton(rightJoystick,
+        Constants.OI.RIGHT_JOYSTICK_INTAKE_PORT);
+    intake.whenPressed(new RunIntake(Constants.IntakeArm.IN));
+
+    outtake1 = new JoystickButton(rightJoystick,
+        Constants.OI.RIGHT_JOYSTICK_OUTTAKE_1_PORT);
+    outtake1.whenPressed(new RunIntake(Constants.IntakeArm.OUT));
+
+    outtake2 = new JoystickButton(rightJoystick,
+        Constants.OI.RIGHT_JOYSTICK_OUTTAKE_2_PORT);
+    outtake2.whenPressed(new RunIntake(Constants.IntakeArm.OUT));
+
+    shooterUp = new JoystickButton(rightJoystick,
+        Constants.OI.RIGHT_JOYSTICK_SHOOTER_UP_PORT);
+    shooterUp.whenPressed(new FireCatapult());
+
+    shooterDown1 = new JoystickButton(rightJoystick,
+        Constants.OI.RIGHT_JOYSTICK_SHOOTER_DOWN_1_PORT);
+    shooterDown1.whenPressed(new ResetCatapult());
+
+    shooterDown2 = new JoystickButton(rightJoystick,
+        Constants.OI.RIGHT_JOYSTICK_SHOOTER_DOWN_2_PORT);
+    shooterDown2.whenPressed(new ResetCatapult());
   }
 }
index 7678a7289cc4506c66670c42418b5292fa9a0ef5..8616cfa765dd39fe98e3f3eeb42c6f3534c45b13 100644 (file)
@@ -1,6 +1,6 @@
 package org.usfirst.frc.team3501.robot;
 
-import org.usfirst.frc.team3501.robot.commands.driving.SetLowGear;
+import org.usfirst.frc.team3501.robot.commands.driving.SetHighGear;
 import org.usfirst.frc.team3501.robot.commands.intakearm.MoveIntakeArm;
 import org.usfirst.frc.team3501.robot.commands.shooter.ResetCatapult;
 import org.usfirst.frc.team3501.robot.subsystems.DriveTrain;
@@ -27,7 +27,6 @@ public class Robot extends IterativeRobot {
 
   @Override
   public void autonomousInit() {
-    Scheduler.getInstance().run();
   }
 
   @Override
@@ -37,13 +36,9 @@ public class Robot extends IterativeRobot {
 
   @Override
   public void teleopInit() {
-    Scheduler.getInstance().add(new SetLowGear()); // Start each match in low
-                                                   // gear
-    Scheduler.getInstance().add(new ResetCatapult()); // Reset catapult at start
-                                                      // of each match.
-
+    Scheduler.getInstance().add(new SetHighGear());
+    Scheduler.getInstance().add(new ResetCatapult());
     Scheduler.getInstance().add(new MoveIntakeArm(Constants.IntakeArm.EXTEND));
-    // Start testing with intake arm extended TODO remove this
   }
 
   @Override
index 1d24648f13e9f3a0bea18c0576d086366298d936..1991726ac0430491e27144202c7e544599ab4f7c 100755 (executable)
@@ -11,26 +11,28 @@ import edu.wpi.first.wpilibj.command.Command;
  * specified direction the intake arm should move
  */
 public class MoveIntakeArm extends Command {
+  Value direction;
 
   public MoveIntakeArm(Value direction) {
+    requires(Robot.intakeArm);
+    this.direction = direction;
+  }
 
+  @Override
+  protected void initialize() {
     if (direction == Constants.IntakeArm.EXTEND)
       Robot.intakeArm.extendPistons();
     else
       Robot.intakeArm.retractPistons();
   }
 
-  @Override
-  protected void initialize() {
-  }
-
   @Override
   protected void execute() {
   }
 
   @Override
   protected boolean isFinished() {
-    return false;
+    return true;
   }
 
   @Override
index eec3b20ad12e38a2b6fcb3d8342d4a5518d9cf44..42ed83fc3f38b5a0c0970f52aa1103fe6c0af63a 100644 (file)
@@ -1,18 +1,24 @@
 package org.usfirst.frc.team3501.robot.commands.intakearm;
 
+import org.usfirst.frc.team3501.robot.Constants;
 import org.usfirst.frc.team3501.robot.Robot;
 
 import edu.wpi.first.wpilibj.command.Command;
 
 public class RunIntake extends Command {
+  int direction;
 
-  public RunIntake() {
+  public RunIntake(int direction) {
     requires(Robot.intakeArm);
+    this.direction = direction;
   }
 
   @Override
   protected void initialize() {
-    Robot.intakeArm.intakeBall();
+    if (direction == Constants.IntakeArm.IN)
+      Robot.intakeArm.intakeBall();
+    else
+      Robot.intakeArm.outputBall();
   }
 
   @Override
index 5f370e98baee876cf422f749fe286b6b1935656e..c68b472e2ff3a5878dc32569aa702ed4aafd99db 100644 (file)
@@ -29,10 +29,10 @@ public class DriveTrain extends PIDSubsystem {
     super(Constants.DriveTrain.kp, Constants.DriveTrain.ki,
         Constants.DriveTrain.kd);
 
-    frontLeft = new CANTalon(Constants.DriveTrain.FRONT_LEFT);
-    frontRight = new CANTalon(Constants.DriveTrain.FRONT_RIGHT);
-    rearLeft = new CANTalon(Constants.DriveTrain.REAR_LEFT);
-    rearRight = new CANTalon(Constants.DriveTrain.REAR_RIGHT);
+    frontLeft = new CANTalon(Constants.DriveTrain.DRIVE_FRONT_LEFT);
+    frontRight = new CANTalon(Constants.DriveTrain.DRIVE_FRONT_RIGHT);
+    rearLeft = new CANTalon(Constants.DriveTrain.DRIVE_REAR_LEFT);
+    rearRight = new CANTalon(Constants.DriveTrain.DRIVE_REAR_RIGHT);
 
     robotDrive = new RobotDrive(frontLeft, rearLeft, frontRight, rearRight);
 
@@ -48,10 +48,10 @@ public class DriveTrain extends PIDSubsystem {
 
     this.disable();
 
-    leftGearPiston = new DoubleSolenoid(Constants.DriveTrain.LEFT_MODULE,
-        Constants.DriveTrain.LEFT_FORWARD, Constants.DriveTrain.LEFT_REVERSE);
-    rightGearPiston = new DoubleSolenoid(Constants.DriveTrain.RIGHT_MODULE,
-        Constants.DriveTrain.RIGHT_FORWARD, Constants.DriveTrain.RIGHT_REVERSE);
+    leftGearPiston = new DoubleSolenoid(Constants.DriveTrain.LEFT_SHIFT_MODULE,
+        Constants.DriveTrain.LEFT_SHIFT_FORWARD, Constants.DriveTrain.LEFT_SHIFT_REVERSE);
+    rightGearPiston = new DoubleSolenoid(Constants.DriveTrain.RIGHT_SHIFT_MODULE,
+        Constants.DriveTrain.RIGHT_SHIFT_FORWARD, Constants.DriveTrain.RIGHT_SHIFT_REVERSE);
   }
 
   @Override