WPILibC++ 2027.0.0-alpha-5
Loading...
Searching...
No Matches
wpi::cmd Namespace Reference

Namespaces

namespace  impl
namespace  sysid

Classes

class  CommandNiDsStadiaController
 A version of wpi::NiDsStadiaController with Trigger factories for command-based. More...
class  Subsystem
 A robot subsystem. More...
class  RepeatCommand
 A command that runs another command repeatedly, restarting it when it ends, until this command is interrupted. More...
class  PrintCommand
 A command that prints a string when initialized. More...
class  InstantCommand
 A Command that runs instantly; it will initialize, execute once, and end on the same iteration of the scheduler. More...
class  WaitCommand
 A command that does nothing but takes a specified amount of time to finish. More...
class  FunctionalCommand
 A command that allows the user to pass in functions for each of the basic command methods through the constructor. More...
class  CommandNiDsXboxController
 A version of wpi::NiDsXboxController with Trigger factories for command-based. More...
class  CommandJoystick
 A version of wpi::Joystick with Trigger factories for command-based. More...
class  CommandHelper
 CRTP implementation to allow polymorphic decorator functions in Command. More...
class  StartEndCommand
 A command that runs a given runnable when it is initialized, and another runnable when it ends. More...
class  ProxyCommand
 Schedules a given command when this command is initialized and ends when it ends, but does not directly run it. More...
class  ParallelDeadlineGroup
 A command composition that runs a set of commands in parallel, ending only when a specific command (the "deadline") ends, interrupting all other commands that are still running at that point. More...
class  CommandNiDsPS5Controller
 A version of wpi::NiDsPS5Controller with Trigger factories for command-based. More...
class  SubsystemBase
 A base for subsystems that handles registration in the constructor, and provides a more intuitive method for setting the default command. More...
class  SelectCommand
 A command composition that runs one of a selection of commands using a selector and a key to command mapping. More...
class  CommandPtr
 A wrapper around std::unique_ptr<Command> so commands have move-only semantics. More...
class  ParallelCommandGroup
 A command composition that runs a set of commands in parallel, ending when the last command ends. More...
class  POVButton
 A class used to bind command scheduling to joystick POV presses. More...
class  ConditionalCommand
 A command composition that runs one of two commands, depending on the value of the given condition when this command is initialized. More...
class  GamepadButton
 A class used to bind command scheduling to gamepad button presses. More...
class  Trigger
 This class provides an easy way to link commands to conditions. More...
class  Command
 A state machine representing a complete action to be performed by the robot. More...
class  ParallelRaceGroup
 A composition that runs a set of commands in parallel, ending when any one of the commands ends and interrupting all the others. More...
class  JoystickButton
 A class used to bind command scheduling to joystick button presses. More...
class  CommandScheduler
 The scheduler responsible for running Commands. More...
class  CommandGamepad
 A version of wpi::Gamepad with Trigger factories for command-based. More...
class  NetworkButton
 A Button that uses a NetworkTable boolean field. More...
class  Requirements
 Represents requirements for a command, which is a set of (pointers to) subsystems. More...
class  WaitUntilCommand
 A command that does nothing but ends after a specified match time or condition. More...
class  CommandNiDsPS4Controller
 A version of wpi::NiDsPS4Controller with Trigger factories for command-based. More...
class  RunCommand
 A command that runs a Runnable continuously. More...
class  DeferredCommand
 Defers Command construction to runtime. More...
class  RobotModeTriggers
 A class containing static Trigger factories for running callbacks when robot mode changes. More...
class  ScheduleCommand
 Schedules the given commands when this command is initialized. More...
class  WrapperCommand
 A class used internally to wrap commands while overriding a specific method; all other methods will call through to the wrapped command. More...
class  NotifierCommand
 A command that starts a notifier to run the given runnable periodically in a separate thread. More...
class  SequentialCommandGroup
 A command composition that runs a list of commands in sequence. More...
class  CommandGenericHID
 A version of wpi::GenericHID with Trigger factories for command-based. More...

Functions

CommandPtr None ()
 Constructs a command that does nothing, finishing immediately.
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 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 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 action.
CommandPtr StartRun (std::function< void()> start, std::function< void()> run, Requirements requirements={})
 Constructs a command that runs an action once, and then runs an action every iteration until interrupted.
CommandPtr Print (std::string_view msg)
 Constructs a command that prints a message and finishes.
