14 #include <wpi/Twine.h> 16 #include "ErrorBase.h" 17 #include "SmartDashboard/SendableBase.h" 73 explicit Command(
double timeout);
189 typedef std::set<Subsystem*> SubsystemSet;
338 virtual void _Initialize();
339 virtual void _Interrupted();
340 virtual void _Execute();
387 double m_startTime = -1;
393 bool m_initialized =
false;
396 SubsystemSet m_requirements;
399 bool m_running =
false;
402 bool m_interruptible =
true;
405 bool m_canceled =
false;
408 bool m_locked =
false;
411 bool m_runWhenDisabled =
false;
417 bool m_completed =
false;
419 int m_commandID = m_commandCounter++;
420 static int m_commandCounter;
bool IsCanceled() const
Returns whether or not this has been canceled.
Definition: Command.cpp:105
Command()
Creates a new command.
Definition: Command.cpp:24
Definition: Utility.cpp:119
double TimeSinceInitialized() const
Returns the time since this command was initialized (in seconds).
Definition: Command.cpp:46
int GetID() const
Get the ID (sequence number) for this command.
Definition: Command.cpp:127
bool IsInitialized() const
Returns whether or not the command has been initialized.
Definition: Command.cpp:101
bool WillRunWhenDisabled() const
Returns whether or not this Command will run when the robot is disabled, or if it will cancel itself...
Definition: Command.cpp:125
void ClearRequirements()
Clears list of subsystem requirements.
Definition: Command.cpp:165
Definition: Subsystem.h:23
void Start()
Starts up the command.
Definition: Command.cpp:62
virtual bool IsFinished()=0
Returns whether this command is finished.
bool DoesRequire(Subsystem *subsystem) const
Checks if the command requires the given Subsystem.
Definition: Command.cpp:113
bool Run()
The run method is used internally to actually run the commands.
Definition: Command.cpp:73
void SetTimeout(double timeout)
Sets the timeout of this command.
Definition: Command.cpp:129
CommandGroup * GetGroup() const
Returns the CommandGroup that this command is a part of.
Definition: Command.cpp:121
void SetRunWhenDisabled(bool run)
Sets whether or not this Command should run when the robot is disabled.
Definition: Command.cpp:123
bool IsRunning() const
Returns whether or not the command is running.
Definition: Command.cpp:99
bool IsInterruptible() const
Returns whether or not this command can be interrupted.
Definition: Command.cpp:107
A CommandGroup is a list of commands which are executed in sequence.
Definition: CommandGroup.h:37
bool AssertUnlocked(const std::string &message)
If changes are locked, then this will generate a CommandIllegalUse error.
Definition: Command.cpp:140
Base class for most objects.
Definition: ErrorBase.h:74
void SetInterruptible(bool interruptible)
Sets whether or not this command can be interrupted.
Definition: Command.cpp:109
Definition: SendableBase.h:19
virtual void _Cancel()
This works like Cancel(), except that it doesn't throw an exception if it is a part of a command grou...
Definition: Command.cpp:183
virtual void Initialize()
The initialize method is called the first time this Command is run after being started.
Definition: Command.cpp:167
bool IsCompleted() const
Returns whether or not the command has completed running.
Definition: Command.cpp:103
Definition: SendableBuilder.h:23
virtual void Execute()
The execute method is called repeatedly until this Command either finishes or is canceled.
Definition: Command.cpp:169
void SetParent(CommandGroup *parent)
Sets the parent of this command.
Definition: Command.cpp:150
The Command class is at the very core of the entire command framework.
Definition: Command.h:48
void Cancel()
This will cancel the current command.
Definition: Command.cpp:90
A ConditionalCommand is a Command that starts one of two commands.
Definition: ConditionalCommand.h:35
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:79
bool IsParented() const
Returns whether the command has a parent.
Definition: Command.cpp:163
virtual void End()
Called when the command ended peacefully.
Definition: Command.cpp:171
void InitSendable(SendableBuilder &builder) override
Initializes this Sendable object.
Definition: Command.cpp:213
void Requires(Subsystem *s)
This method specifies that the given Subsystem is used by this command.
Definition: Command.cpp:53
SubsystemSet GetRequirements() const
Returns the requirements (as an std::set of Subsystem pointers) of this command.
Definition: Command.cpp:117
virtual void Interrupted()
Called when the command ends because somebody called Cancel() or another command shared the same requ...
Definition: Command.cpp:173
bool IsTimedOut() const
Returns whether or not the TimeSinceInitialized() method returns a number which is greater than or eq...
Definition: Command.cpp:136
Definition: Scheduler.h:27