public void whenReleased(int button, Command c) {
buttons.get(button).whenReleased(c);
}
+
+ public void whileHeld(int button, Command c) {
+ buttons.get(button).whileHeld(c);
+ }
}
right.whenPressed(1, new CloseClaw());
right.whenReleased(1, new OpenClaw());
+ right.whenPressed(2, new ToggleClaw());
+
right.whenPressed(11, new TurnOffCompressor());
right.whenPressed(12, new TurnOffCompressor());
right.whenPressed(7, new TurnOnCompressor());
right.whenPressed(8, new TurnOnCompressor());
+
+ // potential bug point: this should "Just Work" because as soon as
+ // command stops running, left stick pos at 0 should take over...
+ // if that is not the case, arm will continue indefinitely.
+ left.whileHeld(7, new TensionLeftWinch(RobotMap.ARM_ADJUST_SPEED));
+ left.whileHeld(6, new TensionLeftWinch(-RobotMap.ARM_ADJUST_SPEED));
+ left.whileHeld(11, new TensionRightWinch(RobotMap.ARM_ADJUST_SPEED));
+ left.whileHeld(10, new TensionRightWinch(-RobotMap.ARM_ADJUST_SPEED));
}
public double getForwardL() {
// arm
public static final int LEFT_WINCH_ADDRESS = 2, RIGHT_WINCH_ADDRESS = 7;
+ public static final double ARM_ADJUST_SPEED = 0.3;
+
// auton
public static final double OVER_STEP_TIME = 1.2, OVER_STEP_SPEED = 0.7,
PAST_STEP_TIME = 1.5, PAST_STEP_SPEED = 0.5;
import org.usfirst.frc.team3501.robot.subsystems.*;
import edu.wpi.first.wpilibj.command.Command;
+import edu.wpi.first.wpilibj.command.Scheduler;
public abstract class CommandBase extends Command {
pneumatics = Robot.pneumatics;
}
+ protected void schedule(Command c) {
+ Scheduler.getInstance().add(c);
+ }
+
protected void initialize() {}
protected void execute() {}
--- /dev/null
+package org.usfirst.frc.team3501.robot.commands;
+
+public class TensionLeftWinch extends CommandBase {
+
+ private double speed;
+
+ public TensionLeftWinch(double speed) {
+ super("TensionLeftWinch");
+ requires(arm);
+
+ this.speed = speed;
+ }
+
+ protected void execute() {
+ arm.moveLeft(speed);
+ }
+
+ protected boolean isFinished() {
+ return true;
+ }
+}
--- /dev/null
+package org.usfirst.frc.team3501.robot.commands;
+
+public class TensionRightWinch extends CommandBase {
+
+ private double speed;
+
+ public TensionRightWinch(double speed) {
+ super("TensionRightWinch");
+ requires(arm);
+
+ this.speed = speed;
+ }
+
+ protected void execute() {
+ arm.moveRight(speed);
+ }
+
+ protected boolean isFinished() {
+ return true;
+ }
+}
--- /dev/null
+package org.usfirst.frc.team3501.robot.commands;
+
+public class ToggleClaw extends CommandBase {
+
+ public ToggleClaw() {
+ super("ToggleClaw");
+ requires(claw);
+ }
+
+ protected void initialize() {
+ if (claw.isOpen())
+ schedule(new CloseClaw());
+ else
+ schedule(new OpenClaw());
+ }
+
+ protected boolean isFinished() {
+ return true;
+ }
+}
piston.set(RobotMap.CLOSED);
}
+ public boolean isOpen() {
+ return piston.get().equals(RobotMap.OPEN);
+ }
+
+ public boolean isClosed() {
+ return piston.get().equals(RobotMap.CLOSED);
+ }
+
public void initDefaultCommand() {}
}