WPILibC++ 2024.3.2
frc2::TrapezoidProfileSubsystem< Distance > Class Template Referenceabstract

A subsystem that generates and runs trapezoidal motion profiles automatically. More...

#include <frc2/command/TrapezoidProfileSubsystem.h>

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

Public Member Functions

 TrapezoidProfileSubsystem (Constraints constraints, Distance_t initialPosition=Distance_t{0}, units::second_t period=20_ms)
 Creates a new TrapezoidProfileSubsystem. 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...
 
- Public Member Functions inherited from frc2::SubsystemBase
void InitSendable (wpi::SendableBuilder &builder) override
 Initializes this Sendable object. More...
 
std::string GetName () const override
 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...
 
virtual std::string GetName () const
 Gets the name of this Subsystem. 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...
 
CommandPtr Defer (wpi::unique_function< CommandPtr()> supplier)
 Constructs a DeferredCommand with the provided supplier. 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

virtual void UseState (State state)=0
 Users should override this to consume the current state of the motion profile. More...
 
void Enable ()
 Enable the TrapezoidProfileSubsystem's output. More...
 
void Disable ()
 Disable the TrapezoidProfileSubsystem's output. More...
 
- Protected Member Functions inherited from frc2::SubsystemBase
 SubsystemBase ()
 Constructor. More...
 
 SubsystemBase (std::string_view name)
 Constructor. More...
 
- Protected Member Functions inherited from wpi::SendableHelper< SubsystemBase >
 SendableHelper ()=default
 
 ~SendableHelper ()
 

Detailed Description

template<class Distance>
class frc2::TrapezoidProfileSubsystem< Distance >

A subsystem that generates and runs trapezoidal motion profiles automatically.

The user specifies how to use the current state of the motion profile by overriding the UseState method.

This class is provided by the NewCommands VendorDep

Constructor & Destructor Documentation

◆ TrapezoidProfileSubsystem()

template<class Distance >
frc2::TrapezoidProfileSubsystem< Distance >::TrapezoidProfileSubsystem ( Constraints  constraints,
Distance_t  initialPosition = Distance_t{0},
units::second_t  period = 20_ms 
)
inlineexplicit

Creates a new TrapezoidProfileSubsystem.

Parameters
constraintsThe constraints (maximum velocity and acceleration) for the profiles.
initialPositionThe initial position of the controller mechanism when the subsystem is constructed.
periodThe period of the main robot loop, in seconds.

Member Function Documentation

◆ Disable()

template<class Distance >
void frc2::TrapezoidProfileSubsystem< Distance >::Disable ( )
inlineprotected

Disable the TrapezoidProfileSubsystem's output.

◆ Enable()

template<class Distance >
void frc2::TrapezoidProfileSubsystem< Distance >::Enable ( )
inlineprotected

Enable the TrapezoidProfileSubsystem's output.

◆ Periodic()

template<class Distance >
void frc2::TrapezoidProfileSubsystem< 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::TrapezoidProfileSubsystem< 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::TrapezoidProfileSubsystem< Distance >::SetGoal ( State  goal)
inline

Sets the goal state for the subsystem.

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

◆ UseState()

template<class Distance >
virtual void frc2::TrapezoidProfileSubsystem< Distance >::UseState ( State  state)
protectedpure virtual

Users should override this to consume the current state of the motion profile.

Parameters
stateThe current state of the motion profile.

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