21template <
class Distance>
45 "kV must be a non-negative number, got {}!",
kV.
value());
51 "kA must be a non-negative number, got {}!",
kA.
value());
67 return kS *
wpi::sgn(velocity) +
kV * velocity +
kA * acceleration;
81 units::second_t dt)
const {
82 auto plant = LinearSystemId::IdentifyVelocitySystem<Distance>(
kV,
kA);
89 units::volt_t{feedforward.Calculate(r, nextR)(0)};
107 units::volt_t maxVoltage,
110 return (maxVoltage -
kS -
kA * acceleration) /
kV;
125 units::volt_t maxVoltage,
128 return (-maxVoltage +
kS -
kA * acceleration) /
kV;
144 return (maxVoltage -
kS *
wpi::sgn(velocity) -
kV * velocity) /
kA;
164 const units::volt_t
kS;
Constructs a plant inversion model-based feedforward from a LinearSystem.
Definition: LinearPlantInversionFeedforward.h:33
A helper class that computes feedforward voltages for a simple permanent-magnet DC motor.
Definition: SimpleMotorFeedforward.h:22
const units::unit_t< kv_unit > kV
The velocity gain.
Definition: SimpleMotorFeedforward.h:167
constexpr units::unit_t< Velocity > MinAchievableVelocity(units::volt_t maxVoltage, units::unit_t< Acceleration > acceleration) const
Calculates the minimum achievable velocity given a maximum voltage supply and an acceleration.
Definition: SimpleMotorFeedforward.h:124
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.
Definition: SimpleMotorFeedforward.h:79
units::compound_unit< Distance, units::inverse< units::seconds > > Velocity
Definition: SimpleMotorFeedforward.h:25
units::compound_unit< units::volts, units::inverse< Acceleration > > ka_unit
Definition: SimpleMotorFeedforward.h:30
const units::volt_t kS
The static gain.
Definition: SimpleMotorFeedforward.h:164
constexpr units::volt_t Calculate(units::unit_t< Velocity > velocity, units::unit_t< Acceleration > acceleration=units::unit_t< Acceleration >(0)) const
Calculates the feedforward from the gains and setpoints.
Definition: SimpleMotorFeedforward.h:64
constexpr units::unit_t< Acceleration > MaxAchievableAcceleration(units::volt_t maxVoltage, units::unit_t< Velocity > velocity) const
Calculates the maximum achievable acceleration given a maximum voltage supply and a velocity.
Definition: SimpleMotorFeedforward.h:142
units::compound_unit< units::volts, units::inverse< Velocity > > kv_unit
Definition: SimpleMotorFeedforward.h:28
units::compound_unit< Velocity, units::inverse< units::seconds > > Acceleration
Definition: SimpleMotorFeedforward.h:27
constexpr units::unit_t< Acceleration > MinAchievableAcceleration(units::volt_t maxVoltage, units::unit_t< Velocity > velocity) const
Calculates the minimum achievable acceleration given a maximum voltage supply and a velocity.
Definition: SimpleMotorFeedforward.h:158
constexpr SimpleMotorFeedforward(units::volt_t kS, units::unit_t< kv_unit > kV, units::unit_t< ka_unit > kA=units::unit_t< ka_unit >(0))
Creates a new SimpleMotorFeedforward with the specified gains.
Definition: SimpleMotorFeedforward.h:39
constexpr units::unit_t< Velocity > MaxAchievableVelocity(units::volt_t maxVoltage, units::unit_t< Acceleration > acceleration) const
Calculates the maximum achievable velocity given a maximum voltage supply and an acceleration.
Definition: SimpleMotorFeedforward.h:106
const units::unit_t< ka_unit > kA
The acceleration gain.
Definition: SimpleMotorFeedforward.h:170
constexpr underlying_type value() const noexcept
unit value
Definition: base.h:2107
static void ReportError(const S &format, Args &&... args)
Definition: MathShared.h:60
static void ReportWarning(const S &format, Args &&... args)
Definition: MathShared.h:69
typename units::detail::compound_impl< U, Us... >::type compound_unit
Represents a unit type made up from other units.
Definition: base.h:1434
Definition: AprilTagPoseEstimator.h:15
Eigen::Vector< double, Size > Vectord
Definition: EigenCore.h:12
constexpr int sgn(T val)
Definition: MathExtras.h:624