From 2485099662fecd9ccb9f6ac455b2f37fefc0ed97 Mon Sep 17 00:00:00 2001 From: niyatisriram Date: Wed, 17 Feb 2016 12:16:54 -0800 Subject: [PATCH] Allow use of photogate as an option in shoot.java command group --- notes/niyati.org | 2 +- .../robot/commands/shooter/Shoot.java | 19 +++++++++++++++---- .../team3501/robot/subsystems/Shooter.java | 9 ++++++++- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/notes/niyati.org b/notes/niyati.org index c095e983..679a02b2 100644 --- a/notes/niyati.org +++ b/notes/niyati.org @@ -1,5 +1,5 @@ TODO: -Put a boolean constant in Constants like usePhotogate and a method in shooter that changes that toggles that constant(constant=!constant) +Put a boolean constant in Constants like usePhotogate and a method in shooter that changes / toggles the constant(constant=!constant) -shooter should have two versions one uses photogate and one does not - one that does use photogate tests for ballInside and then shoots 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 95270bd7..90105e0c 100755 --- a/src/org/usfirst/frc/team3501/robot/commands/shooter/Shoot.java +++ b/src/org/usfirst/frc/team3501/robot/commands/shooter/Shoot.java @@ -1,5 +1,5 @@ package org.usfirst.frc.team3501.robot.commands.shooter; - +import org.usfirst.frc.team3501.robot.Robot; import org.usfirst.frc.team3501.robot.commands.auton.AimAndAlign; import edu.wpi.first.wpilibj.command.CommandGroup; @@ -7,13 +7,24 @@ import edu.wpi.first.wpilibj.command.WaitCommand; public class Shoot extends CommandGroup { + public boolean usePhotogate; + public Shoot() { addSequential(new AimAndAlign()); addSequential(new WaitCommand(3.0)); addSequential(new runShooter()); addSequential(new WaitCommand(3.0)); - 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()); + } + } else { + addSequential(new ExtendPunch()); + addSequential(new WaitCommand(5.0)); + addSequential(new RetractPunch()); + } + } } diff --git a/src/org/usfirst/frc/team3501/robot/subsystems/Shooter.java b/src/org/usfirst/frc/team3501/robot/subsystems/Shooter.java index 0d9187a4..91793d8a 100755 --- a/src/org/usfirst/frc/team3501/robot/subsystems/Shooter.java +++ b/src/org/usfirst/frc/team3501/robot/subsystems/Shooter.java @@ -49,7 +49,10 @@ public class Shooter extends Subsystem { */ public boolean isBallInside() { - return photogate.isBallPresent(); + if (usePhotogate()) + return photogate.isBallPresent(); + else + return false; } public void setSpeed(double speed) { @@ -113,6 +116,10 @@ public class Shooter extends Subsystem { return false; } + public boolean usePhotogate() { + return true; + } + @Override protected void initDefaultCommand() { } -- 2.30.2