Log in

View Full Version : Can isTimedOut() be used in a command group?


Tedi
07-03-2014, 20:50
Hey guys,
So I was wondering if in the constructor of a command group (where addParallel and addSequential are added), can I also add setTimeout(x); and then check within the same command group if it has timed out? I am asking because I am unsure if setting a timeout inside a command group actually works or if it's only for commands.

Example:


public class cmdg extends CommandGroup {
boolean A = false;
public cmdg() {
setTimeout(x);
addSequential(command_here, x);
if (isTimedOut()) {
A = false;
} else {
A = true;
}
if (A) {
//stuff here
} else {
//stuff here
}



}
}


Thanks,
Tedi

Joe Ross
07-03-2014, 22:20
Since CommandGroup extends Command, you can override isFinished. However CommandGroup isFinished implements a few checks, so you should make your isFinished be super.isFinished() || isTimedout() or you'll break the CommandGroup.

Arhowk
09-03-2014, 15:27
No. The constructor only runs once at robot initialization, so none of the commands should be timed out.

NotInControl
14-03-2014, 15:51
No. The constructor only runs once at robot initialization, so none of the commands should be timed out.

To reiterate this....

The only way to use isTimedOut is to first use seTimeOut within the command, or command group.

If you use the 2 paramter constructor to set the timeout value, this is never seen by the command, instead I believe it is passed to the scheduler to be killed.

So isTimedOut will always return false, unless you exlicitly set the timeout within the command itself.

Is that clear?

Hope this helps,
Kevin