WPILibC++ 2024.3.2
WaitUntilCommand.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
9#include <units/time.h>
10
13
14namespace frc2 {
15/**
16 * A command that does nothing but ends after a specified match time or
17 * condition. Useful for CommandGroups.
18 *
19 * This class is provided by the NewCommands VendorDep
20 */
21class WaitUntilCommand : public CommandHelper<Command, WaitUntilCommand> {
22 public:
23 /**
24 * Creates a new WaitUntilCommand that ends after a given condition becomes
25 * true.
26 *
27 * @param condition the condition to determine when to end
28 */
29 explicit WaitUntilCommand(std::function<bool()> condition);
30
31 /**
32 * Creates a new WaitUntilCommand that ends after a given match time.
33 *
34 * <p>NOTE: The match timer used for this command is UNOFFICIAL. Using this
35 * command does NOT guarantee that the time at which the action is performed
36 * will be judged to be legal by the referees. When in doubt, add a safety
37 * factor or time the action manually.
38 *
39 * @param time the match time after which to end, in seconds
40 */
41 explicit WaitUntilCommand(units::second_t time);
42
44
45 WaitUntilCommand(const WaitUntilCommand& other) = default;
46
47 bool IsFinished() override;
48
49 bool RunsWhenDisabled() const override;
50
51 private:
52 std::function<bool()> m_condition;
53};
54} // namespace frc2
CRTP implementation to allow polymorphic decorator functions in Command.
Definition: CommandHelper.h:27
A command that does nothing but ends after a specified match time or condition.
Definition: WaitUntilCommand.h:21
bool RunsWhenDisabled() const override
WaitUntilCommand(units::second_t time)
Creates a new WaitUntilCommand that ends after a given match time.
WaitUntilCommand(WaitUntilCommand &&other)=default
WaitUntilCommand(std::function< bool()> condition)
Creates a new WaitUntilCommand that ends after a given condition becomes true.
WaitUntilCommand(const WaitUntilCommand &other)=default
bool IsFinished() override
Definition: TrapezoidProfileSubsystem.h:12