View Single Post
  #8   Spotlight this post!  
Unread 09-02-2014, 22:40
otherguy's Avatar
otherguy otherguy is offline
sparkE
AKA: James
FRC #2168 (The Aluminum Falcons)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2009
Location: CT
Posts: 429
otherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to behold
Re: Robots don't quit

Quote:
wait so would this be fine
No.

If you're using commands, I would suggest the following implementation. Assuming the code you wrote is inside a command.
  • Create and start the timer in the initialize method of a command.
  • Inside the execute method run the intake
  • inside isFinished() have your check to see if you've waited long enough:
    Code:
    return timer.get() >= Constants.solenoid_timing.getDouble()
  • inside the end method, stop running the intake

Alternatively, you could create the following commands
  • RunIntake - a command which just runs the intake then immediately finishes (isFinished returns true) - leaving the intake running
  • Delay command. This is an empty command that does nothing and never finishes. See how it is useful below.
  • StopIntake - a command that just stops the intake and immediately finishes (isFinished returns true).

You could then make a command group that looked something like this:
Code:
public class RunIntakeThenStop extends CommandGroup {
  public RunIntakeThenStop() {
    addSequential(new RunIntake());
    addSequential(new Delay(), 2.0); //the 2nd parameter is a timeout period in seconds.
    addSequential(new StopIntake());
  }
}
See the javadoc for help using command groups and info on timeout periods for commands.
__________________
http://team2168.org

Last edited by otherguy : 09-02-2014 at 22:41. Reason: fixed error in code
Reply With Quote