WPILibC++ 2024.3.2
frc2::StartEndCommand Class Reference

A command that runs a given runnable when it is initialized, and another runnable when it ends. More...

#include <frc2/command/StartEndCommand.h>

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

Public Member Functions

 StartEndCommand (std::function< void()> onInit, std::function< void()> onEnd, Requirements requirements={})
 Creates a new StartEndCommand. More...
 
 StartEndCommand (StartEndCommand &&other)=default
 
 StartEndCommand (const StartEndCommand &other)=default
 
- Public Member Functions inherited from frc2::CommandHelper< FunctionalCommand, StartEndCommand >
 CommandHelper ()=default
 
CommandPtr ToPtr () &&override
 

Additional Inherited Members

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

Detailed Description

A command that runs a given runnable when it is initialized, and another runnable when it ends.

Useful for running and then stopping a motor, or extending and then retracting a solenoid. Has no end condition as-is; either subclass it or use Command.WithTimeout() or Command.Until() to give it one.

This class is provided by the NewCommands VendorDep

Constructor & Destructor Documentation

◆ StartEndCommand() [1/3]

frc2::StartEndCommand::StartEndCommand ( std::function< void()>  onInit,
std::function< void()>  onEnd,
Requirements  requirements = {} 
)

Creates a new StartEndCommand.

Will run the given runnables when the command starts and when it ends.

Parameters
onInitthe Runnable to run on command init
onEndthe Runnable to run on command end
requirementsthe subsystems required by this command

◆ StartEndCommand() [2/3]

frc2::StartEndCommand::StartEndCommand ( StartEndCommand &&  other)
default

◆ StartEndCommand() [3/3]

frc2::StartEndCommand::StartEndCommand ( const StartEndCommand other)
default

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