WPILibC++ 2024.3.2
frc::ElevatorFeedforward Class Reference

A helper class that computes feedforward outputs for a simple elevator (modeled as a motor acting against the force of gravity). More...

#include <frc/controller/ElevatorFeedforward.h>

Public Types

using Distance = units::meters
 
using Velocity = units::compound_unit< Distance, units::inverse< units::seconds > >
 
using Acceleration = units::compound_unit< Velocity, units::inverse< units::seconds > >
 
using kv_unit = units::compound_unit< units::volts, units::inverse< Velocity > >
 
using ka_unit = units::compound_unit< units::volts, units::inverse< Acceleration > >
 

Public Member Functions

constexpr ElevatorFeedforward (units::volt_t kS, units::volt_t kG, units::unit_t< kv_unit > kV, units::unit_t< ka_unit > kA=units::unit_t< ka_unit >(0))
 Creates a new ElevatorFeedforward with the specified gains. More...
 
constexpr units::volt_t Calculate (units::unit_t< Velocity > velocity, units::unit_t< Acceleration > acceleration=units::unit_t< Acceleration >(0))
 Calculates the feedforward from the gains and setpoints. More...
 
units::volt_t Calculate (units::unit_t< Velocity > currentVelocity, units::unit_t< Velocity > nextVelocity, units::second_t dt) const
 Calculates the feedforward from the gains and setpoints. More...
 
constexpr units::unit_t< VelocityMaxAchievableVelocity (units::volt_t maxVoltage, units::unit_t< Acceleration > acceleration)
 Calculates the maximum achievable velocity given a maximum voltage supply and an acceleration. More...
 
constexpr units::unit_t< VelocityMinAchievableVelocity (units::volt_t maxVoltage, units::unit_t< Acceleration > acceleration)
 Calculates the minimum achievable velocity given a maximum voltage supply and an acceleration. More...
 
constexpr units::unit_t< AccelerationMaxAchievableAcceleration (units::volt_t maxVoltage, units::unit_t< Velocity > velocity)
 Calculates the maximum achievable acceleration given a maximum voltage supply and a velocity. More...
 
constexpr units::unit_t< AccelerationMinAchievableAcceleration (units::volt_t maxVoltage, units::unit_t< Velocity > velocity)
 Calculates the minimum achievable acceleration given a maximum voltage supply and a velocity. More...
 

Public Attributes

const units::volt_t kS
 The static gain. More...
 
const units::volt_t kG
 The gravity gain. More...
 
const units::unit_t< kv_unitkV
 The velocity gain. More...
 
const units::unit_t< ka_unitkA
 The acceleration gain. More...
 

Detailed Description

A helper class that computes feedforward outputs for a simple elevator (modeled as a motor acting against the force of gravity).

Member Typedef Documentation

◆ Acceleration

◆ Distance

using frc::ElevatorFeedforward::Distance = units::meters

◆ ka_unit

◆ kv_unit

◆ Velocity

Constructor & Destructor Documentation

◆ ElevatorFeedforward()

constexpr frc::ElevatorFeedforward::ElevatorFeedforward ( units::volt_t  kS,
units::volt_t  kG,
units::unit_t< kv_unit kV,
units::unit_t< ka_unit kA = units::unit_t<ka_unit>(0) 
)
inlineconstexpr

Creates a new ElevatorFeedforward with the specified gains.

Parameters
kSThe static gain, in volts.
kGThe gravity gain, in volts.
kVThe velocity gain, in volt seconds per distance.
kAThe acceleration gain, in volt secondsĀ² per distance.

Member Function Documentation

◆ Calculate() [1/2]

units::volt_t frc::ElevatorFeedforward::Calculate ( units::unit_t< Velocity currentVelocity,
units::unit_t< Velocity nextVelocity,
units::second_t  dt 
) const
inline

Calculates the feedforward from the gains and setpoints.

