WPILibC++ 2024.3.2
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/SmallSet.h>
10
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 composition, the
18 * composition will not know about the status of the scheduled commands, and
19 * will treat this command as finishing instantly.
20 *
21 * This class is provided by the NewCommands VendorDep
22 */
23class ScheduleCommand : public CommandHelper<Command, 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 */
31 explicit ScheduleCommand(std::span<Command* const> toSchedule);
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:
46 wpi::SmallSet<Command*, 4> m_toSchedule;
47};
48} // namespace frc2
This file defines the SmallSet class.
CRTP implementation to allow polymorphic decorator functions in Command.
Definition: CommandHelper.h:27
A state machine representing a complete action to be performed by the robot.
Definition: Command.h:41
Schedules the given commands when this command is initialized.
Definition: ScheduleCommand.h:23
ScheduleCommand(Command *toSchedule)
ScheduleCommand(std::span< Command *const > toSchedule)
Creates a new ScheduleCommand that schedules the given commands when initialized.
bool IsFinished() override
ScheduleCommand(ScheduleCommand &&other)=default
bool RunsWhenDisabled() const override
void Initialize() override
ScheduleCommand(const ScheduleCommand &other)=default
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
Definition: SmallSet.h:135
Definition: TrapezoidProfileSubsystem.h:12