CommandPtr Wait (wpi::units::second_t duration)
 Constructs a command that does nothing, finishing after a specified duration.
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.
template<typename Key, std::convertible_to< CommandPtr >... CommandPtrs>
CommandPtr Select (std::function< Key()> selector, std::pair< Key, CommandPtrs > &&... commands)
 Runs one of several commands, based on the selector function.
CommandPtr Defer (wpi::util::unique_function< CommandPtr()> supplier, Requirements requirements)
 Runs the command supplied by the supplier.
CommandPtr DeferredProxy (wpi::util::unique_function< Command *()> supplier)
 Constructs a command that schedules the command returned from the supplier when initialized, and ends when it is no longer scheduled.
CommandPtr DeferredProxy (wpi::util::unique_function< CommandPtr()> supplier)
 Constructs a command that schedules the command returned from the supplier when initialized, and ends when it is no longer scheduled.
CommandPtr Sequence (std::vector< CommandPtr > &&commands)
 Runs a group of commands in series, one after the other.
template<std::convertible_to< CommandPtr >... CommandPtrs>
CommandPtr Sequence (CommandPtrs &&... commands)
 Runs a group of commands in series, one after the other.
CommandPtr RepeatingSequence (std::vector< CommandPtr > &&commands)
 Runs a group of commands in series, one after the other.
template<std::convertible_to< CommandPtr >... CommandPtrs>
CommandPtr RepeatingSequence (CommandPtrs &&... commands)
 Runs a group of commands in series, one after the other.
CommandPtr Parallel (std::vector< CommandPtr > &&commands)
 Runs a group of commands at the same time.
template<std::convertible_to< CommandPtr >... CommandPtrs>
CommandPtr Parallel (CommandPtrs &&... commands)
 Runs a group of commands at the same time.
CommandPtr Race (std::vector< CommandPtr > &&commands)
 Runs a group of commands at the same time.
template<std::convertible_to< CommandPtr >... CommandPtrs>
CommandPtr Race (CommandPtrs &&... commands)
 Runs a group of commands at the same time.
CommandPtr Deadline (CommandPtr &&deadline, std::vector< CommandPtr > &&others)
 Runs a group of commands at the same time.
template<std::convertible_to< CommandPtr >... CommandPtrs>
CommandPtr Deadline (CommandPtr &&deadline, CommandPtrs &&... commands)
 Runs a group of commands at the same time.
bool RequirementsDisjoint (Command *first, Command *second)
 Checks if two commands have disjoint requirement sets.

Variables

const size_t invalid_index = std::numeric_limits<size_t>::max()

Function Documentation

◆ Deadline() [1/2]

template<std::convertible_to< CommandPtr >... CommandPtrs>
CommandPtr wpi::cmd::Deadline ( CommandPtr && deadline,
CommandPtrs &&... commands )

Runs a group of commands at the same time.

Ends once a specific command finishes, and cancels the others.

◆ Deadline() [2/2]

CommandPtr wpi::cmd::Deadline ( CommandPtr && deadline,
std::vector< CommandPtr > && others )

Runs a group of commands at the same time.

Ends once a specific command finishes, and cancels the others.

◆ Defer()

CommandPtr wpi::cmd::Defer ( wpi::util::unique_function< CommandPtr()> supplier,
Requirements requirements )

Runs the command supplied by the supplier.

Parameters
supplierthe command supplier
requirementsthe set of requirements for this command

◆ DeferredProxy() [1/2]

CommandPtr wpi::cmd::DeferredProxy ( wpi::util::unique_function< Command *()> supplier)

Constructs a command that schedules the command returned from the supplier when initialized, and ends when it is no longer scheduled.

The supplier is called when the command is initialized.

Parameters
supplierthe command supplier

◆ DeferredProxy() [2/2]

CommandPtr wpi::cmd::DeferredProxy ( wpi::util::unique_function< CommandPtr()> supplier)

Constructs a command that schedules the command returned from the supplier when initialized, and ends when it is no longer scheduled.

The supplier is called when the command is initialized.

Parameters
supplierthe command supplier

◆ Either()

CommandPtr wpi::cmd::Either ( CommandPtr && onTrue,
CommandPtr && onFalse,
std::function< bool()> selector )

Runs one of two commands, based on the boolean selector function.

Parameters
onTruethe command to run if the selector function returns true
onFalsethe command to run if the selector function returns false
selectorthe selector function

◆ Idle()

CommandPtr wpi::cmd::Idle ( Requirements requirements = {})

Constructs a command that does nothing until interrupted.

