WPILibC++ 2024.3.2
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<Command, 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:
44 /// The timer used for waiting.
46
47 private:
48 units::second_t m_duration;
49};
50} // namespace frc2
CRTP implementation to allow polymorphic decorator functions in Command.
Definition: CommandHelper.h:27
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
WaitCommand(const WaitCommand &other)=default
frc::Timer m_timer
The timer used for waiting.
Definition: WaitCommand.h:45
void InitSendable(wpi::SendableBuilder &builder) override
void End(bool interrupted) override
bool RunsWhenDisabled() const override
void Initialize() override
A timer class.
Definition: Timer.h:36
Helper class for building Sendable dashboard representations.
Definition: SendableBuilder.h:21
Definition: TrapezoidProfileSubsystem.h:12