2019-08-25 23:55:59 -04:00
|
|
|
/*----------------------------------------------------------------------------*/
|
2020-06-29 22:25:09 -07:00
|
|
|
/* Copyright (c) 2019-2020 FIRST. All Rights Reserved. */
|
2019-08-25 23:55:59 -04:00
|
|
|
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
|
|
|
|
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
|
|
|
|
/* the project. */
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2020-06-29 22:25:09 -07:00
|
|
|
#include <units/time.h>
|
2019-08-25 23:55:59 -04:00
|
|
|
|
2019-11-20 22:44:18 -08:00
|
|
|
#include "frc2/Timer.h"
|
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.
|
|
|
|
|
*/
|
|
|
|
|
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:
|
2019-10-26 11:21:40 -04:00
|
|
|
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
|