WPILibC++ 2027.0.0-alpha-4
Loading...
Searching...
No Matches
WaitUntilCommand.hpp
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 <functional>
8
11#include "wpi/units/time.hpp"
12
13namespace wpi::cmd {
14/**
15 * A command that does nothing but ends after a specified match time or
16 * condition. Useful for CommandGroups.
17 *
18 * This class is provided by the NewCommands VendorDep
19 */
20class WaitUntilCommand : public CommandHelper<Command, WaitUntilCommand> {
21 public:
22 /**
23 * Creates a new WaitUntilCommand that ends after a given condition becomes
24 * true.
25 *
26 * @param condition the condition to determine when to end
27 */
28 explicit WaitUntilCommand(std::function<bool()> condition);
29
30 /**
31 * Creates a new WaitUntilCommand that ends after a given match time.
32 *
33 * <p>NOTE: The match timer used for this command is UNOFFICIAL. Using this
34 * command does NOT guarantee that the time at which the action is performed
35 * will be judged to be legal by the referees. When in doubt, add a safety
36 * factor or time the action manually.
37 *
38 * The match time counts down when connected to FMS or the DS is in practice
39 * mode for the current mode. When the DS is not connected to FMS or in
40 * practice mode, the command will not wait.
41 *
42 * @param time the match time after which to end, in seconds
43 * @see wpi::DriverStation::GetMatchTime()
44 */
45 explicit WaitUntilCommand(wpi::units::second_t time);
46
48
49 WaitUntilCommand(const WaitUntilCommand& other) = default;
50
51 bool IsFinished() override;
52
53 bool RunsWhenDisabled() const override;
54
55 private:
56 std::function<bool()> m_condition;
57};
58} // namespace wpi::cmd
WaitUntilCommand(std::function< bool()> condition)
Creates a new WaitUntilCommand that ends after a given condition becomes true.
WaitUntilCommand(const WaitUntilCommand &other)=default
WaitUntilCommand(WaitUntilCommand &&other)=default
bool IsFinished() override
bool RunsWhenDisabled() const override
WaitUntilCommand(wpi::units::second_t time)
Creates a new WaitUntilCommand that ends after a given match time.
Definition CommandNiDsStadiaController.hpp:15