WPILibC++  2021.3.1
WaitUntilCommand.h
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 
11 #include "frc2/command/CommandBase.h"
12 #include "frc2/command/CommandHelper.h"
13 
14 namespace frc2 {
19 class WaitUntilCommand : public CommandHelper<CommandBase, WaitUntilCommand> {
20  public:
27  explicit WaitUntilCommand(std::function<bool()> condition);
28 
39  explicit WaitUntilCommand(units::second_t time);
40 
41  WaitUntilCommand(WaitUntilCommand&& other) = default;
42 
43  WaitUntilCommand(const WaitUntilCommand& other) = default;
44 
45  bool IsFinished() override;
46 
47  bool RunsWhenDisabled() const override;
48 
49  private:
50  std::function<bool()> m_condition;
51 };
52 } // namespace frc2
frc2::WaitUntilCommand::WaitUntilCommand
WaitUntilCommand(units::second_t time)
Creates a new WaitUntilCommand that ends after a given match time.
frc2::WaitUntilCommand::IsFinished
bool IsFinished() override
Whether the command has finished.
frc2::WaitUntilCommand::RunsWhenDisabled
bool RunsWhenDisabled() const override
Whether the given command should run when the robot is disabled.
frc2::CommandHelper
CRTP implementation to allow polymorphic decorator functions in Command.
Definition: CommandHelper.h:23
frc2::WaitUntilCommand
A command that does nothing but ends after a specified match time or condition.
Definition: WaitUntilCommand.h:19
frc2::WaitUntilCommand::WaitUntilCommand
WaitUntilCommand(std::function< bool()> condition)
Creates a new WaitUntilCommand that ends after a given condition becomes true.