WPILibC++ 2025.2.1
Loading...
Searching...
No Matches
frc::ArmFeedforward Class Reference

A helper class that computes feedforward outputs for a simple arm (modeled as a motor acting against the force of gravity on a beam suspended at an angle). More...

#include <frc/controller/ArmFeedforward.h>

Public Types

using Angle = units::radians
 
using Velocity = units::radians_per_second
 
using Acceleration
 
using kv_unit
 
using ka_unit
 

Public Member Functions

constexpr ArmFeedforward (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), units::second_t dt=20_ms)
 Creates a new ArmFeedforward with the specified gains.
 
constexpr units::volt_t Calculate (units::unit_t< Angle > angle, units::unit_t< Velocity > velocity, units::unit_t< Acceleration > acceleration) const
 Calculates the feedforward from the gains and setpoints assuming continuous control.
 
units::volt_t Calculate (units::unit_t< Angle > currentAngle, units::unit_t< Velocity > currentVelocity, units::unit_t< Velocity > nextVelocity, units::second_t dt) const
 Calculates the feedforward from the gains and setpoints assuming continuous control.
 
constexpr units::volt_t Calculate (units::unit_t< Angle > currentAngle, units::unit_t< Velocity > currentVelocity) const
 Calculates the feedforward from the gains and setpoint assuming discrete control.
 
units::volt_t Calculate (units::unit_t< Angle > currentAngle, units::unit_t< Velocity > currentVelocity, units::unit_t< Velocity > nextVelocity) const
 Calculates the feedforward from the gains and setpoints assuming discrete control.
 
constexpr units::unit_t< VelocityMaxAchievableVelocity (units::volt_t maxVoltage, units::unit_t< Angle > angle, units::unit_t< Acceleration > acceleration)
 Calculates the maximum achievable velocity given a maximum voltage supply, a position, and an acceleration.
 
constexpr units::unit_t< VelocityMinAchievableVelocity (units::volt_t maxVoltage, units::unit_t< Angle > angle, units::unit_t< Acceleration > acceleration)
 Calculates the minimum achievable velocity given a maximum voltage supply, a position, and an acceleration.
 
constexpr units::unit_t< AccelerationMaxAchievableAcceleration (units::volt_t maxVoltage, units::unit_t< Angle > angle, units::unit_t< Velocity > velocity)
 Calculates the maximum achievable acceleration given a maximum voltage supply, a position, and a velocity.
 
constexpr units::unit_t< AccelerationMinAchievableAcceleration (units::volt_t maxVoltage, units::unit_t< Angle > angle, units::unit_t< Velocity > velocity)
 Calculates the minimum achievable acceleration given a maximum voltage supply, a position, and a velocity.
 
constexpr units::volt_t GetKs () const
 Returns the static gain.
 
constexpr units::volt_t GetKg () const
 Returns the gravity gain.
 
constexpr units::unit_t< kv_unitGetKv () const
 Returns the velocity gain.
 
constexpr units::unit_t< ka_unitGetKa () const
 Returns the acceleration gain.
 

Detailed Description

A helper class that computes feedforward outputs for a simple arm (modeled as a motor acting against the force of gravity on a beam suspended at an angle).

Member Typedef Documentation

◆ Acceleration

Initial value:
units::compound_unit<units::radians_per_second,
typename units::detail::inverse_impl< U >::type inverse
represents the inverse unit type of class U.
Definition base.h:1138
typename units::detail::compound_impl< U, Us... >::type compound_unit
Represents a unit type made up from other units.
Definition base.h:1438

◆ Angle

using frc::ArmFeedforward::Angle = units::radians

◆ ka_unit

◆ kv_unit

◆ Velocity

using frc::ArmFeedforward::Velocity = units::radians_per_second

Constructor & Destructor Documentation

◆ ArmFeedforward()

frc::ArmFeedforward::ArmFeedforward ( 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),
units::second_t dt = 20_ms )
inlineconstexpr

Creates a new ArmFeedforward with the specified gains.

Parameters
kSThe static gain, in volts.
kGThe gravity gain, in volts.
kVThe velocity gain, in volt seconds per radian.
kAThe acceleration gain, in volt secondsĀ² per radian.
dtThe period in seconds.
Throws:
IllegalArgumentException for kv < zero.
Throws:
IllegalArgumentException for ka < zero.
Throws:
IllegalArgumentException for period ≤ zero.

Member Function Documentation

◆ Calculate() [1/4]

units::volt_t frc::ArmFeedforward::Calculate ( units::unit_t< Angle > angle,
units::unit_t< Velocity > velocity,
units::unit_t< Acceleration > acceleration ) const
inlineconstexpr

Calculates the feedforward from the gains and setpoints assuming continuous control.

Parameters
angleThe angle setpoint, in radians. This angle should be measured from the horizontal (i.e. if the provided angle is 0, the arm should be parallel to the floor). If your encoder does not follow this convention, an offset should be added.
velocityThe velocity setpoint.
accelerationThe acceleration setpoint.
Returns
The computed feedforward, in volts.

◆ Calculate() [2/4]

