|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
Can isTimedOut() be used in a command group?
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: Code:
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
}
}
}
Tedi Last edited by Tedi : 07-03-2014 at 20:52. |
|
#2
|
||||||
|
||||||
|
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.
|
|
#3
|
||||
|
||||
|
Re: Can isTimedOut() be used in a command group?
No. The constructor only runs once at robot initialization, so none of the commands should be timed out.
|
|
#4
|
|||
|
|||
|
Re: Can isTimedOut() be used in a command group?
Quote:
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 |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|