9#include <initializer_list>
18#include "wpi/units/time.hpp"
54 std::function<void(
const Command&,
const std::optional<Command*>&)>;
150 void Schedule(std::initializer_list<Command*> commands);
213 template <std::derived_from<Command> T>
215 if (!defaultCommand.HasRequirement(subsystem)) {
217 "Default commands must require their subsystem!");
219 SetDefaultCommandImpl(subsystem, std::make_unique<std::decay_t<T>>(
220 std::forward<T>(defaultCommand)));
288 void Cancel(std::span<Command* const> commands);
300 void Cancel(std::initializer_list<Command*> commands);
325 bool IsScheduled(std::initializer_list<const Command*> commands)
const;
458 std::span<
const std::unique_ptr<Command>> commands);
469 std::initializer_list<const Command*> commands);
477 void SetDefaultCommandImpl(
Subsystem* subsystem,
478 std::unique_ptr<Command> command);
480 void Cancel(
Command* command, std::optional<Command*> interruptor);
483 std::unique_ptr<Impl> m_impl;
489 template <
typename T>
#define WPILIB_MakeError(status, format,...)
Makes a runtime error exception object.
Definition Errors.hpp:164
A declarative way to bind a set of actions to a loop and execute them when the loop is polled.
Definition EventLoop.hpp:15
A class that's a wrapper around a watchdog timer.
Definition Watchdog.hpp:25
A state machine representing a complete action to be performed by the robot.
Definition Command.hpp:41
A wrapper around std::unique_ptr<Command> so commands have move-only semantics.
Definition CommandPtr.hpp:28
void UnregisterSubsystem(std::span< Subsystem *const > subsystems)
wpi::EventLoop * GetActiveButtonLoop() const
Get the active button poll.
void Enable()
Enables the command scheduler.
bool IsScheduled(const Command *command) const
Whether a given command is running.
bool IsScheduled(std::initializer_list< const Command * > commands) const
Whether the given commands are running.
void UnregisterAllSubsystems()
Un-registers all registered Subsystems with the scheduler.
CommandScheduler & operator=(const CommandScheduler &)=delete
friend class CommandTestBase
Definition CommandScheduler.hpp:487
void Cancel(std::span< Command *const > commands)
Cancels commands.
void OnCommandInitialize(Action action)
Adds an action to perform on the initialization of any command by the scheduler.
~CommandScheduler() override
void SetDefaultCommand(Subsystem *subsystem, T &&defaultCommand)
Sets the default command for a subsystem.
Definition CommandScheduler.hpp:214
void RequireUngrouped(std::initializer_list< const Command * > commands)
Requires that the specified commands have not already been added to a composition.
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 RequireUngroupedAndUnscheduled(std::initializer_list< const Command * > commands)
Requires that the specified commands have not already been added to a composition and are not current...
void RequireUngrouped(std::span< const std::unique_ptr< Command > > commands)
Requires that the specified commands have not already been added to a composition.
friend class CommandTestBaseWithParam
Definition CommandScheduler.hpp:490
std::function< void(const Command &, const std::optional< Command * > &)> InterruptAction
Definition CommandScheduler.hpp:53
void Run()
Runs a single iteration of the scheduler.
void UnregisterSubsystem(Subsystem *subsystem)
Un-registers subsystems with the scheduler.
void UnregisterSubsystem(std::initializer_list< Subsystem * > subsystems)
void SetActiveButtonLoop(wpi::EventLoop *loop)
Replace the button poll with another one.
void Schedule(const CommandPtr &command)
Schedules a command for execution.
void PrintWatchdogEpochs()
Prints list of epochs added so far and their times.
CommandScheduler(const CommandScheduler &)=delete
void OnCommandInterrupt(InterruptAction action)
Adds an action to perform on the interruption of any command by the scheduler.
void Schedule(Command *command)
Schedules a command for execution.
Command * Requiring(const Subsystem *subsystem) const
Returns the command currently requiring a given subsystem.
void Schedule(CommandPtr &&command)
Schedules a command for execution.
void SetDefaultCommand(Subsystem *subsystem, CommandPtr &&defaultCommand)
Sets the default command for a subsystem.
void RequireUngroupedAndUnscheduled(const Command *command)
Requires that the specified command has not already been added to a composition and is not currently ...
void RegisterSubsystem(std::span< Subsystem *const > subsystems)
void CancelAll()
Cancels all commands that are currently scheduled.
void InitSendable(wpi::util::SendableBuilder &builder) override
Initializes this Sendable object.
void Disable()
Disables the command scheduler.
void RequireUngrouped(const Command *command)
Requires that the specified command hasn't already been added to a composition.
bool IsScheduled(std::span< const Command *const > commands) const
Whether the given commands are running.
void Cancel(Command *command)
Cancels commands.
void OnCommandExecute(Action action)
Adds an action to perform on the execution of any command by the scheduler.
std::function< void(const Command &)> Action
Definition CommandScheduler.hpp:52
static CommandScheduler & GetInstance()
Returns the Scheduler instance.
void Schedule(std::span< Command *const > commands)
Schedules multiple commands for execution.
bool IsScheduled(const CommandPtr &command) const
Whether a given command is running.
void RemoveDefaultCommand(Subsystem *subsystem)
Removes the default command for a subsystem.
wpi::EventLoop * GetDefaultButtonLoop() const
Get the default button poll.
Command * GetDefaultCommand(const Subsystem *subsystem) const
Gets the default command associated with this subsystem.
void OnCommandFinish(Action action)
Adds an action to perform on the finishing of any command by the scheduler.
void SetPeriod(wpi::units::second_t period)
Changes the period of the loop overrun watchdog.
void Cancel(const CommandPtr &command)
Cancels commands.
void RegisterSubsystem(std::initializer_list< Subsystem * > subsystems)
void RegisterSubsystem(Subsystem *subsystem)
Registers subsystems with the scheduler.
void Cancel(std::initializer_list< Command * > commands)
Cancels commands.
void OnCommandInterrupt(Action action)
Adds an action to perform on the interruption of any command by the scheduler.
void Schedule(std::initializer_list< Command * > commands)
Schedules multiple commands for execution.
A robot subsystem.
Definition Subsystem.hpp:42
Helper class for building Sendable dashboard representations.
Definition SendableBuilder.hpp:21
A helper class for use with objects that add themselves to SendableRegistry.
Definition SendableHelper.hpp:21
Interface for Sendable objects.
Definition Sendable.hpp:16
Definition CommandNiDsStadiaController.hpp:15