14 #include "ErrorBase.h" 15 #include "SmartDashboard/NamedSendable.h" 16 #include "networktables/NetworkTableEntry.h" 58 explicit Command(
const std::string& name);
59 explicit Command(
double timeout);
60 Command(
const std::string& name,
double timeout);
72 typedef std::set<Subsystem*> SubsystemSet;
110 virtual void _Initialize();
111 virtual void _Interrupted();
112 virtual void _Execute();
128 double m_startTime = -1;
135 bool m_initialized =
false;
138 SubsystemSet m_requirements;
141 bool m_running =
false;
144 bool m_interruptible =
true;
147 bool m_canceled =
false;
150 bool m_locked =
false;
153 bool m_runWhenDisabled =
false;
158 int m_commandID = m_commandCounter++;
159 static int m_commandCounter;
162 std::string
GetName()
const override;
163 void InitTable(std::shared_ptr<nt::NetworkTable> subtable)
override;
169 NT_EntryListener m_runningListener = 0;
bool IsCanceled() const
Returns whether or not this has been canceled.
Definition: Command.cpp:374
Command()
Creates a new command.
Definition: Command.cpp:30
double TimeSinceInitialized() const
Returns the time since this command was initialized (in seconds).
Definition: Command.cpp:102
int GetID() const
Get the ID (sequence number) for this command.
Definition: Command.cpp:80
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:430
void ClearRequirements()
Clears list of subsystem requirements.
Definition: Command.cpp:309
std::string GetName() const override
Definition: Command.cpp:432
Definition: Subsystem.h:21
void Start()
Starts up the command.
Definition: Command.cpp:159
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:398
bool Run()
The run method is used internally to actually run the commands.
Definition: Command.cpp:174
void SetTimeout(double timeout)
Sets the timeout of this command.
Definition: Command.cpp:88
CommandGroup * GetGroup() const
Returns the CommandGroup that this command is a part of.
Definition: Command.cpp:410
void SetRunWhenDisabled(bool run)
Sets whether or not this Command should run when the robot is disabled.
Definition: Command.cpp:421
bool IsRunning() const
Returns whether or not the command is running.
Definition: Command.cpp:337
bool IsInterruptible() const
Returns whether or not this command can be interrupted.
Definition: Command.cpp:381
A CommandGroup is a list of commands which are executed in sequence.
Definition: CommandGroup.h:39
bool AssertUnlocked(const std::string &message)
If changes are locked, then this will generate a CommandIllegalUse error.
Definition: Command.cpp:275
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:388
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:365
virtual void Initialize()
The initialize method is called the first time this Command is run after being started.
Definition: Command.cpp:195
NetworkTables Entry.
Definition: NetworkTableEntry.h:30
virtual void Execute()
The execute method is called repeatedly until this Command either finishes or is canceled.
Definition: Command.cpp:201
void SetParent(CommandGroup *parent)
Sets the parent of this command.
Definition: Command.cpp:290
void InitTable(std::shared_ptr< nt::NetworkTable > subtable) override
Initializes a table for this sendable object.
Definition: Command.cpp:436
The Command class is at the very core of the entire command framework.
Definition: Command.h:52
std::string GetSmartDashboardType() const override
Definition: Command.cpp:434
void Cancel()
This will cancel the current command.
Definition: Command.cpp:350
A ConditionalCommand is a Command that starts one of two commands.
Definition: ConditionalCommand.h:41
virtual void End()
Called when the command ended peacefully.
Definition: Command.cpp:208
void Requires(Subsystem *s)
This method specifies that the given Subsystem is used by this command.
Definition: Command.cpp:121
SubsystemSet GetRequirements() const
Returns the requirements (as an std::set of Subsystems pointers) of this command. ...
Definition: Command.cpp:259
virtual void Interrupted()
Called when the command ends because somebody called cancel() or another command shared the same requ...
Definition: Command.cpp:221
The interface for sendable objects that gives the sendable a default name in the Smart Dashboard...
Definition: NamedSendable.h:21
bool IsTimedOut() const
Returns whether or not the timeSinceInitialized() method returns a number which is greater than or eq...
Definition: Command.cpp:248
Definition: Scheduler.h:30