--- /dev/null
+TODO:
+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
+- one that doesn't does not use this test.
package org.usfirst.frc.team3501.robot.commands.auton;
-import edu.wpi.first.wpilibj.command.Command;
+import org.usfirst.frc.team3501.robot.Robot;
+import org.usfirst.frc.team3501.robot.commands.intakearm.MoveIntakeArmToAngle;
+import org.usfirst.frc.team3501.robot.subsystems.IntakeArm;
+
+import edu.wpi.first.wpilibj.command.CommandGroup;
/**
*
*/
-public class CompactRobot extends Command {
+public class CompactRobot extends CommandGroup {
public CompactRobot() {
- // Use requires() here to declare subsystem dependencies
- // eg. requires(chassis);
- }
-
- // Called just before this Command runs the first time
- @Override
- protected void initialize() {
- // move hood down
- // move intakeArm out
- // move defenseArm down
- }
-
- // Called repeatedly when this Command is scheduled to run
- @Override
- protected void execute() {
- }
-
- // Make this return true when this Command no longer needs to run execute()
- @Override
- protected boolean isFinished() {
- return false;
- }
-
- // Called once after isFinished returns true
- @Override
- protected void end() {
- }
-
- // Called when another command which requires one or more of the same
- // subsystems is scheduled to run
- @Override
- protected void interrupted() {
+ addSequential(new MoveIntakeArmToAngle(IntakeArm.potAngles[3],
+ IntakeArm.moveIntakeArmSpeed));
+ Robot.shooter.lowerHood();
}
}
@Override
protected void initialize() {
this.setTimeout(TIMEOUT_AMOUNT);
- if (Robot.photogate.isBallPresent())
+ if (Robot.shooter.isBallInside())
Robot.intakeArm.outputBall();
}
@Override
protected boolean isFinished() {
- return (this.isTimedOut() || !Robot.photogate.isBallPresent());
+ return (this.isTimedOut() || !Robot.shooter.isBallInside());
}
@Override
@Override
protected void initialize() {
this.setTimeout(TIMEOUT_AMOUNT);
- if (!Robot.photogate.isBallPresent())
+ if (!Robot.shooter.isBallInside())
Robot.intakeArm.intakeBall();
}
@Override
protected boolean isFinished() {
- return (this.isTimedOut() || Robot.photogate.isBallPresent());
+ return (this.isTimedOut() || Robot.shooter.isBallInside());
}
@Override
package org.usfirst.frc.team3501.robot.commands.scaler;
import org.usfirst.frc.team3501.robot.Constants;
+import org.usfirst.frc.team3501.robot.commands.auton.CompactRobot;
-import edu.wpi.first.wpilibj.command.Command;
+import edu.wpi.first.wpilibj.command.CommandGroup;
-public class ToggleScaling extends Command {
+public class ToggleScaling extends CommandGroup {
public ToggleScaling() {
-
- }
-
- @Override
- protected void initialize() {
Constants.Scaler.SCALING = !Constants.Scaler.SCALING;
- }
-
- @Override
- protected void execute() {
-
- }
-
- @Override
- protected boolean isFinished() {
- return true;
- }
-
- @Override
- protected void end() {
- }
-
- @Override
- protected void interrupted() {
- end();
+ if (Constants.Scaler.SCALING)
+ addSequential(new CompactRobot());
}
}
--- /dev/null
+package org.usfirst.frc.team3501.robot.commands.shooter;
+
+import org.usfirst.frc.team3501.robot.Robot;
+
+import edu.wpi.first.wpilibj.command.Command;
+
+public class ExtendPunch extends Command {
+
+ @Override
+ protected void initialize() {
+ Robot.shooter.extendPunch();
+ }
+
+ @Override
+ protected void execute() {
+
+ }
+
+ @Override
+ protected boolean isFinished() {
+ return true;
+ }
+
+ @Override
+ protected void end() {
+
+ }
+
+ @Override
+ protected void interrupted() {
+
+ }
+
+}
+++ /dev/null
-package org.usfirst.frc.team3501.robot.commands.shooter;
-
-import org.usfirst.frc.team3501.robot.Robot;
-
-import edu.wpi.first.wpilibj.command.Command;
-
-public class Punch extends Command {
-
- @Override
- protected void initialize() {
- Robot.shooter.extendPunch();
- }
-
- @Override
- protected void execute() {
-
- }
-
- @Override
- protected boolean isFinished() {
- return true;
- }
-
- @Override
- protected void end() {
- Robot.shooter.retractPunch();
- }
-
- @Override
- protected void interrupted() {
-
- }
-
-}
--- /dev/null
+package org.usfirst.frc.team3501.robot.commands.shooter;
+
+import org.usfirst.frc.team3501.robot.Robot;
+
+import edu.wpi.first.wpilibj.command.Command;
+
+public class RetractPunch extends Command {
+
+ @Override
+ protected void initialize() {
+ Robot.shooter.retractPunch();
+ }
+
+ @Override
+ protected void execute() {
+
+ }
+
+ @Override
+ protected boolean isFinished() {
+ return true;
+ }
+
+ @Override
+ protected void end() {
+
+ }
+
+ @Override
+ protected void interrupted() {
+
+ }
+
+}
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;
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 Punch());
+ 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());
+ }
+
}
}
private Encoder encoder;
private Lidar lidar;
private Photogate photogate;
+ private boolean usePhotoGate;
public Shooter() {
shooter = new CANTalon(Constants.Shooter.PORT);
encoder = new Encoder(Constants.Shooter.ENCODER_PORT_A,
Constants.Shooter.ENCODER_PORT_B, false, EncodingType.k4X);
+ usePhotoGate = true;
}
/***
*/
public boolean isBallInside() {
- return photogate.isBallPresent();
+
+ if (usePhotogate())
+ return photogate.isBallPresent();
+ else
+ return true;
+
}
public void setSpeed(double speed) {
return false;
}
+ public boolean usePhotogate() {
+ return this.usePhotoGate;
+ }
+
+ public void togglePhotoGate() {
+ this.usePhotoGate = !this.usePhotoGate;
+ }
+
@Override
protected void initDefaultCommand() {
}