Adds default methods for Commands (#238) (#238)

Closes #235
This commit is contained in:
Krypton Cougars
2016-11-18 17:42:40 -05:00
committed by Peter Johnson
parent b115c75226
commit b78f580d47
24 changed files with 214 additions and 203 deletions

View File

@@ -188,6 +188,56 @@ bool Command::Run() {
return !IsFinished();
}
/**
* The initialize method is called the first time this Command is run after
* being started.
*/
void Command::Initialize() {}
/**
* The execute method is called repeatedly until this Command either finishes
* or is canceled.
*/
void Command::Execute() {}
/**
* Called when the command ended peacefully. This is where you may want
* to wrap up loose ends, like shutting off a motor that was being used
* in the command.
*/
void Command::End() {}
/**
* Returns whether this command is finished.
* If it is, then the command will be removed and {@link Command#end() end()}
* will be called.
*
* <p>It may be useful for a team to reference the {@link Command#isTimedOut()
* isTimedOut()} method for time-sensitive commands.</p>
*
* <p>By default this will always return false, which means it will never end
* automatically. It may still be cancelled manually or interrupted by another
* command. For most real-world scenarios you will override this method with
* additional logic.</p>
*
* @return whether this command is finished.
* @see Command#isTimedOut() isTimedOut()
*/
bool Command::IsFinished() { return false; }
/**
* Called when the command ends because somebody called
* {@link Command#cancel() cancel()} or another command shared the same
* requirements as this one, and booted it out.
*
* <p>This is where you may want to wrap up loose ends, like shutting off a
* motor that was being used in the command.</p>
*
* <p>Generally, it is useful to simply call the {@link Command#end() end()}
* method within this method, as done here.</p>
*/
void Command::Interrupted() { End(); }
void Command::_Initialize() {}
void Command::_Interrupted() {}