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

A base for subsystems that handles registration in the constructor, and provides a more intuitive method for setting the default command. More...

#include <frc2/command/SubsystemBase.h>

Inheritance diagram for frc2::SubsystemBase:
frc2::Subsystem wpi::Sendable wpi::SendableHelper< SubsystemBase > frc2::PIDSubsystem frc2::ProfiledPIDSubsystem< Distance > frc2::TrapezoidProfileSubsystem< Distance >

Public Member Functions

void InitSendable (wpi::SendableBuilder &builder) override
 Initializes this Sendable object. More...
 
std::string GetName () const
 Gets the name of this Subsystem. More...
 
void SetName (std::string_view name)
 Sets the name of this Subsystem. More...
 
std::string GetSubsystem () const
 Gets the subsystem name of this Subsystem. More...
 
void SetSubsystem (std::string_view name)
 Sets the subsystem name of this Subsystem. More...
 
void AddChild (std::string name, wpi::Sendable *child)
 Associate a Sendable with this Subsystem. More...
 
- Public Member Functions inherited from frc2::Subsystem
virtual ~Subsystem ()
 
virtual void Periodic ()
 This method is called periodically by the CommandScheduler. More...
 
virtual void SimulationPeriodic ()
 This method is called periodically by the CommandScheduler. More...
 
template<std::derived_from< Command > T>
void SetDefaultCommand (T &&defaultCommand)
 Sets the default Command of the subsystem. More...
 
void SetDefaultCommand (CommandPtr &&defaultCommand)
 Sets the default Command of the subsystem. More...
 
void RemoveDefaultCommand ()
 Removes the default command for the subsystem. More...
 
CommandGetDefaultCommand () const
 Gets the default command for this subsystem. More...
 
CommandGetCurrentCommand () const
 Returns the command currently running on this subsystem. More...
 
void Register ()
 Registers this subsystem with the CommandScheduler, allowing its Periodic() method to be called when the scheduler runs. More...
 
CommandPtr RunOnce (std::function< void()> action)
 Constructs a command that runs an action once and finishes. More...
 
CommandPtr Run (std::function< void()> action)
 Constructs a command that runs an action every iteration until interrupted. More...
 
CommandPtr StartEnd (std::function< void()> start, std::function< void()> end)
 Constructs a command that runs an action once and another action when the command is interrupted. More...
 
CommandPtr RunEnd (std::function< void()> run, std::function< void()> end)
 Constructs a command that runs an action every iteration until interrupted, and then runs a second action. More...
 
- Public Member Functions inherited from wpi::Sendable
virtual ~Sendable ()=default
 
virtual void InitSendable (SendableBuilder &builder)=0
 Initializes this Sendable object. More...
 
- Public Member Functions inherited from wpi::SendableHelper< SubsystemBase >
 SendableHelper (const SendableHelper &rhs)=default
 
 SendableHelper (SendableHelper &&rhs)
 
SendableHelperoperator= (const SendableHelper &rhs)=default
 
SendableHelperoperator= (SendableHelper &&rhs)
 

Protected Member Functions

 SubsystemBase ()
 
- Protected Member Functions inherited from wpi::SendableHelper< SubsystemBase >
 SendableHelper ()=default
 
 ~SendableHelper ()
 

Detailed Description

A base for subsystems that handles registration in the constructor, and provides a more intuitive method for setting the default command.

This class is provided by the NewCommands VendorDep

Constructor & Destructor Documentation

◆ SubsystemBase()

frc2::SubsystemBase::SubsystemBase ( )
protected

Member Function Documentation

◆ AddChild()

void frc2::SubsystemBase::AddChild ( std::string  name,
wpi::Sendable child 
)

Associate a Sendable with this Subsystem.

Also update the child's name.

Parameters
namename to give child
childsendable

◆ GetName()

std::string frc2::SubsystemBase::GetName ( ) const

Gets the name of this Subsystem.

Returns
Name

◆ GetSubsystem()

std::string frc2::SubsystemBase::GetSubsystem ( ) const

Gets the subsystem name of this Subsystem.

Returns
Subsystem name

◆ InitSendable()

void frc2::SubsystemBase::InitSendable ( wpi::SendableBuilder builder)
overridevirtual

Initializes this Sendable object.

Parameters
buildersendable builder

Implements wpi::Sendable.

◆ SetName()

void frc2::SubsystemBase::SetName ( std::string_view  name)

Sets the name of this Subsystem.

Parameters
namename

◆ SetSubsystem()

void frc2::SubsystemBase::SetSubsystem ( std::string_view  name)

Sets the subsystem name of this Subsystem.

Parameters
namesubsystem name

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