8#include <initializer_list>
116 void Schedule(std::initializer_list<Command*> commands);
172 template <std::derived_from<Command> T>
174 if (!defaultCommand.HasRequirement(subsystem)) {
176 "Default commands must require their subsystem!");
178 SetDefaultCommandImpl(subsystem, std::make_unique<std::decay_t<T>>(
179 std::forward<T>(defaultCommand)));
247 void Cancel(std::span<Command* const> commands);
259 void Cancel(std::initializer_list<Command*> commands);
284 bool IsScheduled(std::initializer_list<const Command*> commands)
const;
389 void SetDefaultCommandImpl(
Subsystem* subsystem,
390 std::unique_ptr<Command> command);
393 std::unique_ptr<Impl> m_impl;
399 template <
typename T>
A state machine representing a complete action to be performed by the robot.
Definition: Command.h:44
A wrapper around std::unique_ptr<Command> so commands have move-only semantics.
Definition: CommandPtr.h:29
The scheduler responsible for running Commands.
Definition: CommandScheduler.h:36
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 not have been already 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.
bool IsScheduled(const CommandPtr &command) const
Whether a given command is running.
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:397
void RegisterSubsystem(std::initializer_list< Subsystem * > subsystems)
void RequireUngrouped(const Command *command)
Requires that the specified command hasn't been already 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(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 OnCommandInitialize(Action action)
Adds an action to perform on the initialization of any command by the scheduler.
void InitSendable(nt::NTSendableBuilder &builder) override
Initializes this Sendable object.
std::function< void(const Command &)> Action
Definition: CommandScheduler.h:49
void SetActiveButtonLoop(frc::EventLoop *loop)
Replace the button poll with another one.
friend class CommandTestBaseWithParam
Definition: CommandScheduler.h:400
void Disable()
Disables the command scheduler.
void Cancel(std::span< Command *const > commands)
Cancels commands.
CommandScheduler(const CommandScheduler &)=delete
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 Run()
Runs a single iteration of the scheduler.
Command * Requiring(const Subsystem *subsystem) const
Returns the command currently requiring a given subsystem.
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 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:173
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 not have been already added to a composition.
A robot subsystem.
Definition: Subsystem.h:39
The loop polling BooleanEvent objects and executing the actions bound to them.
Definition: EventLoop.h:15
A class that's a wrapper around a watchdog timer.
Definition: Watchdog.h:26
Definition: NTSendableBuilder.h:18
Interface for NetworkTable Sendable objects.
Definition: NTSendable.h:16
A helper class for use with objects that add themselves to SendableRegistry.
Definition: SendableHelper.h:19
Definition: ProfiledPIDCommand.h:18
#define FRC_MakeError(status, format,...)
Makes a runtime error exception object.
Definition: Errors.h:153