Parameters
currentVelocityThe current velocity setpoint, in distance per second.
nextVelocityThe next velocity setpoint, in distance per second.
dtTime between velocity setpoints in seconds.
Returns
The computed feedforward, in volts.

◆ Calculate() [2/2]

constexpr units::volt_t frc::ElevatorFeedforward::Calculate ( units::unit_t< Velocity velocity,
units::unit_t< Acceleration acceleration = units::unit_t<Acceleration>(0) 
)
inlineconstexpr

Calculates the feedforward from the gains and setpoints.

Parameters
velocityThe velocity setpoint, in distance per second.
accelerationThe acceleration setpoint, in distance per secondĀ².
Returns
The computed feedforward, in volts.

◆ MaxAchievableAcceleration()

constexpr units::unit_t< Acceleration > frc::ElevatorFeedforward::MaxAchievableAcceleration ( units::volt_t  maxVoltage,
units::unit_t< Velocity velocity 
)
inlineconstexpr

Calculates the maximum achievable acceleration given a maximum voltage supply and a velocity.

Useful for ensuring that velocity and acceleration constraints for a trapezoidal profile are simultaneously achievable - enter the velocity constraint, and this will give you a simultaneously-achievable acceleration constraint.

Parameters
maxVoltageThe maximum voltage that can be supplied to the elevator.
velocityThe velocity of the elevator.
Returns
The maximum possible acceleration at the given velocity.

◆ MaxAchievableVelocity()

constexpr units::unit_t< Velocity > frc::ElevatorFeedforward::MaxAchievableVelocity ( units::volt_t  maxVoltage,
units::unit_t< Acceleration acceleration 
)
inlineconstexpr

Calculates the maximum achievable velocity given a maximum voltage supply and an acceleration.

Useful for ensuring that velocity and acceleration constraints for a trapezoidal profile are simultaneously achievable - enter the acceleration constraint, and this will give you a simultaneously-achievable velocity constraint.

Parameters
maxVoltageThe maximum voltage that can be supplied to the elevator.
accelerationThe acceleration of the elevator.
Returns
The maximum possible velocity at the given acceleration.

◆ MinAchievableAcceleration()

constexpr units::unit_t< Acceleration > frc::ElevatorFeedforward::MinAchievableAcceleration ( units::volt_t  maxVoltage,
units::unit_t< Velocity velocity 
)
inlineconstexpr

Calculates the minimum achievable acceleration given a maximum voltage supply and a velocity.

Useful for ensuring that velocity and acceleration constraints for a trapezoidal profile are simultaneously achievable - enter the velocity constraint, and this will give you a simultaneously-achievable acceleration constraint.

Parameters
maxVoltageThe maximum voltage that can be supplied to the elevator.
velocityThe velocity of the elevator.
Returns
The minimum possible acceleration at the given velocity.

◆ MinAchievableVelocity()

constexpr units::unit_t< Velocity > frc::ElevatorFeedforward::MinAchievableVelocity ( units::volt_t  maxVoltage,
units::unit_t< Acceleration acceleration 
)
inlineconstexpr

Calculates the minimum achievable velocity given a maximum voltage supply and an acceleration.

Useful for ensuring that velocity and acceleration constraints for a trapezoidal profile are simultaneously achievable - enter the acceleration constraint, and this will give you a simultaneously-achievable velocity constraint.

Parameters
maxVoltageThe maximum voltage that can be supplied to the elevator.
accelerationThe acceleration of the elevator.
Returns
The minimum possible velocity at the given acceleration.

Member Data Documentation

◆ kA

const units::unit_t<ka_unit> frc::ElevatorFeedforward::kA

The acceleration gain.

◆ kG

const units::volt_t frc::ElevatorFeedforward::kG

The gravity gain.

◆ kS

const units::volt_t frc::ElevatorFeedforward::kS

The static gain.

◆ kV

const units::unit_t<kv_unit> frc::ElevatorFeedforward::kV

The velocity gain.


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