From: Harel Dor Date: Thu, 10 Mar 2016 01:14:39 +0000 (-0800) Subject: Update ports to competition setup, minor bugfixes X-Git-Url: http://challenge-bot.com/repos/?p=3501%2Fstronghold-2016;a=commitdiff_plain;h=e1f7a74216c8845966fb0fa03a08dfeb3868ff3e Update ports to competition setup, minor bugfixes --- diff --git a/src/org/usfirst/frc/team3501/robot/Constants.java b/src/org/usfirst/frc/team3501/robot/Constants.java index 825ce7a3..a703b0b9 100644 --- a/src/org/usfirst/frc/team3501/robot/Constants.java +++ b/src/org/usfirst/frc/team3501/robot/Constants.java @@ -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; diff --git a/src/org/usfirst/frc/team3501/robot/OI.java b/src/org/usfirst/frc/team3501/robot/OI.java index fdb91263..07352f87 100644 --- a/src/org/usfirst/frc/team3501/robot/OI.java +++ b/src/org/usfirst/frc/team3501/robot/OI.java @@ -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()); } } diff --git a/src/org/usfirst/frc/team3501/robot/Robot.java b/src/org/usfirst/frc/team3501/robot/Robot.java index 7678a728..8616cfa7 100644 --- a/src/org/usfirst/frc/team3501/robot/Robot.java +++ b/src/org/usfirst/frc/team3501/robot/Robot.java @@ -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 diff --git a/src/org/usfirst/frc/team3501/robot/commands/intakearm/MoveIntakeArm.java b/src/org/usfirst/frc/team3501/robot/commands/intakearm/MoveIntakeArm.java index 1d24648f..1991726a 100755 --- a/src/org/usfirst/frc/team3501/robot/commands/intakearm/MoveIntakeArm.java +++ b/src/org/usfirst/frc/team3501/robot/commands/intakearm/MoveIntakeArm.java @@ -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 diff --git a/src/org/usfirst/frc/team3501/robot/commands/intakearm/RunIntake.java b/src/org/usfirst/frc/team3501/robot/commands/intakearm/RunIntake.java index eec3b20a..42ed83fc 100644 --- a/src/org/usfirst/frc/team3501/robot/commands/intakearm/RunIntake.java +++ b/src/org/usfirst/frc/team3501/robot/commands/intakearm/RunIntake.java @@ -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 diff --git a/src/org/usfirst/frc/team3501/robot/subsystems/DriveTrain.java b/src/org/usfirst/frc/team3501/robot/subsystems/DriveTrain.java index 5f370e98..c68b472e 100644 --- a/src/org/usfirst/frc/team3501/robot/subsystems/DriveTrain.java +++ b/src/org/usfirst/frc/team3501/robot/subsystems/DriveTrain.java @@ -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