units::volt_t frc::ArmFeedforward::Calculate ( units::unit_t< Angle > currentAngle,
units::unit_t< Velocity > currentVelocity ) const
inlineconstexpr

Calculates the feedforward from the gains and setpoint assuming discrete control.

Use this method when the velocity does not change.

Parameters
currentAngleThe current angle. This angle should be measured from the horizontal (i.e. if the provided angle is 0, the arm should be parallel to the floor). If your encoder does not follow this convention, an offset should be added.
currentVelocityThe current velocity.
Returns
The computed feedforward in volts.

◆ Calculate() [3/4]

units::volt_t frc::ArmFeedforward::Calculate ( units::unit_t< Angle > currentAngle,
units::unit_t< Velocity > currentVelocity,
units::unit_t< Velocity > nextVelocity ) const

Calculates the feedforward from the gains and setpoints assuming discrete control.

Parameters
currentAngleThe current angle. This angle should be measured from the horizontal (i.e. if the provided angle is 0, the arm should be parallel to the floor). If your encoder does not follow this convention, an offset should be added.
currentVelocityThe current velocity.
nextVelocityThe next velocity.
Returns
The computed feedforward in volts.

◆ Calculate() [4/4]

units::volt_t frc::ArmFeedforward::Calculate ( units::unit_t< Angle > currentAngle,
units::unit_t< Velocity > currentVelocity,
units::unit_t< Velocity > nextVelocity,
units::second_t dt ) const
inline

Calculates the feedforward from the gains and setpoints assuming continuous control.

Parameters
currentAngleThe current angle in radians. This angle should be measured from the horizontal (i.e. if the provided angle is 0, the arm should be parallel to the floor). If your encoder does not follow this convention, an offset should be added.
currentVelocityThe current velocity setpoint.
nextVelocityThe next velocity setpoint.
dtTime between velocity setpoints in seconds.
Returns
The computed feedforward in volts.

◆ GetKa()

units::unit_t< ka_unit > frc::ArmFeedforward::GetKa ( ) const
inlineconstexpr

Returns the acceleration gain.

Returns
The acceleration gain.

◆ GetKg()

units::volt_t frc::ArmFeedforward::GetKg ( ) const
inlineconstexpr

Returns the gravity gain.

Returns
The gravity gain.

◆ GetKs()

units::volt_t frc::ArmFeedforward::GetKs ( ) const
inlineconstexpr

Returns the static gain.

Returns
The static gain.

◆ GetKv()

units::unit_t< kv_unit > frc::ArmFeedforward::GetKv ( ) const
inlineconstexpr

Returns the velocity gain.

Returns
The velocity gain.

◆ MaxAchievableAcceleration()

units::unit_t< Acceleration > frc::ArmFeedforward::MaxAchievableAcceleration ( units::volt_t maxVoltage,
units::unit_t< Angle > angle,
units::unit_t< Velocity > velocity )
inlineconstexpr

Calculates the maximum achievable acceleration given a maximum voltage supply, a position, 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 arm.
angleThe angle of the arm. This angle should be measured from the horizontal (i.e. if the provided angle is 0, the arm should be parallel to the floor). If your encoder does not follow this convention, an offset should be added.
velocityThe velocity of the arm.
Returns
The maximum possible acceleration at the given velocity and angle.

◆ MaxAchievableVelocity()

units::unit_t< Velocity > frc::ArmFeedforward::MaxAchievableVelocity ( units::volt_t maxVoltage,
units::unit_t< Angle > angle,
units::unit_t< Acceleration > acceleration )
inlineconstexpr

Calculates the maximum achievable velocity given a maximum voltage supply, a position, 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 arm.
angleThe angle of the arm. This angle should be measured from the horizontal (i.e. if the provided angle is 0, the arm should be parallel to the floor). If your encoder does not follow this convention, an offset should be added.
accelerationThe acceleration of the arm.
Returns
The maximum possible velocity at the given acceleration and angle.

◆ MinAchievableAcceleration()

units::unit_t< Acceleration > frc::ArmFeedforward::MinAchievableAcceleration ( units::volt_t maxVoltage,
units::unit_t< Angle > angle,
units::unit_t< Velocity > velocity )
inlineconstexpr

Calculates the minimum achievable acceleration given a maximum voltage supply, a position, 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 arm.
angleThe angle of the arm. This angle should be measured from the horizontal (i.e. if the provided angle is 0, the arm should be parallel to the floor). If your encoder does not follow this convention, an offset should be added.
velocityThe velocity of the arm.
Returns
The minimum possible acceleration at the given velocity and angle.

◆ MinAchievableVelocity()

units::unit_t< Velocity > frc::ArmFeedforward::MinAchievableVelocity ( units::volt_t maxVoltage,
units::unit_t< Angle > angle,
units::unit_t< Acceleration > acceleration )
inlineconstexpr

Calculates the minimum achievable velocity given a maximum voltage supply, a position, 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 arm.
angleThe angle of the arm. This angle should be measured from the horizontal (i.e. if the provided angle is 0, the arm should be parallel to the floor). If your encoder does not follow this convention, an offset should be added.
accelerationThe acceleration of the arm.
Returns
The minimum possible velocity at the given acceleration and angle.

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