50 units::second_t dt = 20_ms)
51 : kS(kS), kG(kG), kV(kV), kA(kA), m_dt(dt) {
53 wpi::math::MathSharedStore::ReportError(
54 "kV must be a non-negative number, got {}!", kV.value());
55 this->kV = units::unit_t<kv_unit>{0};
59 wpi::math::MathSharedStore::ReportError(
60 "kA must be a non-negative number, got {}!", kA.value());
61 this->kA = units::unit_t<ka_unit>{0};
66 "period must be a positive number, got {}!", dt.value());
85 [[deprecated(
"Use the current/next velocity overload instead.")]]
90 kV * velocity + kA * acceleration;
106 [[deprecated(
"Use the current/next velocity overload instead.")]]
110 units::second_t dt)
const {
111 return Calculate(currentAngle, currentVelocity, nextVelocity);
128 return kS *
wpi::sgn(currentVelocity) +
220 return (maxVoltage - kS *
wpi::sgn(velocity) -
244 return MaxAchievableAcceleration(-maxVoltage, angle, velocity);
252 constexpr void SetKs(units::volt_t kS) { this->kS = kS; }
259 constexpr void SetKg(units::volt_t kG) { this->kG = kG; }
280 constexpr units::volt_t
GetKs()
const {
return kS; }
287 constexpr units::volt_t
GetKg()
const {
return kG; }
317 units::second_t m_dt;
#define WPILIB_DLLEXPORT
Definition SymbolExports.h:36
A helper class that computes feedforward outputs for a simple arm (modeled as a motor acting against ...
Definition ArmFeedforward.h:23
units::compound_unit< units::volts, units::inverse< Acceleration > > ka_unit
Definition ArmFeedforward.h:32
units::compound_unit< units::radians_per_second, units::inverse< units::second > > Acceleration
Definition ArmFeedforward.h:27
constexpr units::unit_t< Acceleration > MaxAchievableAcceleration(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,...
Definition ArmFeedforward.h:217
units::radians_per_second Velocity
Definition ArmFeedforward.h:26
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::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.
Definition ArmFeedforward.h:125
constexpr void SetKs(units::volt_t kS)
Sets the static gain.
Definition ArmFeedforward.h:252
constexpr units::volt_t GetKs() const
Returns the static gain.
Definition ArmFeedforward.h:280
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.
Definition ArmFeedforward.h:86
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.
Definition ArmFeedforward.h:47
constexpr units::unit_t< ka_unit > GetKa() const
Returns the acceleration gain.
Definition ArmFeedforward.h:301
constexpr units::unit_t< Acceleration > MinAchievableAcceleration(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,...
Definition ArmFeedforward.h:241
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.
Definition ArmFeedforward.h:107
units::compound_unit< units::volts, units::inverse< units::radians_per_second > > kv_unit
Definition ArmFeedforward.h:29
constexpr void SetKg(units::volt_t kG)
Sets the gravity gain.
Definition ArmFeedforward.h:259
constexpr units::unit_t< kv_unit > GetKv() const
Returns the velocity gain.
Definition ArmFeedforward.h:294
constexpr void SetKa(units::unit_t< ka_unit > kA)
Sets the acceleration gain.
Definition ArmFeedforward.h:273
units::radians Angle
Definition ArmFeedforward.h:25
constexpr void SetKv(units::unit_t< kv_unit > kV)
Sets the velocity gain.
Definition ArmFeedforward.h:266
constexpr units::unit_t< Velocity > MinAchievableVelocity(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,...
Definition ArmFeedforward.h:192
constexpr units::unit_t< Velocity > MaxAchievableVelocity(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,...
Definition ArmFeedforward.h:167
constexpr units::volt_t GetKg() const
Returns the gravity gain.
Definition ArmFeedforward.h:287
Container for values which represent quantities of a given unit.
Definition base.h:1930
constexpr underlying_type value() const noexcept
unit value
Definition base.h:2111
static void ReportError(const S &format, Args &&... args)
Definition MathShared.h:62
static void ReportWarning(const S &format, Args &&... args)
Definition MathShared.h:71
typename units::detail::inverse_impl< U >::type inverse
represents the inverse unit type of class U.
Definition base.h:1138
constexpr dimensionless::scalar_t cos(const AngleUnit angle) noexcept
Compute cosine.
Definition math.h:63
typename units::detail::compound_impl< U, Us... >::type compound_unit
Represents a unit type made up from other units.
Definition base.h:1438
constexpr int sgn(T val)
Definition MathExtras.h:758