WPILibC++ 2022.4.1
frc2::ProfiledPIDSubsystem< Distance > Class Template Referenceabstract

A subsystem that uses a ProfiledPIDController to control an output. More...

#include <frc2/command/ProfiledPIDSubsystem.h>

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

Public Member Functions

 ProfiledPIDSubsystem (frc::ProfiledPIDController< Distance > controller, Distance_t initialPosition=Distance_t{0})
 Creates a new ProfiledPIDSubsystem. More...
 
void Periodic () override
 This method is called periodically by the CommandScheduler. More...
 
void SetGoal (State goal)
 Sets the goal state for the subsystem. More...
 
void SetGoal (Distance_t goal)
 Sets the goal state for the subsystem. More...
 
virtual void Enable ()
 Enables the PID control. More...
 
virtual void Disable ()
 Disables the PID control. More...
 
bool IsEnabled ()
 Returns whether the controller is enabled. More...
 
frc::ProfiledPIDController< Distance > & GetController ()
 Returns the ProfiledPIDController. More...
 
- Public Member Functions inherited from frc2::SubsystemBase
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
 ~Subsystem ()
 
virtual void SimulationPeriodic ()
 This method is called periodically by the CommandScheduler. More...
 
template<class T , typename = std::enable_if_t<std::is_base_of_v< Command, std::remove_reference_t<T>>>>
void SetDefaultCommand (T &&defaultCommand)
 Sets the default Command of 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...
 
- Public Member Functions inherited from wpi::Sendable
virtual ~Sendable ()=default
 
- Public Member Functions inherited from wpi::SendableHelper< SubsystemBase >
 SendableHelper (const SendableHelper &rhs)=default
 
 SendableHelper (SendableHelper &&rhs)
 
SendableHelperoperator= (const SendableHelper &rhs)=default
 
SendableHelperoperator= (SendableHelper &&rhs)
 
std::string GetName () const
 Gets the name of this Sendable object. More...
 
void SetName (std::string_view name)
 Sets the name of this Sendable object. More...
 
void SetName (std::string_view subsystem, std::string_view name)
 Sets both the subsystem name and device name of this Sendable object. More...
 
std::string GetSubsystem () const
 Gets the subsystem name of this Sendable object. More...
 
void SetSubsystem (std::string_view subsystem)
 Sets the subsystem name of this Sendable object. More...
 

Protected Member Functions

virtual Distance_t GetMeasurement ()=0
 Returns the measurement of the process variable used by the ProfiledPIDController. More...
 
virtual void UseOutput (double output, State setpoint)=0
 Uses the output from the ProfiledPIDController. More...
 
- Protected Member Functions inherited from frc2::SubsystemBase
 SubsystemBase ()
 
- Protected Member Functions inherited from wpi::SendableHelper< SubsystemBase >
 SendableHelper ()=default
 
void SetName (std::string_view moduleType, int channel)
 Sets the name of the sensor with a channel number. More...
 
void SetName (std::string_view moduleType, int moduleNumber, int channel)
 Sets the name of the sensor with a module and channel number. More...
 
void AddChild (std::shared_ptr< Sendable > child)
 Add a child component. More...
 
void AddChild (void *child)
 Add a child component. More...
 
 ~SendableHelper ()
 

Protected Attributes

frc::ProfiledPIDController< Distance > m_controller
 
bool m_enabled {false}
 

Detailed Description

template<class Distance>
class frc2::ProfiledPIDSubsystem< Distance >

A subsystem that uses a ProfiledPIDController to control an output.

The controller is run synchronously from the subsystem's periodic() method.

This class is provided by the NewCommands VendorDep

See also
ProfiledPIDController

Constructor & Destructor Documentation

◆ ProfiledPIDSubsystem()

template<class Distance >
frc2::ProfiledPIDSubsystem< Distance >::ProfiledPIDSubsystem ( frc::ProfiledPIDController< Distance >  controller,
Distance_t  initialPosition = Distance_t{0} 
)
inlineexplicit

Creates a new ProfiledPIDSubsystem.

Parameters
controllerthe ProfiledPIDController to use
initialPositionthe initial goal position of the subsystem

Member Function Documentation

◆ Disable()

template<class Distance >
virtual void frc2::ProfiledPIDSubsystem< Distance >::Disable ( )
inlinevirtual

Disables the PID control.

Sets output to zero.

◆ Enable()

template<class Distance >
virtual void frc2::ProfiledPIDSubsystem< Distance >::Enable ( )
inlinevirtual

Enables the PID control.

Resets the controller.

◆ GetController()

template<class Distance >
frc::ProfiledPIDController< Distance > & frc2::ProfiledPIDSubsystem< Distance >::GetController ( )
inline

Returns the ProfiledPIDController.

Returns
The controller.

◆ GetMeasurement()

template<class Distance >
virtual Distance_t frc2::ProfiledPIDSubsystem< Distance >::GetMeasurement ( )
protectedpure virtual

Returns the measurement of the process variable used by the ProfiledPIDController.

Returns
the measurement of the process variable

◆ IsEnabled()

template<class Distance >
bool frc2::ProfiledPIDSubsystem< Distance >::IsEnabled ( )
inline

Returns whether the controller is enabled.

Returns
Whether the controller is enabled.

◆ Periodic()

template<class Distance >
void frc2::ProfiledPIDSubsystem< Distance >::Periodic ( )
inlineoverridevirtual

This method is called periodically by the CommandScheduler.

Useful for updating subsystem-specific state that you don't want to offload to a Command. Teams should try to be consistent within their own codebases about which responsibilities will be handled by Commands, and which will be handled here.

Reimplemented from frc2::Subsystem.

◆ SetGoal() [1/2]

template<class Distance >
void frc2::ProfiledPIDSubsystem< Distance >::SetGoal ( Distance_t  goal)
inline

Sets the goal state for the subsystem.

Goal velocity assumed to be zero.

Parameters
goalThe goal position for the subsystem's motion profile.

◆ SetGoal() [2/2]

template<class Distance >
void frc2::ProfiledPIDSubsystem< Distance >::SetGoal ( State  goal)
inline

Sets the goal state for the subsystem.

Parameters
goalThe goal state for the subsystem's motion profile.

◆ UseOutput()

template<class Distance >
virtual void frc2::ProfiledPIDSubsystem< Distance >::UseOutput ( double  output,
State  setpoint 
)
protectedpure virtual

Uses the output from the ProfiledPIDController.

Parameters
outputthe output of the ProfiledPIDController
setpointthe setpoint state of the ProfiledPIDController, for feedforward

Member Data Documentation

◆ m_controller

template<class Distance >
frc::ProfiledPIDController<Distance> frc2::ProfiledPIDSubsystem< Distance >::m_controller
protected

◆ m_enabled

template<class Distance >
bool frc2::ProfiledPIDSubsystem< Distance >::m_enabled {false}
protected

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