public static final Value HIGH_GEAR = DoubleSolenoid.Value.kForward;
public static final Value LOW_GEAR = DoubleSolenoid.Value.kReverse;
- public static final double CLIMBER_SPEED = 5;
-
// MOTOR CONTROLLERS
public static final int FRONT_LEFT = 1;
public static final int FRONT_RIGHT = 3;
package org.usfirst.frc.team3501.robot;
-import org.usfirst.frc.team3501.robot.commandgroups.ToggleWinch;
+import org.usfirst.frc.team3501.robot.commands.climber.ToggleWinch;
import org.usfirst.frc.team3501.robot.commands.driving.ToggleGear;
import org.usfirst.frc.team3501.robot.commands.intake.ReverseIntakeContinuous;
import org.usfirst.frc.team3501.robot.commands.intake.RunIntakeContinuous;
toggleWinch = new JoystickButton(leftJoystick,
Constants.OI.TOGGLE_WINCH_PORT);
- /*
- * if (!Robot.getDriveTrain().isClimbing()) { toggleWinch.whenPressed(new
- * RunWinchContinuous()); Robot.getDriveTrain().setClimbing(true); } else {
- * toggleWinch.whenPressed(new MaintainClimbedPosition());
- * Robot.getDriveTrain().setClimbing(false); }
- */
toggleWinch.whenPressed(new ToggleWinch());
}
+++ /dev/null
-package org.usfirst.frc.team3501.robot.commandgroups;
-
-import org.usfirst.frc.team3501.robot.Robot;
-import org.usfirst.frc.team3501.robot.commands.climber.MaintainClimbedPosition;
-import org.usfirst.frc.team3501.robot.commands.climber.RunWinchContinuous;
-
-import edu.wpi.first.wpilibj.command.CommandGroup;
-
-public class ToggleWinch extends CommandGroup {
-
- public ToggleWinch() {
- if (!Robot.getDriveTrain().isClimbing()) {
- Robot.getDriveTrain().setClimbing(true);
- addSequential(new RunWinchContinuous());
-
- } else {
- Robot.getDriveTrain().setClimbing(false);
- addSequential(new MaintainClimbedPosition());
- }
- }
-
-}
package org.usfirst.frc.team3501.robot.commands.climber;
import org.usfirst.frc.team3501.robot.Robot;
+import org.usfirst.frc.team3501.robot.subsystems.DriveTrain;
import edu.wpi.first.wpilibj.command.Command;
*
*/
public class RunWinchContinuous extends Command {
+ DriveTrain driveTrain = Robot.getDriveTrain();
+ private double climbingSpeed;
/**
* See JavaDoc comment in class for details
* value range is from -1 to 1
*/
public RunWinchContinuous() {
- requires(Robot.getDriveTrain());
+ requires(driveTrain);
+ climbingSpeed = driveTrain.CLIMBER_SPEED;
}
@Override
protected void initialize() {
- Robot.getDriveTrain().setMotorValues(
- Robot.getDriveTrain().getClimbingSpeed(),
- Robot.getDriveTrain().getClimbingSpeed());
}
@Override
protected void execute() {
-
+ Robot.getDriveTrain().setMotorValues(climbingSpeed, climbingSpeed);
}
@Override
--- /dev/null
+package org.usfirst.frc.team3501.robot.commands.climber;
+
+import org.usfirst.frc.team3501.robot.Robot;
+import org.usfirst.frc.team3501.robot.subsystems.DriveTrain;
+
+import edu.wpi.first.wpilibj.command.Command;
+
+/**
+ *
+ */
+public class ToggleWinch extends Command {
+ DriveTrain driveTrain = Robot.getDriveTrain();
+ private double climbingSpeed;
+ private double maintainPositionSpeed;
+
+ public ToggleWinch() {
+ requires(driveTrain);
+ climbingSpeed = driveTrain.CLIMBER_SPEED;
+ maintainPositionSpeed = driveTrain.MAINTAIN_CLIMBED_POSITION;
+ }
+
+ @Override
+ protected void initialize() {
+ }
+
+ @Override
+ protected void execute() {
+ if (driveTrain.shouldBeClimbing) {
+ driveTrain.setMotorValues(climbingSpeed, climbingSpeed);
+ } else {
+ driveTrain.setMotorValues(maintainPositionSpeed, maintainPositionSpeed);
+ }
+ }
+
+ @Override
+ protected boolean isFinished() {
+ return false;
+ }
+
+ @Override
+ protected void end() {
+ driveTrain.shouldBeClimbing = !driveTrain.shouldBeClimbing;
+ }
+
+ @Override
+ protected void interrupted() {
+ end();
+ }
+}
public static final int ENCODER_PULSES_PER_REVOLUTION = 256;
public static final double INCHES_PER_PULSE = WHEEL_DIAMETER * Math.PI
/ ENCODER_PULSES_PER_REVOLUTION;
- public static final int MAINTAIN_CLIMBED_POSITION = 0;
- public static final int TIME_TO_CLIMB_FOR = 0;
+
+ public static final double MAINTAIN_CLIMBED_POSITION = 0;
+ public static final double TIME_TO_CLIMB_FOR = 0;
+ public static final double CLIMBER_SPEED = 0;
+
private static DriveTrain driveTrain;
private final CANTalon frontLeft, frontRight, rearLeft, rearRight;
private ADXRS450_Gyro imu;
- private boolean isClimbing;
- private static double CLIMBER_SPEED;;
+ public boolean shouldBeClimbing;
private DriveTrain() {
// MOTOR CONTROLLERS
rightGearPiston = new DoubleSolenoid(Constants.DriveTrain.MODULE_NUMBER,
Constants.DriveTrain.RIGHT_GEAR_PISTON_FORWARD,
Constants.DriveTrain.RIGHT_GEAR_PISTON_REVERSE);
-
- CLIMBER_SPEED = Constants.DriveTrain.CLIMBER_SPEED;
}
public static DriveTrain getDriveTrain() {
frontRight.set(-right);
rearRight.set(-right);
- this.isClimbing = true;
}
public void joystickDrive(final double thrust, final double twist) {
public void stop() {
setMotorValues(0, 0);
- this.isClimbing = false;
}
public double getLeftMotorVal() {
protected void initDefaultCommand() {
setDefaultCommand(new JoystickDrive());
}
-
- public boolean isClimbing() {
- return this.isClimbing;
- }
-
- public void setClimbing(boolean isClimbing) {
- this.isClimbing = isClimbing;
- }
-
- public double getClimbingSpeed() {
- return this.CLIMBER_SPEED;
- }
-
}