From: Harel Dor Date: Tue, 23 Feb 2016 06:08:54 +0000 (-0800) Subject: Fix ports and unusuable code to make shooter test work X-Git-Url: http://challenge-bot.com/repos/?p=3501%2Fstronghold-2016;a=commitdiff_plain;h=refs%2Fheads%2Fharel%2Ftemp-shooting Fix ports and unusuable code to make shooter test work --- 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/StartShooter.java b/src/org/usfirst/frc/team3501/robot/commands/shooter/StartShooter.java new file mode 100644 index 00000000..45e12634 --- /dev/null +++ b/src/org/usfirst/frc/team3501/robot/commands/shooter/StartShooter.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 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 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() { + } +} 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 index b4e80578..00000000 --- a/src/org/usfirst/frc/team3501/robot/commands/shooter/runShooter.java +++ /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() { - } -}