WPILibC++ 2024.3.2
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, Requirements 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/4]

frc2::InstantCommand::InstantCommand ( std::function< void()>  toRun,
Requirements  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() [2/4]

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

◆ InstantCommand() [3/4]

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

◆ InstantCommand() [4/4]

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: