mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-05 03:21:42 +00:00
Command::IsFinished() must be overriden by subclasses again (#353)
Documentation was added for InstantCommand and TimedCommand.
This commit is contained in:
committed by
Peter Johnson
parent
140c365e4b
commit
b25a7cb370
@@ -277,16 +277,15 @@ public abstract class Command implements NamedSendable {
|
||||
* <p>It may be useful for a team to reference the {@link Command#isTimedOut() isTimedOut()}
|
||||
* method for time-sensitive commands.
|
||||
*
|
||||
* <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>Returning false will result in the command never ending automatically. It may still be
|
||||
* cancelled manually or interrupted by another command. Returning true will result in the
|
||||
* command executing once and finishing immediately. We recommend using {@link InstantCommand}
|
||||
* for this.
|
||||
*
|
||||
* @return whether this command is finished.
|
||||
* @see Command#isTimedOut() isTimedOut()
|
||||
*/
|
||||
protected boolean isFinished() {
|
||||
return false;
|
||||
}
|
||||
protected abstract boolean isFinished();
|
||||
|
||||
/**
|
||||
* Called when the command ended peacefully. This is where you may want to wrap up loose ends,
|
||||
|
||||
@@ -7,10 +7,21 @@
|
||||
|
||||
package edu.wpi.first.wpilibj.command;
|
||||
|
||||
/**
|
||||
* This command will execute once, then finish immediately afterward.
|
||||
*
|
||||
* <p>Subclassing {@link InstantCommand} is shorthand for returning true from
|
||||
* {@link Command isFinished}.
|
||||
*/
|
||||
public class InstantCommand extends Command {
|
||||
|
||||
public InstantCommand() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@link InstantCommand InstantCommand} with the given name.
|
||||
* @param name the name for this command
|
||||
*/
|
||||
public InstantCommand(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
@@ -7,6 +7,10 @@
|
||||
|
||||
package edu.wpi.first.wpilibj.command;
|
||||
|
||||
/**
|
||||
* A {@link TimedCommand} will wait for a timeout before finishing.
|
||||
* {@link TimedCommand} is used to execute a command for a given amount of time.
|
||||
*/
|
||||
public class TimedCommand extends Command {
|
||||
public TimedCommand(String name, double timeout) {
|
||||
super(name, timeout);
|
||||
|
||||
Reference in New Issue
Block a user