WPILibC++ 2022.4.1
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 <wpi/SmallVector.h>
8#include <wpi/span.h>
9
13
14namespace frc2 {
15/**
16 * Schedules the given commands when this command is initialized. Useful for
17 * forking off from CommandGroups. Note that if run from a CommandGroup, the
18 * group will not know about the status of the scheduled commands, and will
19 * treat this command as finishing instantly.
20 *
21 * This class is provided by the NewCommands VendorDep
22 */
23class ScheduleCommand : public CommandHelper<CommandBase, ScheduleCommand> {
24 public:
25 /**
26 * Creates a new ScheduleCommand that schedules the given commands when
27 * initialized.
28 *
29 * @param toSchedule the commands to schedule
30 */
32
33 explicit ScheduleCommand(Command* toSchedule);
34
35 ScheduleCommand(ScheduleCommand&& other) = default;
36
37 ScheduleCommand(const ScheduleCommand& other) = default;
38
39 void Initialize() override;
40
41 bool IsFinished() override;
42
43 bool RunsWhenDisabled() const override;
44
45 private:
47};
48} // namespace frc2
CRTP implementation to allow polymorphic decorator functions in Command.
Definition: CommandHelper.h:25
A state machine representing a complete action to be performed by the robot.
Definition: Command.h:50
Schedules the given commands when this command is initialized.
Definition: ScheduleCommand.h:23
ScheduleCommand(Command *toSchedule)
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(wpi::span< Command *const > toSchedule)
Creates a new ScheduleCommand that schedules the given commands when initialized.
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:856
Definition: span.h:114
Definition: PIDController.h:16