WPILibC++  2020.3.2-60-g3011ebe
WaitUntilCommand.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2019 FIRST. All Rights Reserved. */
3 /* Open Source Software - may be modified and shared by FRC teams. The code */
4 /* must be accompanied by the FIRST BSD license file in the root directory of */
5 /* the project. */
6 /*----------------------------------------------------------------------------*/
7 
8 #pragma once
9 
10 #include <functional>
11 
12 #include <units/units.h>
13 
14 #include "frc2/command/CommandBase.h"
15 #include "frc2/command/CommandHelper.h"
16 
17 namespace frc2 {
22 class WaitUntilCommand : public CommandHelper<CommandBase, WaitUntilCommand> {
23  public:
30  explicit WaitUntilCommand(std::function<bool()> condition);
31 
42  explicit WaitUntilCommand(units::second_t time);
43 
44  WaitUntilCommand(WaitUntilCommand&& other) = default;
45 
46  WaitUntilCommand(const WaitUntilCommand& other) = default;
47 
48  bool IsFinished() override;
49 
50  bool RunsWhenDisabled() const override;
51 
52  private:
53  std::function<bool()> m_condition;
54 };
55 } // namespace frc2
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:26
frc2::WaitUntilCommand
A command that does nothing but ends after a specified match time or condition.
Definition: WaitUntilCommand.h:22
frc2::WaitUntilCommand::WaitUntilCommand
WaitUntilCommand(std::function< bool()> condition)
Creates a new WaitUntilCommand that ends after a given condition becomes true.