View Single Post
  #5   Spotlight this post!  
Unread 09-02-2014, 20:28
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: whileHeld() Motor Program Issue

I went through the code more closely than last time...

JoystickButton inherits whileHeld from Button.
Button extends Trigger.
whileHeld calls Trigger's whileActive method

From Javadoc:
Code:
whileActive

public void whileActive(Command command)
Constantly starts the given command while the button is held. Command.start() will be called repeatedly while the trigger is active, and will be canceled when the trigger becomes inactive.

Parameters:
command - the command to start
That's as far as I went. I assumed that calling start repeatedly on a command would cause it to cancel a previous running instance of the command. What it does do:

Command.start() adds the command to a vector of command that should be added to the list of commands that the scheduler will process.

Here's the catch, the scheduler doesn't do anything with the command if the command is already in the list. See line 145.

So I agree. whileHeld should work as advertised. I know that I've had trouble with it in the past, and have always implemented commands as I outlined above. Maybe the problems I had with whileHeld were actually with something else, I haven't gone back to investigate.
__________________
http://team2168.org
Reply With Quote