Parameters
requirementsSubsystems to require
Returns
the command

◆ None()

CommandPtr wpi::cmd::None ( )

Constructs a command that does nothing, finishing immediately.

◆ Parallel() [1/2]

template<std::convertible_to< CommandPtr >... CommandPtrs>
CommandPtr wpi::cmd::Parallel ( CommandPtrs &&... commands)

Runs a group of commands at the same time.

Ends once all commands in the group finish.

◆ Parallel() [2/2]

CommandPtr wpi::cmd::Parallel ( std::vector< CommandPtr > && commands)

Runs a group of commands at the same time.

Ends once all commands in the group finish.

◆ Print()

CommandPtr wpi::cmd::Print ( std::string_view msg)

Constructs a command that prints a message and finishes.

Parameters
msgthe message to print

◆ Race() [1/2]

template<std::convertible_to< CommandPtr >... CommandPtrs>
CommandPtr wpi::cmd::Race ( CommandPtrs &&... commands)

Runs a group of commands at the same time.

Ends once any command in the group finishes, and cancels the others.

◆ Race() [2/2]

CommandPtr wpi::cmd::Race ( std::vector< CommandPtr > && commands)

Runs a group of commands at the same time.

Ends once any command in the group finishes, and cancels the others.

◆ RepeatingSequence() [1/2]

template<std::convertible_to< CommandPtr >... CommandPtrs>
CommandPtr wpi::cmd::RepeatingSequence ( CommandPtrs &&... commands)

Runs a group of commands in series, one after the other.

Once the last command ends, the group is restarted.

◆ RepeatingSequence() [2/2]

CommandPtr wpi::cmd::RepeatingSequence ( std::vector< CommandPtr > && commands)

Runs a group of commands in series, one after the other.

Once the last command ends, the group is restarted.

◆ RequirementsDisjoint()

bool wpi::cmd::RequirementsDisjoint ( Command * first,
Command * second )

Checks if two commands have disjoint requirement sets.

Parameters
firstThe first command to check.
secondThe second command to check.
Returns
False if first and second share a requirement.

◆ Run()

CommandPtr wpi::cmd::Run ( std::function< void()> action,
Requirements requirements = {} )

Constructs a command that runs an action every iteration until interrupted.

Parameters
actionthe action to run
requirementssubsystems the action requires

◆ RunEnd()

CommandPtr wpi::cmd::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 action.

Parameters
runthe action to run every iteration
endthe action to run on interrupt
requirementssubsystems the action requires

◆ RunOnce()

CommandPtr wpi::cmd::RunOnce ( std::function< void()> action,
Requirements requirements = {} )

Constructs a command that runs an action once and finishes.

Parameters
actionthe action to run
requirementssubsystems the action requires

◆ Select()

template<typename Key, std::convertible_to< CommandPtr >... CommandPtrs>
CommandPtr wpi::cmd::Select ( std::function< Key()> selector,
std::pair< Key, CommandPtrs > &&... commands )

Runs one of several commands, based on the selector function.

Parameters
selectorthe selector function
commandsmap of commands to select from

◆ Sequence() [1/2]

template<std::convertible_to< CommandPtr >... CommandPtrs>
CommandPtr wpi::cmd::Sequence ( CommandPtrs &&... commands)

Runs a group of commands in series, one after the other.

◆ Sequence() [2/2]

CommandPtr wpi::cmd::Sequence ( std::vector< CommandPtr > && commands)

Runs a group of commands in series, one after the other.

◆ StartEnd()

CommandPtr wpi::cmd::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.

Parameters
startthe action to run on start
endthe action to run on interrupt
requirementssubsystems the action requires

◆ StartRun()

CommandPtr wpi::cmd::StartRun ( std::function< void()> start,
std::function< void()> run,
Requirements requirements = {} )

Constructs a command that runs an action once, and then runs an action every iteration until interrupted.

Parameters
startthe action to run on start
runthe action to run every iteration
requirementssubsystems the action requires

◆ Wait()

CommandPtr wpi::cmd::Wait ( wpi::units::second_t duration)

Constructs a command that does nothing, finishing after a specified duration.

Parameters
durationafter how long the command finishes

◆ WaitUntil()

CommandPtr wpi::cmd::WaitUntil ( std::function< bool()> condition)

Constructs a command that does nothing, finishing once a condition becomes true.

Parameters
conditionthe condition

Variable Documentation

◆ invalid_index

const size_t wpi::cmd::invalid_index = std::numeric_limits<size_t>::max()