-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved tote elevator commands to new package
- Loading branch information
Nam Tran
committed
Feb 1, 2015
1 parent
126f0d7
commit 702937b
Showing
2 changed files
with
104 additions
and
0 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
src/org/team708/robot/commands/toteElevator/ToteElevatorDown.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package org.team708.robot.commands.toteElevator; | ||
import org.team708.robot.Robot; | ||
import org.team708.robot.util.Math708; | ||
|
||
import edu.wpi.first.wpilibj.command.Command; | ||
|
||
/** | ||
* | ||
*/ | ||
public class ToteElevatorDown extends Command { | ||
|
||
private final double threshold = 1; | ||
|
||
public ToteElevatorDown() { | ||
// Use requires() here to declare subsystem dependencies | ||
// eg. requires(chassis); | ||
requires(Robot.toteElevator); | ||
} | ||
|
||
// 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 (!Robot.toteElevator.elevatorDown) { | ||
Robot.toteElevator.lowerTote(); | ||
} | ||
} | ||
|
||
// 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; | ||
} | ||
|
||
// Called once after isFinished returns true | ||
protected void end() { | ||
Robot.toteElevator.stopTote(); | ||
Robot.toteElevator.elevatorDown = true; | ||
Robot.toteElevator.setToteCount(0); | ||
Robot.toteElevator.resetEncoder(); | ||
} | ||
|
||
// Called when another command which requires one or more of the same | ||
// subsystems are scheduled to run | ||
protected void interrupted() { | ||
end(); | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
src/org/team708/robot/commands/toteElevator/ToteElevatorUp.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package org.team708.robot.commands.toteElevator; | ||
|
||
import org.team708.robot.Robot; | ||
import org.team708.robot.util.Math708; | ||
|
||
import edu.wpi.first.wpilibj.command.Command; | ||
|
||
/** | ||
* | ||
*/ | ||
public class ToteElevatorUp extends Command { | ||
|
||
private final double threshold = 1; | ||
private boolean atToteLimitMax; | ||
|
||
public ToteElevatorUp() { | ||
// Use requires() here to declare subsystem dependencies | ||
// eg. requires(chassis); | ||
requires(Robot.toteElevator); | ||
} | ||
|
||
// Called just before this Command runs the first time | ||
protected void initialize() { | ||
atToteLimitMax = (Robot.toteElevator.toteCount == Robot.toteElevator.TOTE_UPPER_LIMIT); | ||
|
||
} | ||
|
||
// Called repeatedly when this Command is scheduled to run | ||
protected void execute() { | ||
if (!atToteLimitMax) { | ||
Robot.toteElevator.raiseTote(); | ||
} | ||
} | ||
|
||
// 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) | ||
|| atToteLimitMax; | ||
} | ||
|
||
// Called once after isFinished returns true | ||
protected void end() { | ||
Robot.toteElevator.stopTote(); | ||
Robot.toteElevator.setToteCount(Robot.toteElevator.getToteCount() + 1); | ||
Robot.toteElevator.resetEncoder(); | ||
Robot.toteElevator.elevatorDown = false; | ||
} | ||
|
||
// Called when another command which requires one or more of the same | ||
// subsystems are scheduled to run | ||
protected void interrupted() { | ||
end(); | ||
} | ||
} |