WPILibC++ 2024.3.2
RunCommand.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 <functional>
8
12
13namespace frc2 {
14/**
15 * A command that runs a Runnable continuously. Has no end condition as-is;
16 * either subclass it or use Command.WithTimeout() or
17 * Command.Until() to give it one. If you only wish
18 * to execute a Runnable once, use InstantCommand.
19 *
20 * This class is provided by the NewCommands VendorDep
21 */
22class RunCommand : public CommandHelper<FunctionalCommand, RunCommand> {
23 public:
24 /**
25 * Creates a new RunCommand. The Runnable will be run continuously until the
26 * command ends. Does not run when disabled.
27 *
28 * @param toRun the Runnable to run
29 * @param requirements the subsystems to require
30 */
31 explicit RunCommand(std::function<void()> toRun,
32 Requirements requirements = {});
33
34 RunCommand(RunCommand&& other) = default;
35
36 RunCommand(const RunCommand& other) = default;
37};
38} // namespace frc2
CRTP implementation to allow polymorphic decorator functions in Command.
Definition: CommandHelper.h:27
Represents requirements for a command, which is a set of (pointers to) subsystems.
Definition: Requirements.h:20
A command that runs a Runnable continuously.
Definition: RunCommand.h:22
RunCommand(const RunCommand &other)=default
RunCommand(RunCommand &&other)=default
RunCommand(std::function< void()> toRun, Requirements requirements={})
Creates a new RunCommand.
Definition: TrapezoidProfileSubsystem.h:12