View Single Post
  #2   Spotlight this post!  
Unread 09-02-2012, 09:16
Brian Selle's Avatar
Brian Selle Brian Selle is offline
Mentor
FRC #3310 (Black Hawk Robotics)
Team Role: Engineer
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Texas
Posts: 165
Brian Selle has a spectacular aura aboutBrian Selle has a spectacular aura aboutBrian Selle has a spectacular aura about
Re: Set command to run for a certain amount of time

Here is a command that uses a timer. When you create an instance of the command you pass in the time (seconds) you want it to run.


package edu.rhhs.frc.commands;

/**
* @author rhhs
*/
public class ConveyorTimed extends CommandBase {

private double m_timeout;

public ConveyorTimed(double timeout) {
m_timeout = timeout;
requires(m_conveyor);
}

protected void initialize() {
setTimeout(m_timeout);
m_conveyor.start();
}

protected void execute() {
}

protected boolean isFinished() {
return isTimedOut();
}

protected void end() {
m_conveyor.stop();
}

protected void interrupted() {
m_conveyor.stop();
}
}
Reply With Quote