2020-12-26 14:12:05 -08:00
|
|
|
// Copyright (c) FIRST and other WPILib contributors.
|
|
|
|
|
// Open Source Software; you can modify and/or share it under the terms of
|
|
|
|
|
// the WPILib BSD license file in the root directory of this project.
|
2019-08-25 23:55:59 -04:00
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2021-05-28 22:06:59 -07:00
|
|
|
#include <frc/Timer.h>
|
2020-06-29 22:25:09 -07:00
|
|
|
#include <units/time.h>
|
2019-08-25 23:55:59 -04:00
|
|
|
|
2019-11-05 20:52:49 -08:00
|
|
|
#include "frc2/command/CommandBase.h"
|
|
|
|
|
#include "frc2/command/CommandHelper.h"
|
2019-08-25 23:55:59 -04:00
|
|
|
|
|
|
|
|
namespace frc2 {
|
|
|
|
|
/**
|
|
|
|
|
* A command that does nothing but takes a specified amount of time to finish.
|
|
|
|
|
* Useful for CommandGroups. Can also be subclassed to make a command with an
|
|
|
|
|
* internal timer.
|
2022-01-08 11:11:34 -08:00
|
|
|
*
|
|
|
|
|
* This class is provided by the NewCommands VendorDep
|
2019-08-25 23:55:59 -04:00
|
|
|
*/
|
|
|
|
|
class WaitCommand : public CommandHelper<CommandBase, WaitCommand> {
|
|
|
|
|
public:
|
|
|
|
|
/**
|
|
|
|
|
* Creates a new WaitCommand. This command will do nothing, and end after the
|
|
|
|
|
* specified duration.
|
|
|
|
|
*
|
2019-09-02 23:39:51 -07:00
|
|
|
* @param duration the time to wait
|
2019-08-25 23:55:59 -04:00
|
|
|
*/
|
2019-09-02 23:39:51 -07:00
|
|
|
explicit WaitCommand(units::second_t duration);
|
2019-08-25 23:55:59 -04:00
|
|
|
|
|
|
|
|
WaitCommand(WaitCommand&& other) = default;
|
|
|
|
|
|
|
|
|
|
WaitCommand(const WaitCommand& other) = default;
|
|
|
|
|
|
|
|
|
|
void Initialize() override;
|
|
|
|
|
|
|
|
|
|
void End(bool interrupted) override;
|
|
|
|
|
|
|
|
|
|
bool IsFinished() override;
|
|
|
|
|
|
|
|
|
|
bool RunsWhenDisabled() const override;
|
|
|
|
|
|
|
|
|
|
protected:
|
2021-05-28 22:06:59 -07:00
|
|
|
frc::Timer m_timer;
|
2019-08-25 23:55:59 -04:00
|
|
|
|
|
|
|
|
private:
|
2019-09-02 23:39:51 -07:00
|
|
|
units::second_t m_duration;
|
2019-08-25 23:55:59 -04:00
|
|
|
};
|
|
|
|
|
} // namespace frc2
|