8#include <initializer_list>
27class PerpetualCommand;
75 virtual void End(
bool interrupted);
150 WPI_DEPRECATED(
"Replace with Until()")
161 std::function<
void()> toRun,
162 std::initializer_list<Subsystem*> requirements) &&;
172 std::function<
void()> toRun,
173 std::span<Subsystem* const> requirements = {}) &&;
183 std::function<
void()> toRun,
184 std::initializer_list<Subsystem*> requirements) &&;
194 std::function<
void()> toRun,
195 std::span<Subsystem* const> requirements = {}) &&;
209 "PerpetualCommand violates the assumption that execute() doesn't get "
210 "called after isFinished() returns true -- an assumption that should be "
212 "This was unsafe/undefined behavior from the start, and RepeatCommand "
213 "provides an easy way to achieve similar end results with slightly "
214 "different (and safe) semantics.")
This file defines the SmallSet class.
A state machine representing a complete action to be performed by the robot.
Definition: Command.h:47
bool IsScheduled() const
Whether or not the command is currently scheduled.
void Cancel()
Cancels 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.
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 WithTimeout(units::second_t duration) &&
Decorates this command with a timeout.
CommandPtr WithInterrupt(std::function< bool()> condition) &&
Decorates this command with an interrupt condition.
CommandPtr BeforeStarting(std::function< void()> toRun, std::initializer_list< Subsystem * > requirements) &&
Decorates this command with a runnable to run before this command starts.
virtual std::string GetName() const
Gets the name of this Command.
virtual wpi::SmallSet< Subsystem *, 4 > GetRequirements() const =0
Specifies the set of subsystems used by this command.
CommandPtr Repeatedly() &&
Decorates this command to run repeatedly, restarting it when it ends, until this command is interrupt...
virtual bool RunsWhenDisabled() const
Whether the given command should run when the robot is disabled.
Definition: Command.h:360
CommandPtr WithInterruptBehavior(Command::InterruptionBehavior interruptBehavior) &&
Decorates this command to run or stop when disabled.
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.
bool m_isComposed
Definition: Command.h:400
Command(const Command &)=default
CommandPtr BeforeStarting(std::function< void()> toRun, std::span< Subsystem *const > requirements={}) &&
Decorates this command with a runnable to run before this command starts.
CommandPtr Until(std::function< bool()> condition) &&
Decorates this command with an interrupt condition.
CommandPtr AndThen(std::function< void()> toRun, std::span< Subsystem *const > requirements={}) &&
Decorates this command with a runnable to run after the command finishes.
virtual void Execute()
The main body of a command.
bool IsGrouped() const
Whether the command is currently grouped in a command group.
void SetGrouped(bool grouped)
Sets whether the command is currently grouped in a command group.
CommandPtr AndThen(std::function< void()> toRun, std::initializer_list< Subsystem * > requirements) &&
Decorates this command with a runnable to run after the command finishes.
Command & operator=(const Command &rhs)
virtual void SetName(std::string_view name)
Sets the name of this Command.
virtual InterruptionBehavior GetInterruptionBehavior() const
How the command behaves when another command with a shared requirement is scheduled.
Definition: Command.h:368
PerpetualCommand Perpetually() &&
virtual CommandPtr ToPtr() &&=0
Transfers ownership of this command to a unique pointer.
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.
InterruptionBehavior
An enum describing the command's behavior when another command with a shared requirement is scheduled...
Definition: Command.h:104
@ kCancelSelf
This command ends, End(true) is called, and the incoming command is scheduled normally.
Command & operator=(Command &&)=default
virtual std::unique_ptr< Command > TransferOwnership() &&=0
Transfers ownership of this command to a unique pointer.
virtual bool IsFinished()
Whether the command has finished.
Definition: Command.h:83
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
A command that runs another command in perpetuity, ignoring that command's end conditions.
Definition: PerpetualCommand.h:37
A robot subsystem.
Definition: Subsystem.h:39
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
Definition: SmallSet.h:135
basic_string_view< char > string_view
Definition: core.h:520
type
Definition: core.h:575
EIGEN_CONSTEXPR Index first(const T &x) EIGEN_NOEXCEPT
Definition: IndexedViewHelper.h:81
static EIGEN_DEPRECATED const end_t end
Definition: IndexedViewHelper.h:181
Definition: InstantCommand.h:14
std::string GetTypeName(const T &type)
Definition: Command.h:23
bool RequirementsDisjoint(Command *first, Command *second)
Checks if two commands have disjoint requirement sets.
Definition: StdDeque.h:50
std::string Demangle(std::string_view mangledSymbol)
Demangle a C++ symbol.