mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-02 02:51:42 +00:00
Reflowed comments and removed commented out code (#735)
This commit is contained in:
committed by
Peter Johnson
parent
1e8d18b328
commit
c663d7cd16
@@ -22,29 +22,24 @@ class Subsystem;
|
||||
|
||||
/**
|
||||
* The Command class is at the very core of the entire command framework.
|
||||
* Every command can be started with a call to {@link Command#Start() Start()}.
|
||||
* Once a command is started it will call {@link Command#Initialize()
|
||||
* Initialize()}, and then will repeatedly call
|
||||
* {@link Command#Execute() Execute()} until the
|
||||
* {@link Command#IsFinished() IsFinished()} returns true. Once it does,
|
||||
* {@link Command#End() End()} will be called.
|
||||
*
|
||||
* <p>However, if at any point while it is running {@link Command#Cancel()
|
||||
* Cancel()} is called, then the command will be stopped and
|
||||
* {@link Command#Interrupted() Interrupted()} will be called.</p>
|
||||
* Every command can be started with a call to Start(). Once a command is
|
||||
* started it will call Initialize(), and then will repeatedly call Execute()
|
||||
* until the IsFinished() returns true. Once it does,End() will be called.
|
||||
*
|
||||
* <p>If a command uses a {@link Subsystem}, then it should specify that it does
|
||||
* so by calling the {@link Command#Requires(Subsystem) Requires(...)} method
|
||||
* in its constructor. Note that a Command may have multiple requirements, and
|
||||
* {@link Command#Requires(Subsystem) Requires(...)} should be called for each
|
||||
* one.</p>
|
||||
* However, if at any point while it is running Cancel() is called, then the
|
||||
* command will be stopped and Interrupted() will be called.
|
||||
*
|
||||
* <p>If a command is running and a new command with shared requirements is
|
||||
* started, then one of two things will happen. If the active command is
|
||||
* interruptible, then {@link Command#Cancel() Cancel()} will be called and the
|
||||
* command will be removed to make way for the new one. If the active command
|
||||
* is not interruptible, the other one will not even be started, and the active
|
||||
* one will continue functioning.</p>
|
||||
* If a command uses a Subsystem, then it should specify that it does so by
|
||||
* calling the Requires() method in its constructor. Note that a Command may
|
||||
* have multiple requirements, and Requires() should be called for each one.
|
||||
*
|
||||
* If a command is running and a new command with shared requirements is
|
||||
* started, then one of two things will happen. If the active command is
|
||||
* interruptible, then Cancel() will be called and the command will be removed
|
||||
* to make way for the new one. If the active command is not interruptible, the
|
||||
* other one will not even be started, and the active one will continue
|
||||
* functioning.
|
||||
*
|
||||
* @see CommandGroup
|
||||
* @see Subsystem
|
||||
@@ -88,19 +83,19 @@ class Command : public ErrorBase, public NamedSendable {
|
||||
|
||||
/**
|
||||
* 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>
|
||||
* If it is, then the command will be removed and End() will be called.
|
||||
*
|
||||
* <p>Returning false will result in the command never ending automatically.
|
||||
* It may be useful for a team to reference the IsTimedOut() method for
|
||||
* time-sensitive commands.
|
||||
*
|
||||
* 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.</p>
|
||||
* immediately. We recommend using InstantCommand for this.
|
||||
*
|
||||
* @return whether this command is finished.
|
||||
* @see Command#isTimedOut() isTimedOut()
|
||||
* @return Whether this command is finished.
|
||||
* @see IsTimedOut()
|
||||
*/
|
||||
virtual bool IsFinished() = 0;
|
||||
|
||||
@@ -117,42 +112,41 @@ class Command : public ErrorBase, public NamedSendable {
|
||||
|
||||
private:
|
||||
void LockChanges();
|
||||
/*synchronized*/ void Removed();
|
||||
void Removed();
|
||||
void StartRunning();
|
||||
void StartTiming();
|
||||
|
||||
/** The name of this command */
|
||||
// The name of this command
|
||||
std::string m_name;
|
||||
|
||||
/** The time since this command was initialized */
|
||||
// The time since this command was initialized
|
||||
double m_startTime = -1;
|
||||
|
||||
/** The time (in seconds) before this command "times out" (or -1 if no
|
||||
* timeout) */
|
||||
// The time (in seconds) before this command "times out" (-1 if no timeout)
|
||||
double m_timeout;
|
||||
|
||||
/** Whether or not this command has been initialized */
|
||||
// Whether or not this command has been initialized
|
||||
bool m_initialized = false;
|
||||
|
||||
/** The requirements (or null if no requirements) */
|
||||
// The requirements (or null if no requirements)
|
||||
SubsystemSet m_requirements;
|
||||
|
||||
/** Whether or not it is running */
|
||||
// Whether or not it is running
|
||||
bool m_running = false;
|
||||
|
||||
/** Whether or not it is interruptible*/
|
||||
// Whether or not it is interruptible
|
||||
bool m_interruptible = true;
|
||||
|
||||
/** Whether or not it has been canceled */
|
||||
// Whether or not it has been canceled
|
||||
bool m_canceled = false;
|
||||
|
||||
/** Whether or not it has been locked */
|
||||
// Whether or not it has been locked
|
||||
bool m_locked = false;
|
||||
|
||||
/** Whether this command should run when the robot is disabled */
|
||||
// Whether this command should run when the robot is disabled
|
||||
bool m_runWhenDisabled = false;
|
||||
|
||||
/** The {@link CommandGroup} this is in */
|
||||
// The CommandGroup this is in
|
||||
CommandGroup* m_parent = nullptr;
|
||||
|
||||
int m_commandID = m_commandCounter++;
|
||||
|
||||
@@ -17,21 +17,18 @@
|
||||
namespace frc {
|
||||
|
||||
/**
|
||||
* A {@link CommandGroup} is a list of commands which are executed in sequence.
|
||||
* A CommandGroup is a list of commands which are executed in sequence.
|
||||
*
|
||||
* <p>Commands in a {@link CommandGroup} are added using the {@link
|
||||
* CommandGroup#AddSequential(Command) AddSequential(...)} method and are
|
||||
* called sequentially. {@link CommandGroup CommandGroups} are themselves
|
||||
* {@link Command Commands} and can be given to other
|
||||
* {@link CommandGroup CommandGroups}.</p>
|
||||
* Commands in a CommandGroup are added using the AddSequential() method and are
|
||||
* called sequentially. CommandGroups are themselves Commands and can be given
|
||||
* to other CommandGroups.
|
||||
*
|
||||
* <p>{@link CommandGroup CommandGroups} will carry all of the requirements of
|
||||
* their {@link Command subcommands}. Additional requirements can be specified
|
||||
* by calling {@link CommandGroup#Requires(Subsystem) Requires(...)} normally
|
||||
* in the constructor.</P>
|
||||
* CommandGroups will carry all of the requirements of their Command
|
||||
* subcommands. Additional requirements can be specified by calling Requires()
|
||||
* normally in the constructor.
|
||||
*
|
||||
* <p>CommandGroups can also execute commands in parallel, simply by adding them
|
||||
* using {@link CommandGroup#AddParallel(Command) AddParallel(...)}.</p>
|
||||
* CommandGroups can also execute commands in parallel, simply by adding them
|
||||
* using AddParallel().
|
||||
*
|
||||
* @see Command
|
||||
* @see Subsystem
|
||||
@@ -63,13 +60,13 @@ class CommandGroup : public Command {
|
||||
private:
|
||||
void CancelConflicts(Command* command);
|
||||
|
||||
/** The commands in this group (stored in entries) */
|
||||
// The commands in this group (stored in entries)
|
||||
std::vector<CommandGroupEntry> m_commands;
|
||||
|
||||
/** The active children in this group (stored in entries) */
|
||||
// The active children in this group (stored in entries)
|
||||
std::list<CommandGroupEntry> m_children;
|
||||
|
||||
/** The current command, -1 signifies that none have been run */
|
||||
// The current command, -1 signifies that none have been run
|
||||
int m_currentCommandIndex = -1;
|
||||
};
|
||||
|
||||
|
||||
@@ -15,25 +15,17 @@
|
||||
namespace frc {
|
||||
|
||||
/**
|
||||
* A {@link ConditionalCommand} is a {@link Command} that starts one of two
|
||||
* commands.
|
||||
* A ConditionalCommand is a Command that starts one of two commands.
|
||||
*
|
||||
* <p>
|
||||
* A {@link ConditionalCommand} uses m_condition to determine whether it should
|
||||
* run m_onTrue or m_onFalse.
|
||||
* </p>
|
||||
* A ConditionalCommand uses m_condition to determine whether it should run
|
||||
* m_onTrue or m_onFalse.
|
||||
*
|
||||
* <p>
|
||||
* A {@link ConditionalCommand} adds the proper {@link Command} to the {@link
|
||||
* Scheduler} during {@link ConditionalCommand#initialize()} and then {@link
|
||||
* ConditionalCommand#isFinished()} will return true once that {@link Command}
|
||||
* has finished executing.
|
||||
* </p>
|
||||
* A ConditionalCommand adds the proper Command to the Scheduler during
|
||||
* Initialize() and then IsFinished() will return true once that Command has
|
||||
* finished executing.
|
||||
*
|
||||
* <p>
|
||||
* If no {@link Command} is specified for m_onFalse, the occurrence of that
|
||||
* condition will be a no-op.
|
||||
* </p>
|
||||
* If no Command is specified for m_onFalse, the occurrence of that condition
|
||||
* will be a no-op.
|
||||
*
|
||||
* @see Command
|
||||
* @see Scheduler
|
||||
@@ -59,21 +51,13 @@ class ConditionalCommand : public Command {
|
||||
void Interrupted() override;
|
||||
|
||||
private:
|
||||
/**
|
||||
* The Command to execute if {@link ConditionalCommand#Condition()} returns
|
||||
* true
|
||||
*/
|
||||
// The Command to execute if Condition() returns true
|
||||
Command* m_onTrue;
|
||||
|
||||
/**
|
||||
* The Command to execute if {@link ConditionalCommand#Condition()} returns
|
||||
* false
|
||||
*/
|
||||
// The Command to execute if Condition() returns false
|
||||
Command* m_onFalse;
|
||||
|
||||
/**
|
||||
* Stores command chosen by condition
|
||||
*/
|
||||
// Stores command chosen by condition
|
||||
Command* m_chosenCommand = nullptr;
|
||||
};
|
||||
|
||||
|
||||
@@ -16,8 +16,7 @@ namespace frc {
|
||||
/**
|
||||
* This command will execute once, then finish immediately afterward.
|
||||
*
|
||||
* <p>Subclassing {@link InstantCommand} is shorthand for returning true from
|
||||
* {@link Command isFinished}.
|
||||
* Subclassing InstantCommand is shorthand for returning true from IsFinished().
|
||||
*/
|
||||
class InstantCommand : public Command {
|
||||
public:
|
||||
|
||||
@@ -50,7 +50,7 @@ class PIDCommand : public Command, public PIDOutput, public PIDSource {
|
||||
virtual void UsePIDOutput(double output) = 0;
|
||||
|
||||
private:
|
||||
/** The internal {@link PIDController} */
|
||||
// The internal PIDController
|
||||
std::shared_ptr<PIDController> m_controller;
|
||||
|
||||
public:
|
||||
|
||||
@@ -18,14 +18,13 @@
|
||||
namespace frc {
|
||||
|
||||
/**
|
||||
* This class is designed to handle the case where there is a {@link Subsystem}
|
||||
* which uses a single {@link PIDController} almost constantly (for instance,
|
||||
* an elevator which attempts to stay at a constant height).
|
||||
*
|
||||
* <p>It provides some convenience methods to run an internal {@link
|
||||
* PIDController}. It also allows access to the internal {@link PIDController}
|
||||
* in order to give total control to the programmer.</p>
|
||||
* This class is designed to handle the case where there is a Subsystem which
|
||||
* uses a single PIDController almost constantly (for instance, an elevator
|
||||
* which attempts to stay at a constant height).
|
||||
*
|
||||
* It provides some convenience methods to run an internal PIDController. It
|
||||
* also allows access to the internal PIDController in order to give total
|
||||
* control to the programmer.
|
||||
*/
|
||||
class PIDSubsystem : public Subsystem, public PIDOutput, public PIDSource {
|
||||
public:
|
||||
@@ -65,7 +64,7 @@ class PIDSubsystem : public Subsystem, public PIDOutput, public PIDSource {
|
||||
virtual void UsePIDOutput(double output) = 0;
|
||||
|
||||
private:
|
||||
/** The internal {@link PIDController} */
|
||||
// The internal PIDController
|
||||
std::shared_ptr<PIDController> m_controller;
|
||||
|
||||
public:
|
||||
|
||||
@@ -14,8 +14,9 @@
|
||||
namespace frc {
|
||||
|
||||
/**
|
||||
* A {@link TimedCommand} will wait for a timeout before finishing.
|
||||
* {@link TimedCommand} is used to execute a command for a given amount of time.
|
||||
* A TimedCommand will wait for a timeout before finishing.
|
||||
*
|
||||
* TimedCommand is used to execute a command for a given amount of time.
|
||||
*/
|
||||
class TimedCommand : public Command {
|
||||
public:
|
||||
|
||||
Reference in New Issue
Block a user