Skip to content

Commit

Permalink
Added a manual override on the indexer
Browse files Browse the repository at this point in the history
  • Loading branch information
omn0mn0m committed Apr 11, 2015
1 parent 66caabb commit 0a0a0f7
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 19 deletions.
6 changes: 4 additions & 2 deletions src/org/team708/robot/OI.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ public class OI {
// Claw Buttons
public static final int TOGGLE_CLAW_OPEN_BUTTON = Gamepad.button_R_Shoulder;
// public static final int INTERRUPT_CLAW_BUTTON = Gamepad.button_L_Shoulder;
public static final int ANTI_SWAG_CLAW_BUTTON = Gamepad.button_L_Shoulder;
// public static final int ANTI_SWAG_CLAW_BUTTON = Gamepad.button_L_Shoulder;
public static final int INDEXER_MANUAL_OVERRIDE_BUTTON = Gamepad.button_L_Shoulder;

// Claw Elevator Buttons
public static final int clawHeightIncrementButton = Gamepad.button_B;
Expand All @@ -64,7 +65,8 @@ public class OI {
private static final AxisDown toteDown = new AxisDown(operatorGamepad, TOTE_AXIS); // Moves the indexer down to release the tote stack
public static final Button toggleClawOpen = new JoystickButton(operatorGamepad, TOGGLE_CLAW_OPEN_BUTTON); // Opens and closes the claw on a toggle
// public static final Button interruptClaw = new JoystickButton(operatorGamepad, INTERRUPT_CLAW_BUTTON); // Toggles the wrist position (horizontal/vertical)
public static final Button antiSwagClaw = new JoystickButton(operatorGamepad, ANTI_SWAG_CLAW_BUTTON);
// public static final Button antiSwagClaw = new JoystickButton(operatorGamepad, ANTI_SWAG_CLAW_BUTTON);
public static final Button indexerManualOverride = new JoystickButton(operatorGamepad, INDEXER_MANUAL_OVERRIDE_BUTTON);
public static final Button clawHeightIncrement = new JoystickButton(operatorGamepad, clawHeightIncrementButton); // Increases the claw height by the height of a tote
public static final Button clawHeightDecrement = new JoystickButton(operatorGamepad, clawHeightDecrementButton); // Decreases the claw height by the height of a tote
public static final Button gucciGrabberToggle = new JoystickButton(operatorGamepad, GUCCI_GRABBER_TOGGLE_BUTTON); // Toggles the position of the gucci grabber
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ protected void execute() {
Robot.clawElevator.resetEncoder();
} else {}

if (OI.antiSwagClaw.get()) {
Robot.clawElevator.manualMove(moveSpeed * Constants.ANTISWAG);
} else {
// if (OI.antiSwagClaw.get()) {
// Robot.clawElevator.manualMove(moveSpeed * Constants.ANTISWAG);
// } else {
Robot.clawElevator.manualMove(moveSpeed);
}
// }

}

Expand Down
13 changes: 9 additions & 4 deletions src/org/team708/robot/commands/indexer/IndexerDown.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.team708.robot.commands.indexer;

import org.team708.robot.Constants;
import org.team708.robot.OI;
import org.team708.robot.Robot;

import edu.wpi.first.wpilibj.command.Command;
Expand All @@ -24,16 +25,20 @@ protected void initialize() {

// Called repeatedly when this Command is scheduled to run
protected void execute() {
// if (!Robot.indexer.indexerDown) {
Robot.indexer.lowerIndexer();
// }
if (!OI.indexerManualOverride.get()) {
// if (!Robot.indexer.indexerDown) {
Robot.indexer.lowerIndexer();
// }
} else {
cancel();
}
}

// Make this return true when this Command no longer needs to run execute()
protected boolean isFinished() {
// return Math708.isWithinThreshold(Robot.toteElevator.getEncoderDistance(), -Robot.toteElevator.TOP_ENCODER_DISTANCE, threshold)
// || Robot.toteElevator.elevatorDown;
return Robot.indexer.getEncoderDistance() <= -(Constants.TOTE_HEIGHT + EXTRA_TRAVEL_DISTANCE);
return Robot.indexer.getEncoderDistance() <= -(Constants.TOTE_HEIGHT + EXTRA_TRAVEL_DISTANCE) || OI.indexerManualOverride.get();
}

// Called once after isFinished returns true
Expand Down
21 changes: 13 additions & 8 deletions src/org/team708/robot/commands/indexer/IndexerUp.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.team708.robot.commands.indexer;

import org.team708.robot.Constants;
import org.team708.robot.OI;
import org.team708.robot.Robot;

import edu.wpi.first.wpilibj.command.Command;
Expand Down Expand Up @@ -41,22 +42,26 @@ protected void initialize() {

// Called repeatedly when this Command is scheduled to run
protected void execute() {
if (Robot.indexer.toteCount == 0 && !irHasTote) {
irHasTote = (Robot.indexer.getIRDistance() <= Constants.IR_HAS_TOTE_DISTANCE);
if (!OI.indexerManualOverride.get()) {
if (Robot.indexer.toteCount == 0 && !irHasTote) {
irHasTote = (Robot.indexer.getIRDistance() <= Constants.IR_HAS_TOTE_DISTANCE);
}

// if (!atToteLimitMax && hasToteInitially) {
Robot.indexer.raiseIndexer();
// }
} else {
cancel();
}

// if (!atToteLimitMax && hasToteInitially) {
Robot.indexer.raiseIndexer();
// }
}

// Make this return true when this Command no longer needs to run execute()
protected boolean isFinished() {
// return Robot.indexer.getEncoderDistance() >= Constants.TOTE_HEIGHT || !hasToteInitially;
if (Robot.indexer.toteCount>=1)
return (Robot.indexer.getEncoderDistance() >= Constants.TOTE_HEIGHT) || !hasToteInitially;
return (Robot.indexer.getEncoderDistance() >= Constants.TOTE_HEIGHT) || !hasToteInitially || OI.indexerManualOverride.get();
else
return (irHasTote && (Robot.indexer.getIRDistance() > Constants.IR_HAS_TOTE_DISTANCE)) || !hasToteInitially;
return (irHasTote && (Robot.indexer.getIRDistance() > Constants.IR_HAS_TOTE_DISTANCE)) || !hasToteInitially || OI.indexerManualOverride.get();
}

// Called once after isFinished returns true
Expand Down
44 changes: 44 additions & 0 deletions src/org/team708/robot/commands/indexer/JoystickIndexerControl.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package org.team708.robot.commands.indexer;

import org.team708.robot.OI;
import org.team708.robot.Robot;
import org.team708.robot.util.Gamepad;

import edu.wpi.first.wpilibj.command.Command;

/**
*
*/
public class JoystickIndexerControl extends Command {

public JoystickIndexerControl() {
// Use requires() here to declare subsystem dependencies
// eg. requires(chassis);
requires(Robot.indexer);
}

// Called just before this Command runs the first time
protected void initialize() {
}

// Called repeatedly when this Command is scheduled to run
protected void execute() {
if (OI.indexerManualOverride.get()) {
Robot.indexer.move(OI.operatorGamepad.getAxis(Gamepad.leftStick_Y));
}
}

// Make this return true when this Command no longer needs to run execute()
protected boolean isFinished() {
return false;
}

// Called once after isFinished returns true
protected void end() {
}

// Called when another command which requires one or more of the same
// subsystems is scheduled to run
protected void interrupted() {
}
}
7 changes: 6 additions & 1 deletion src/org/team708/robot/subsystems/Indexer.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.team708.robot.Constants;
import org.team708.robot.RobotMap;
import org.team708.robot.commands.indexer.JoystickIndexerControl;
import org.team708.robot.util.IRSensor;

import edu.wpi.first.wpilibj.CANTalon;
Expand Down Expand Up @@ -95,6 +96,10 @@ public void lowerIndexer() {
// indexerMotorRight.set(Constants.MOTOR_REVERSE);
}

public void move(double speed) {
indexerMotorLeft.set(-speed);
}

/**
* Turns off the indexer so it does not move
*/
Expand All @@ -120,7 +125,7 @@ public void setToteCount(int toteCount) {

public void initDefaultCommand() {
// Set the default command for a subsystem here.
//setDefaultCommand(new MySpecialCommand());
setDefaultCommand(new JoystickIndexerControl());
}

/**
Expand Down

0 comments on commit 0a0a0f7

Please sign in to comment.