13 #include <wpi/SmallPtrSet.h>
14 #include <wpi/Twine.h>
16 #include "frc/ErrorBase.h"
17 #include "frc/commands/Subsystem.h"
18 #include "frc/smartdashboard/Sendable.h"
19 #include "frc/smartdashboard/SendableHelper.h"
76 explicit Command(
double timeout);
376 virtual void _Initialize();
377 virtual void _Interrupted();
378 virtual void _Execute();
454 double m_startTime = -1;
460 bool m_initialized =
false;
466 bool m_running =
false;
469 bool m_interruptible =
true;
472 bool m_canceled =
false;
475 bool m_locked =
false;
478 bool m_runWhenDisabled =
false;
484 bool m_completed =
false;
486 int m_commandID = m_commandCounter++;
487 static int m_commandCounter;
virtual void End()
Called when the command ended peacefully.
bool Run()
The run method is used internally to actually run the commands.
const SubsystemSet & GetRequirements() const
Returns the requirements (as an std::set of Subsystem pointers) of this command.
void Cancel()
This will cancel the current command.
void SetSubsystem(const wpi::Twine &subsystem)
Sets the subsystem name of this Command.
virtual void Interrupted()
Called when the command ends because somebody called Cancel() or another command shared the same requ...
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
Definition: SmallPtrSet.h:395
virtual bool IsFinished()=0
Returns whether this command is finished.
A CommandGroup is a list of commands which are executed in sequence.
Definition: CommandGroup.h:36
void Requires(Subsystem *s)
This method specifies that the given Subsystem is used by this command.
Definition: Scheduler.h:22
A ConditionalCommand is a Command that starts one of two commands.
Definition: ConditionalCommand.h:35
void SetParent(CommandGroup *parent)
Sets the parent of this command.
Command()
Creates a new command.
bool IsRunning() const
Returns whether or not the command is running.
void InitSendable(SendableBuilder &builder) override
Initializes this Sendable object.
double TimeSinceInitialized() const
Returns the time since this command was initialized (in seconds).
The Command class is at the very core of the entire command framework.
Definition: Command.h:49
void ClearRequirements()
Clears list of subsystem requirements.
bool IsParented() const
Returns whether the command has a parent.
Definition: Subsystem.h:24
std::string GetName() const
Gets the name of this Command.
bool IsInitialized() const
Returns whether or not the command has been initialized.
int GetID() const
Get the ID (sequence number) for this command.
std::string GetSubsystem() const
Gets the subsystem name of this Command.
Base class for most objects.
Definition: ErrorBase.h:104
bool IsCanceled() const
Returns whether or not this has been canceled.
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
Definition: SmallPtrSet.h:324
void Start()
Starts up the command.
virtual void _Cancel()
This works like Cancel(), except that it doesn't throw an exception if it is a part of a command grou...
bool DoesRequire(Subsystem *subsystem) const
Checks if the command requires the given Subsystem.
void SetName(const wpi::Twine &name)
Sets the name of this Command.
Interface for Sendable objects.
Definition: Sendable.h:17
void SetTimeout(double timeout)
Sets the timeout of this command.
void SetInterruptible(bool interruptible)
Sets whether or not this command can be interrupted.
void SetRunWhenDisabled(bool run)
Sets whether or not this Command should run when the robot is disabled.
bool IsCompleted() const
Returns whether or not the command has completed running.
A class that enforces constraints on the differential drive kinematics.
Definition: SPIAccelerometerSim.h:16
bool IsTimedOut() const
Returns whether or not the TimeSinceInitialized() method returns a number which is greater than or eq...
virtual void Initialize()
The initialize method is called the first time this Command is run after being started.
virtual void Execute()
The execute method is called repeatedly until this Command either finishes or is canceled.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:85
A helper class for use with objects that add themselves to SendableRegistry.
Definition: SendableHelper.h:28
bool WillRunWhenDisabled() const
Returns whether or not this Command will run when the robot is disabled, or if it will cancel itself.
Definition: SendableBuilder.h:23
CommandGroup * GetGroup() const
Returns the CommandGroup that this command is a part of.
bool AssertUnlocked(const std::string &message)
If changes are locked, then this will generate a CommandIllegalUse error.
bool IsInterruptible() const
Returns whether or not this command can be interrupted.