WPILibC++  2020.3.2
WaitCommand.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 <units/units.h>
11 
12 #include "frc2/Timer.h"
13 #include "frc2/command/CommandBase.h"
14 #include "frc2/command/CommandHelper.h"
15 
16 namespace frc2 {
22 class WaitCommand : public CommandHelper<CommandBase, WaitCommand> {
23  public:
30  explicit WaitCommand(units::second_t duration);
31 
32  WaitCommand(WaitCommand&& other) = default;
33 
34  WaitCommand(const WaitCommand& other) = default;
35 
36  void Initialize() override;
37 
38  void End(bool interrupted) override;
39 
40  bool IsFinished() override;
41 
42  bool RunsWhenDisabled() const override;
43 
44  protected:
45  Timer m_timer;
46 
47  private:
48  units::second_t m_duration;
49 };
50 } // namespace frc2
frc2::WaitCommand::WaitCommand
WaitCommand(units::second_t duration)
Creates a new WaitCommand.
frc2::WaitCommand::End
void End(bool interrupted) override
The action to take when the command ends.
frc2::Timer
A wrapper for the frc::Timer class that returns unit-typed values.
Definition: Timer.h:40
frc2::WaitCommand::RunsWhenDisabled
bool RunsWhenDisabled() const override
Whether the given command should run when the robot is disabled.
frc2::WaitCommand::Initialize
void Initialize() override
The initial subroutine of a command.
frc2::CommandHelper
CRTP implementation to allow polymorphic decorator functions in Command.
Definition: CommandHelper.h:26
frc2::WaitCommand
A command that does nothing but takes a specified amount of time to finish.
Definition: WaitCommand.h:22
frc2::WaitCommand::IsFinished
bool IsFinished() override
Whether the command has finished.