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
|
|
|
|
|
|
|
|
#include "frc2/command/WaitUntilCommand.h"
|
|
|
|
|
|
2021-05-28 22:06:59 -07:00
|
|
|
#include <frc/Timer.h>
|
2019-11-05 20:52:49 -08:00
|
|
|
|
2019-08-25 23:55:59 -04:00
|
|
|
using namespace frc2;
|
|
|
|
|
|
|
|
|
|
WaitUntilCommand::WaitUntilCommand(std::function<bool()> condition)
|
|
|
|
|
: m_condition{std::move(condition)} {}
|
|
|
|
|
|
2019-11-05 20:52:49 -08:00
|
|
|
WaitUntilCommand::WaitUntilCommand(units::second_t time)
|
2021-05-28 22:06:59 -07:00
|
|
|
: m_condition{[=] { return frc::Timer::GetMatchTime() - time > 0_s; }} {}
|
2019-08-25 23:55:59 -04:00
|
|
|
|
2020-12-28 12:58:06 -08:00
|
|
|
bool WaitUntilCommand::IsFinished() {
|
|
|
|
|
return m_condition();
|
|
|
|
|
}
|
2019-08-25 23:55:59 -04:00
|
|
|
|
2020-12-28 12:58:06 -08:00
|
|
|
bool WaitUntilCommand::RunsWhenDisabled() const {
|
|
|
|
|
return true;
|
|
|
|
|
}
|