WPILibC++ 2023.4.3-108-ge5452e3
frc2::InstantCommand Class Reference

A Command that runs instantly; it will initialize, execute once, and end on the same iteration of the scheduler. More...

#include <frc2/command/InstantCommand.h>

Inheritance diagram for frc2::InstantCommand:
frc2::CommandHelper< FunctionalCommand, InstantCommand >

Public Member Functions

 InstantCommand (std::function< void()> toRun, std::initializer_list< Subsystem * > requirements)
 Creates a new InstantCommand that runs the given Runnable with the given requirements. More...
 
 InstantCommand (std::function< void()> toRun, std::span< Subsystem *const > requirements={})
 Creates a new InstantCommand that runs the given Runnable with the given requirements. More...
 
 InstantCommand (InstantCommand &&other)=default
 
 InstantCommand (const InstantCommand &other)=default
 
 InstantCommand ()
 Creates a new InstantCommand with a Runnable that does nothing. More...
 
- Public Member Functions inherited from frc2::CommandHelper< FunctionalCommand, InstantCommand >
 CommandHelper ()=default
 
CommandPtr ToPtr () &&override
 

Additional Inherited Members

- Protected Member Functions inherited from frc2::CommandHelper< FunctionalCommand, InstantCommand >
std::unique_ptr< CommandTransferOwnership () &&override
 

Detailed Description

A Command that runs instantly; it will initialize, execute once, and end on the same iteration of the scheduler.

Users can either pass in a Runnable and a set of requirements, or else subclass this command if desired.

This class is provided by the NewCommands VendorDep

Constructor & Destructor Documentation

◆ InstantCommand() [1/5]

frc2::InstantCommand::InstantCommand ( std::function< void()>  toRun,
std::initializer_list< Subsystem * >  requirements 
)

Creates a new InstantCommand that runs the given Runnable with the given requirements.

Parameters
toRunthe Runnable to run
requirementsthe subsystems required by this command

◆ InstantCommand() [2/5]

frc2::InstantCommand::InstantCommand ( std::function< void()>  toRun,
std::span< Subsystem *const >  requirements = {} 
)
explicit

Creates a new InstantCommand that runs the given Runnable with the given requirements.

Parameters
toRunthe Runnable to run
requirementsthe subsystems required by this command

◆ InstantCommand() [3/5]

frc2::InstantCommand::InstantCommand ( InstantCommand &&  other)
default

◆ InstantCommand() [4/5]

frc2::InstantCommand::InstantCommand ( const InstantCommand other)
default

◆ InstantCommand() [5/5]

frc2::InstantCommand::InstantCommand ( )

Creates a new InstantCommand with a Runnable that does nothing.

Useful only as a no-arg constructor to call implicitly from subclass constructors.


The documentation for this class was generated from the following file: