125 std::function<
bool()> selector);
133template <
typename Key, std::convertible_to<CommandPtr>... CommandPtrs>
136 std::pair<Key, CommandPtrs>&&... commands) {
137 std::vector<std::pair<Key, std::unique_ptr<Command>>> vec;
139 ((void)vec.emplace_back(commands.first, std::move(commands.second).Unwrap()),
182template <std::convertible_to<CommandPtr>... Args>
184 std::vector<CommandPtr> data;
185 data.reserve(
sizeof...(Args));
186 (data.emplace_back(std::forward<Args>(args)), ...);
201template <std::convertible_to<CommandPtr>... CommandPtrs>
218template <std::convertible_to<CommandPtr>... CommandPtrs>
236template <std::convertible_to<CommandPtr>... CommandPtrs>
253template <std::convertible_to<CommandPtr>... CommandPtrs>
270template <std::convertible_to<CommandPtr>... CommandPtrs>
273 return Deadline(std::move(deadline),
CommandPtr ToPtr() &&override
Definition: CommandHelper.h:33
A state machine representing a complete action to be performed by the robot.
Definition: Command.h:41
A wrapper around std::unique_ptr<Command> so commands have move-only semantics.
Definition: CommandPtr.h:29
Represents requirements for a command, which is a set of (pointers to) subsystems.
Definition: Requirements.h:20
A command composition that runs one of a selection of commands using a selector and a key to command ...
Definition: SelectCommand.h:39
unique_function is a type-erasing functor similar to std::function.
Definition: FunctionExtras.h:57
basic_string_view< char > string_view
Definition: core.h:501
std::vector< CommandPtr > MakeVector(Args &&... args)
Create a vector of commands.
Definition: Commands.h:183
CommandPtr Deadline(CommandPtr &&deadline, std::vector< CommandPtr > &&others)
Runs a group of commands at the same time.
CommandPtr StartEnd(std::function< void()> start, std::function< void()> end, Requirements requirements={})
Constructs a command that runs an action once and another action when the command is interrupted.
CommandPtr WaitUntil(std::function< bool()> condition)
Constructs a command that does nothing, finishing once a condition becomes true.
CommandPtr Either(CommandPtr &&onTrue, CommandPtr &&onFalse, std::function< bool()> selector)
Runs one of two commands, based on the boolean selector function.
CommandPtr RunEnd(std::function< void()> run, std::function< void()> end, Requirements requirements={})
Constructs a command that runs an action every iteration until interrupted, and then runs a second ac...
CommandPtr None()
Constructs a command that does nothing, finishing immediately.
CommandPtr DeferredProxy(wpi::unique_function< Command *()> supplier)
Constructs a command that schedules the command returned from the supplier when initialized,...
CommandPtr Parallel(std::vector< CommandPtr > &&commands)
Runs a group of commands at the same time.
CommandPtr RepeatingSequence(std::vector< CommandPtr > &&commands)
Runs a group of commands in series, one after the other.
CommandPtr Sequence(std::vector< CommandPtr > &&commands)
Runs a group of commands in series, one after the other.
CommandPtr Idle(Requirements requirements={})
Constructs a command that does nothing until interrupted.
CommandPtr RunOnce(std::function< void()> action, Requirements requirements={})
Constructs a command that runs an action once and finishes.
CommandPtr Run(std::function< void()> action, Requirements requirements={})
Constructs a command that runs an action every iteration until interrupted.
CommandPtr Print(std::string_view msg)
Constructs a command that prints a message and finishes.
CommandPtr Wait(units::second_t duration)
Constructs a command that does nothing, finishing after a specified duration.
CommandPtr Defer(wpi::unique_function< CommandPtr()> supplier, Requirements requirements)
Runs the command supplied by the supplier.
CommandPtr Select(std::function< Key()> selector, std::pair< Key, CommandPtrs > &&... commands)
Runs one of several commands, based on the selector function.
Definition: Commands.h:135
CommandPtr Race(std::vector< CommandPtr > &&commands)
Runs a group of commands at the same time.
Definition: TrapezoidProfileSubsystem.h:12