68 virtual void End(
bool interrupted);
503 std::optional<std::string> m_previousComposition;
This file defines the SmallSet class.
A state machine representing a complete action to be performed by the robot.
Definition Command.h:41
bool IsScheduled() const
Whether or not the command is currently scheduled.
void Cancel()
Cancels this command.
std::string GetSubsystem() const
Gets the subsystem name of this Command.
CommandPtr AsProxy() &&
Decorates this command to run "by proxy" by wrapping it in a ProxyCommand.
virtual void End(bool interrupted)
The action to take when the command ends.
void InitSendable(wpi::SendableBuilder &builder) override
Initializes this Sendable object.
void AddRequirements(Requirements requirements)
Adds the specified Subsystem requirements to the command.
Command(Command &&)=default
CommandPtr HandleInterrupt(std::function< void()> handler) &&
Decorates this command with a lambda to call on interrupt, following the command's inherent Command::...
CommandPtr FinallyDo(std::function< void()> end) &&
Decorates this command with a lambda to call on interrupt or end, following the command's inherent Co...
CommandPtr WithTimeout(units::second_t duration) &&
Decorates this command with a timeout.
CommandPtr WithDeadline(CommandPtr &&deadline) &&
Creates a new command that runs this command and the deadline in parallel, finishing (and interruptin...
CommandPtr AndThen(CommandPtr &&next) &&
Decorates this command with a set of commands to run after it in sequence.
CommandPtr BeforeStarting(CommandPtr &&before) &&
Decorates this command with another command to run before this command starts.
void AddRequirements(Subsystem *requirement)
Adds the specified Subsystem requirement to the command.
CommandPtr Repeatedly() &&
Decorates this command to run repeatedly, restarting it when it ends, until this command is interrupt...
std::optional< std::string > GetPreviousCompositionSite() const
Get the stacktrace of where this command was composed, or an empty optional.
void SetName(std::string_view name)
Sets the name of this Command.
virtual bool RunsWhenDisabled() const
Whether the given command should run when the robot is disabled.
Definition Command.h:476
CommandPtr BeforeStarting(std::function< void()> toRun, Requirements requirements={}) &&
Decorates this command with a runnable to run before this command starts.
CommandPtr WithInterruptBehavior(Command::InterruptionBehavior interruptBehavior) &&
Decorates this command to have a different interrupt behavior.
CommandPtr FinallyDo(std::function< void(bool)> end) &&
Decorates this command with a lambda to call on interrupt or end, following the command's inherent Co...
CommandPtr WithName(std::string_view name) &&
Decorates this Command with a name.
bool IsComposed() const
Whether the command is currently grouped in a command group.
Command(const Command &)=default
virtual wpi::SmallSet< Subsystem *, 4 > GetRequirements() const
Specifies the set of subsystems used by this command.
CommandPtr Until(std::function< bool()> condition) &&
Decorates this command with an interrupt condition.
virtual void Execute()
The main body of a command.
void AddRequirements(wpi::SmallSet< Subsystem *, 4 > requirements)
Adds the specified Subsystem requirements to the command.
CommandPtr OnlyWhile(std::function< bool()> condition) &&
Decorates this command with a run condition.
CommandPtr OnlyIf(std::function< bool()> condition) &&
Decorates this command to only run if this condition is met.
Command & operator=(const Command &rhs)
virtual InterruptionBehavior GetInterruptionBehavior() const
How the command behaves when another command with a shared requirement is scheduled.
Definition Command.h:484
CommandPtr AlongWith(CommandPtr &¶llel) &&
Decorates this command with a set of commands to run parallel to it, ending when the last command end...
std::string GetName() const
Gets the name of this Command.
virtual CommandPtr ToPtr() &&=0
Transfers ownership of this command to a unique pointer.
CommandPtr DeadlineFor(CommandPtr &¶llel) &&
Decorates this command with a set of commands to run parallel to it, ending when the calling command ...
CommandPtr IgnoringDisable(bool doesRunWhenDisabled) &&
Decorates this command to run or stop when disabled.
void SetComposed(bool isComposed)
Sets whether the command is currently composed in a command composition.
bool HasRequirement(Subsystem *requirement) const
Whether the command requires a given subsystem.
virtual void Initialize()
The initial subroutine of a command.
void Schedule()
Schedules this command.
void SetSubsystem(std::string_view subsystem)
Sets the subsystem name of this Command.
InterruptionBehavior
An enum describing the command's behavior when another command with a shared requirement is scheduled...
Definition Command.h:173
@ kCancelSelf
This command ends, End(true) is called, and the incoming command is scheduled normally.
@ kCancelIncoming
This command continues, and the incoming command is not scheduled.
CommandPtr RaceWith(CommandPtr &¶llel) &&
Decorates this command with a set of commands to run parallel to it, ending when the first command en...
Command & operator=(Command &&)=default
CommandPtr AndThen(std::function< void()> toRun, Requirements requirements={}) &&
Decorates this command with a runnable to run after the command finishes.
virtual bool IsFinished()
Whether the command has finished.
Definition Command.h:76
CommandPtr Unless(std::function< bool()> condition) &&
Decorates this command to only run if this condition is not met.
A wrapper around std::unique_ptr<Command> so commands have move-only semantics.
Definition CommandPtr.h:28
Represents requirements for a command, which is a set of (pointers to) subsystems.
Definition Requirements.h:20
A robot subsystem.
Definition Subsystem.h:43
Helper class for building Sendable dashboard representations.
Definition SendableBuilder.h:21
A helper class for use with objects that add themselves to SendableRegistry.
Definition SendableHelper.h:21
Interface for Sendable objects.
Definition Sendable.h:16
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
Definition SmallSet.h:135
Definition FunctionalCommand.h:13
bool RequirementsDisjoint(Command *first, Command *second)
Checks if two commands have disjoint requirement sets.