9#include <initializer_list>
53 std::function<void(
const Command&,
const std::optional<Command*>&)>;
149 void Schedule(std::initializer_list<Command*> commands);
212 template <std::derived_from<Command> T>
214 if (!defaultCommand.HasRequirement(subsystem)) {
216 "Default commands must require their subsystem!");
218 SetDefaultCommandImpl(subsystem, std::make_unique<std::decay_t<T>>(
219 std::forward<T>(defaultCommand)));
287 void Cancel(std::span<Command* const> commands);
299 void Cancel(std::initializer_list<Command*> commands);
324 bool IsScheduled(std::initializer_list<const Command*> commands)
const;
457 std::span<
const std::unique_ptr<Command>> commands);
468 std::initializer_list<const Command*> commands);
476 void SetDefaultCommandImpl(
Subsystem* subsystem,
477 std::unique_ptr<Command> command);
479 void Cancel(
Command* command, std::optional<Command*> interruptor);
482 std::unique_ptr<Impl> m_impl;
488 template <
typename T>
A state machine representing a complete action to be performed by the robot.
Definition Command.h:41
A wrapper around std::unique_ptr<Command> so commands have move-only semantics.
Definition CommandPtr.h:28
The scheduler responsible for running Commands.
Definition CommandScheduler.h:38
void Schedule(std::initializer_list< Command * > commands)
Schedules multiple commands for execution.
void RequireUngrouped(std::span< const std::unique_ptr< Command > > commands)
Requires that the specified commands have not already been added to a composition.
void CancelAll()
Cancels all commands that are currently scheduled.
void OnCommandFinish(Action action)
Adds an action to perform on the finishing of any command by the scheduler.
Command * GetDefaultCommand(const Subsystem *subsystem) const
Gets the default command associated with this subsystem.
bool IsScheduled(std::initializer_list< const Command * > commands) const
Whether the given commands are running.
void InitSendable(wpi::SendableBuilder &builder) override
Initializes this Sendable object.
bool IsScheduled(const CommandPtr &command) const
Whether a given command is running.
void RequireUngroupedAndUnscheduled(std::initializer_list< const Command * > commands)
Requires that the specified commands have not already been added to a composition and are not current...
CommandScheduler & operator=(const CommandScheduler &)=delete
void SetPeriod(units::second_t period)
Changes the period of the loop overrun watchdog.
friend class CommandTestBase
Definition CommandScheduler.h:486
void RegisterSubsystem(std::initializer_list< Subsystem * > subsystems)
void RequireUngrouped(const Command *command)
Requires that the specified command hasn't already been added to a composition.
void RegisterSubsystem(std::span< Subsystem *const > subsystems)
void Schedule(std::span< Command *const > commands)
Schedules multiple commands for execution.
void Schedule(CommandPtr &&command)
Schedules a command for execution.
void Schedule(Command *command)
Schedules a command for execution.
void UnregisterSubsystem(Subsystem *subsystem)
Un-registers subsystems with the scheduler.
bool IsScheduled(const Command *command) const
Whether a given command is running.
void RegisterSubsystem(Subsystem *subsystem)
Registers subsystems with the scheduler.
void Cancel(Command *command)
Cancels commands.
void OnCommandExecute(Action action)
Adds an action to perform on the execution of any command by the scheduler.
void RequireUngroupedAndUnscheduled(const Command *command)
Requires that the specified command has not already been added to a composition and is not currently ...
void OnCommandInitialize(Action action)
Adds an action to perform on the initialization of any command by the scheduler.
std::function< void(const Command &)> Action
Definition CommandScheduler.h:51
void SetActiveButtonLoop(frc::EventLoop *loop)
Replace the button poll with another one.
friend class CommandTestBaseWithParam
Definition CommandScheduler.h:489
void Disable()
Disables the command scheduler.
void Cancel(std::span< Command *const > commands)
Cancels commands.
CommandScheduler(const CommandScheduler &)=delete
std::function< void(const Command &, const std::optional< Command * > &)> InterruptAction
Definition CommandScheduler.h:52
void UnregisterSubsystem(std::span< Subsystem *const > subsystems)
void RemoveDefaultCommand(Subsystem *subsystem)
Removes the default command for a subsystem.
void SetDefaultCommand(Subsystem *subsystem, CommandPtr &&defaultCommand)
Sets the default command for a subsystem.
void Cancel(std::initializer_list< Command * > commands)
Cancels commands.
void Schedule(const CommandPtr &command)
Schedules a command for execution.
~CommandScheduler() override
void RequireUngroupedAndUnscheduled(std::span< const std::unique_ptr< Command > > commands)
Requires that the specified commands have not already been added to a composition and are not current...
void Run()
Runs a single iteration of the scheduler.
void PrintWatchdogEpochs()
Prints list of epochs added so far and their times.
Command * Requiring(const Subsystem *subsystem) const
Returns the command currently requiring a given subsystem.
void OnCommandInterrupt(InterruptAction action)
Adds an action to perform on the interruption of any command by the scheduler.
void OnCommandInterrupt(Action action)
Adds an action to perform on the interruption of any command by the scheduler.
static CommandScheduler & GetInstance()
Returns the Scheduler instance.
frc::EventLoop * GetDefaultButtonLoop() const
Get the default button poll.
void UnregisterSubsystem(std::initializer_list< Subsystem * > subsystems)
void UnregisterAllSubsystems()
Un-registers all registered Subsystems with the scheduler.
void Cancel(const CommandPtr &command)
Cancels commands.
void Enable()
Enables the command scheduler.
void SetDefaultCommand(Subsystem *subsystem, T &&defaultCommand)
Sets the default command for a subsystem.
Definition CommandScheduler.h:213
frc::EventLoop * GetActiveButtonLoop() const
Get the active button poll.
bool IsScheduled(std::span< const Command *const > commands) const
Whether the given commands are running.
void RequireUngrouped(std::initializer_list< const Command * > commands)
Requires that the specified commands have not already been added to a composition.
A robot subsystem.
Definition Subsystem.h:43
A declarative way to bind a set of actions to a loop and execute them when the loop is polled.
Definition EventLoop.h:15
A class that's a wrapper around a watchdog timer.
Definition Watchdog.h:26
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
Definition FunctionalCommand.h:13
#define FRC_MakeError(status, format,...)
Makes a runtime error exception object.
Definition Errors.h:164