|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
Re: Cancel a command
Whoops, didn't see that section of the docs
![]() There's an easy way to do what you want in your situation though. Code:
public class ScissorToPosition extends Command {
// ...
boolean isUnsafe = false;
public void initialize() {
if(m_setpoint > 70 && Robot.wristPID.getSetpoint() > 30) {
System.out.println("Scissor canceled since wrist > 30");
isUnsafe = true;
} else {
isUnsafe = false;
// init as usual
}
}
// ...
public void execute() {
if(isUnsafe) {
return;
// IMPORTANT. execute() will be called once regardless of isFinished() status
}
// execute as usual
}
public void isFinished() {
if(isUnsafe) {
return true;
}
return Robot.scissorPID.onTarget();
}
}
|
|
#2
|
|||
|
|||
|
Re: Cancel a command
Good to know I'll have them add that part to the code as well.
Quote:
|
|
#3
|
||||
|
||||
|
Re: Cancel a command
Quote:
I'm curious as to why a command can't be canceled in a commandgroup. Is there any particular reason for that? |
|
#4
|
|||
|
|||
|
Re: Cancel a command
Right! Seems like you should be able to cancel a running command anywhere. maybe when its in a Command group its not its own object anymore. I guess for now we will just have to play by the rules.
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|