WPILibC++ 2023.4.3
ScheduleCommand.h
Go to the documentation of this file.
1// Copyright (c) FIRST and other WPILib contributors.
2// Open Source Software; you can modify and/or share it under the terms of
3// the WPILib BSD license file in the root directory of this project.
4
5#pragma once
6
7#include <span>
8
9#include <wpi/SmallVector.h>
10
14
15namespace frc2 {
16/**
17 * Schedules the given commands when this command is initialized. Useful for
18 * forking off from CommandGroups. Note that if run from a composition, the
19 * composition will not know about the status of the scheduled commands, and
20 * will treat this command as finishing instantly.
21 *
22 * This class is provided by the NewCommands VendorDep
23 */
24class ScheduleCommand : public CommandHelper<CommandBase, ScheduleCommand> {
25 public:
26 /**
27 * Creates a new ScheduleCommand that schedules the given commands when
28 * initialized.
29 *
30 * @param toSchedule the commands to schedule
31 */
32 explicit ScheduleCommand(std::span<Command* const> toSchedule);
33
34 explicit ScheduleCommand(Command* toSchedule);
35
36 ScheduleCommand(ScheduleCommand&& other) = default;
37
38 ScheduleCommand(const ScheduleCommand& other) = default;
39
40 void Initialize() override;
41
42 bool IsFinished() override;
43
44 bool RunsWhenDisabled() const override;
45
46 private:
48};
49} // namespace frc2
CRTP implementation to allow polymorphic decorator functions in Command.
Definition: CommandHelper.h:26
A state machine representing a complete action to be performed by the robot.
Definition: Command.h:47
Schedules the given commands when this command is initialized.
Definition: ScheduleCommand.h:24
ScheduleCommand(Command *toSchedule)
ScheduleCommand(std::span< Command *const > toSchedule)
Creates a new ScheduleCommand that schedules the given commands when initialized.
bool IsFinished() override
Whether the command has finished.
ScheduleCommand(ScheduleCommand &&other)=default
bool RunsWhenDisabled() const override
Whether the given command should run when the robot is disabled.
void Initialize() override
The initial subroutine of a command.
ScheduleCommand(const ScheduleCommand &other)=default
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1186
Definition: InstantCommand.h:14