Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
UltimateAscent/src/org/usfirst/frc3946/UltimateAscent/commands/LevelDuringClimb.java /
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
64 lines (52 sloc)
1.71 KB
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
| /* | |
| * To change this template, choose Tools | Templates | |
| * and open the template in the editor. | |
| */ | |
| package org.usfirst.frc3946.UltimateAscent.commands; | |
| import edu.wpi.first.wpilibj.Timer; | |
| /** | |
| * | |
| * @author 10374778 | |
| */ | |
| public class LevelDuringClimb extends CommandBase { | |
| double currentTime; | |
| double lastFail = 0; | |
| boolean balanced = false; | |
| public LevelDuringClimb() { | |
| // Use requires() here to declare subsystem dependencies | |
| // eg. requires(chassis); | |
| // requires (climbingMotor); | |
| } | |
| // Called just before this Command runs the first time | |
| protected void initialize() { | |
| System.out.println("LevelDuringClimb"); | |
| // climbingMotor.setSetpoint(0.0); | |
| // climbingMotor.enable(); | |
| setTimeout (2); | |
| } | |
| // Called repeatedly when this Command is scheduled to run | |
| protected void execute() { | |
| currentTime = Timer.getFPGATimestamp(); | |
| if (climbingMotor.AmIBalanced() == false) { | |
| lastFail = currentTime; | |
| balanced = false; | |
| } else { | |
| if (currentTime - lastFail > 2) { | |
| balanced = true; | |
| } | |
| } | |
| } | |
| // Make this return true when this Command no longer needs to run execute() | |
| protected boolean isFinished() { | |
| return balanced; | |
| } | |
| // Called once after isFinished returns true | |
| protected void end() { | |
| climbingMotor.disable(); | |
| } | |
| // Called when another command which requires one or more of the same | |
| // subsystems is scheduled to run | |
| protected void interrupted() { | |
| System.out.println("Climbing interrupted"); | |
| } | |
| } |