Advertisement
Guest User

Untitled

a guest
Jan 18th, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. package org.usfirst.frc.team1797.robot.commands;
  2.  
  3. import org.usfirst.frc.team1797.robot.Robot;
  4.  
  5. import edu.wpi.first.wpilibj.command.Command;
  6.  
  7. /**
  8. *
  9. */
  10. public class AutoCrossBaseline13 extends Command {
  11.  
  12. private static final double DRIVE_LENGTH = 2; //the time for the command to run for (in seconds)
  13. private static final double DRIVE_SPEED = 0.3; // Speed for motors to run at while executing
  14.  
  15. private long startTime = Long.MAX_VALUE; //Similar to last actuation but used for timing motors.
  16.  
  17. public AutoCrossBaseline13() {
  18. // Use requires() here to declare subsystem dependencies
  19. // eg. requires(chassis);
  20. requires(Robot.DRIVE_TRAIN);
  21. }
  22.  
  23. // Called just before this Command runs the first time
  24. protected void initialize() {
  25. startTime = System.currentTimeMillis();
  26. Robot.DRIVE_TRAIN.arcadeDrive(DRIVE_SPEED, 0);
  27. }
  28.  
  29. // Called repeatedly when this Command is scheduled to run
  30. protected void execute() {
  31. }
  32.  
  33. // Make this return true when this Command no longer needs to run execute()
  34. protected boolean isFinished() {
  35. return System.currentTimeMillis() - startTime >= (DRIVE_LENGTH * 1000);
  36. }
  37.  
  38. // Called once after isFinished returns true
  39. protected void end() {
  40. Robot.DRIVE_TRAIN.stopDrive();
  41. }
  42.  
  43. // Called when another command which requires one or more of the same
  44. // subsystems is scheduled to run
  45. protected void interrupted() {
  46. end();
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement