WPILibC++ 2024.1.1-beta-4
frc2::FunctionalCommand Class Reference

A command that allows the user to pass in functions for each of the basic command methods through the constructor. More...

#include <frc2/command/FunctionalCommand.h>

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

Public Member Functions

 FunctionalCommand (std::function< void()> onInit, std::function< void()> onExecute, std::function< void(bool)> onEnd, std::function< bool()> isFinished, Requirements requirements={})
 Creates a new FunctionalCommand. More...
 
 FunctionalCommand (FunctionalCommand &&other)=default
 
 FunctionalCommand (const FunctionalCommand &other)=default
 
void Initialize () override
 
void Execute () override
 
void End (bool interrupted) override
 
bool IsFinished () override
 
- Public Member Functions inherited from frc2::CommandHelper< Command, FunctionalCommand >
 CommandHelper ()=default
 
CommandPtr ToPtr () &&override
 

Additional Inherited Members

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

Detailed Description

A command that allows the user to pass in functions for each of the basic command methods through the constructor.

Useful for inline definitions of complex commands - note, however, that if a command is beyond a certain complexity it is usually better practice to write a proper class for it than to inline it.

This class is provided by the NewCommands VendorDep

Constructor & Destructor Documentation

◆ FunctionalCommand() [1/3]

frc2::FunctionalCommand::FunctionalCommand ( std::function< void()>  onInit,
std::function< void()>  onExecute,
std::function< void(bool)>  onEnd,
std::function< bool()>  isFinished,
Requirements  requirements = {} 
)

Creates a new FunctionalCommand.

Parameters
onInitthe function to run on command initialization
onExecutethe function to run on command execution
onEndthe function to run on command end
isFinishedthe function that determines whether the command has finished
requirementsthe subsystems required by this command

◆ FunctionalCommand() [2/3]

frc2::FunctionalCommand::FunctionalCommand ( FunctionalCommand &&  other)
default

◆ FunctionalCommand() [3/3]

frc2::FunctionalCommand::FunctionalCommand ( const FunctionalCommand other)
default

Member Function Documentation

◆ End()

void frc2::FunctionalCommand::End ( bool  interrupted)
override

◆ Execute()

void frc2::FunctionalCommand::Execute ( )
override

◆ Initialize()

void frc2::FunctionalCommand::Initialize ( )
override

◆ IsFinished()

bool frc2::FunctionalCommand::IsFinished ( )
override

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