From 1e41dfe4e5913508b81298ba64e6d879b6739f39 Mon Sep 17 00:00:00 2001 From: Harel Dor Date: Mon, 22 Feb 2016 22:08:54 -0800 Subject: [PATCH] Fix ports and unusuable code to make shooter test work --- .../usfirst/frc/team3501/robot/Constants.java | 12 +++--- src/org/usfirst/frc/team3501/robot/OI.java | 7 +++- src/org/usfirst/frc/team3501/robot/Robot.java | 13 +++++-- .../robot/commands/shooter/Shoot.java | 29 +++++++------- .../{runShooter.java => StartShooter.java} | 5 +-- .../robot/commands/shooter/StopShooter.java | 38 +++++++++++++++++++ 6 files changed, 76 insertions(+), 28 deletions(-) rename src/org/usfirst/frc/team3501/robot/commands/shooter/{runShooter.java => StartShooter.java} (85%) create mode 100644 src/org/usfirst/frc/team3501/robot/commands/shooter/StopShooter.java diff --git a/src/org/usfirst/frc/team3501/robot/Constants.java b/src/org/usfirst/frc/team3501/robot/Constants.java index 657fc285..520959a9 100644 --- a/src/org/usfirst/frc/team3501/robot/Constants.java +++ b/src/org/usfirst/frc/team3501/robot/Constants.java @@ -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; diff --git a/src/org/usfirst/frc/team3501/robot/OI.java b/src/org/usfirst/frc/team3501/robot/OI.java index bde311bd..07c47e84 100644 --- a/src/org/usfirst/frc/team3501/robot/OI.java +++ b/src/org/usfirst/frc/team3501/robot/OI.java @@ -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()); diff --git a/src/org/usfirst/frc/team3501/robot/Robot.java b/src/org/usfirst/frc/team3501/robot/Robot.java index d0516b8e..71e156b6 100644 --- a/src/org/usfirst/frc/team3501/robot/Robot.java +++ b/src/org/usfirst/frc/team3501/robot/Robot.java @@ -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(); + + } } } diff --git a/src/org/usfirst/frc/team3501/robot/commands/shooter/Shoot.java b/src/org/usfirst/frc/team3501/robot/commands/shooter/Shoot.java index 31fb261e..df25ac13 100755 --- a/src/org/usfirst/frc/team3501/robot/commands/shooter/Shoot.java +++ b/src/org/usfirst/frc/team3501/robot/commands/shooter/Shoot.java @@ -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/runShooter.java b/src/org/usfirst/frc/team3501/robot/commands/shooter/StartShooter.java similarity index 85% rename from src/org/usfirst/frc/team3501/robot/commands/shooter/runShooter.java rename to src/org/usfirst/frc/team3501/robot/commands/shooter/StartShooter.java index b4e80578..45e12634 100644 --- a/src/org/usfirst/frc/team3501/robot/commands/shooter/runShooter.java +++ b/src/org/usfirst/frc/team3501/robot/commands/shooter/StartShooter.java @@ -7,9 +7,9 @@ import edu.wpi.first.wpilibj.command.Command; /** * */ -public class runShooter extends Command { +public class StartShooter extends Command { - public runShooter() { + public StartShooter() { } @@ -30,7 +30,6 @@ public class runShooter extends Command { @Override protected void end() { - Robot.shooter.stop(); } @Override 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 index 00000000..7488a493 --- /dev/null +++ b/src/org/usfirst/frc/team3501/robot/commands/shooter/StopShooter.java @@ -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() { + } +} -- 2.30.2