7#include <initializer_list>
83 WPI_DEPRECATED(
"Call Clear on the EventLoop instance directly!")
181 if (!defaultCommand.HasRequirement(subsystem)) {
183 "Default commands must require their subsystem!");
185 SetDefaultCommandImpl(subsystem,
186 std::make_unique<std::remove_reference_t<T>>(
187 std::forward<T>(defaultCommand)));
255 void Cancel(std::span<Command* const> commands);
267 void Cancel(std::initializer_list<Command*> commands);
292 bool IsScheduled(std::initializer_list<const Command*> commands)
const;
397 void SetDefaultCommandImpl(
Subsystem* subsystem,
398 std::unique_ptr<Command> command);
401 std::unique_ptr<Impl> m_impl;
407 template <
typename T>
A state machine representing a complete action to be performed by the robot.
Definition: Command.h:47
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:36
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:405
void RequireUngrouped(const Command *command)
Requires that the specified command hasn't been already added to a composition.
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:408
void Disable()
Disables the command scheduler.
void ClearButtons()
Removes all button bindings from the scheduler.
void Cancel(std::span< Command *const > commands)
Cancels commands.
CommandScheduler(const CommandScheduler &)=delete
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 SetDefaultCommand(Subsystem *subsystem, T &&defaultCommand)
Sets the default command for a subsystem.
Definition: CommandScheduler.h:180
void Cancel(const CommandPtr &command)
Cancels commands.
void Enable()
Enables the command scheduler.
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
typename std::enable_if< B, T >::type enable_if_t
Definition: core.h:298
typename std::remove_reference< T >::type remove_reference_t
Definition: core.h:303
Definition: InstantCommand.h:14
Definition: StdDeque.h:50
#define FRC_MakeError(status, format,...)
Makes a runtime error exception object.
Definition: Errors.h:152