WPILibC++ 2023.4.3
WaitCommand.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 <frc/Timer.h>
8#include <units/time.h>
9
12
13namespace frc2 {
14/**
15 * A command that does nothing but takes a specified amount of time to finish.
16 *
17 * This class is provided by the NewCommands VendorDep
18 */
19class WaitCommand : public CommandHelper<CommandBase, WaitCommand> {
20 public:
21 /**
22 * Creates a new WaitCommand. This command will do nothing, and end after the
23 * specified duration.
24 *
25 * @param duration the time to wait
26 */
27 explicit WaitCommand(units::second_t duration);
28
29 WaitCommand(WaitCommand&& other) = default;
30
31 WaitCommand(const WaitCommand& other) = default;
32
33 void Initialize() override;
34
35 void End(bool interrupted) override;
36
37 bool IsFinished() override;
38
39 bool RunsWhenDisabled() const override;
40
41 void InitSendable(wpi::SendableBuilder& builder) override;
42
43 protected:
45
46 private:
47 units::second_t m_duration;
48};
49} // namespace frc2
CRTP implementation to allow polymorphic decorator functions in Command.
Definition: CommandHelper.h:26
A command that does nothing but takes a specified amount of time to finish.
Definition: WaitCommand.h:19
WaitCommand(WaitCommand &&other)=default
WaitCommand(units::second_t duration)
Creates a new WaitCommand.
bool IsFinished() override
Whether the command has finished.
WaitCommand(const WaitCommand &other)=default
frc::Timer m_timer
Definition: WaitCommand.h:44
void InitSendable(wpi::SendableBuilder &builder) override
Initializes this Sendable object.
void End(bool interrupted) override
The action to take when the command ends.
bool RunsWhenDisabled() const override
Whether the given command should run when the robot is disabled.
void Initialize() override
The initial subroutine of a command.
A timer class.
Definition: Timer.h:36
Definition: SendableBuilder.h:18
Definition: InstantCommand.h:14