Class MotorFeedforward
A feedforward model often uses the dynamics of a system to calculate a voltage for a movement that is specified by a desired velocity.
Feedforward models often take into account acceleration as well, but this is implicitly calculated from desired velocities so that only sensible movements can be specified.
A motor feedforward *model* can be converted into *controllers* through 3 decorator methods: `.velocity()`, `.position()`, and `.angle()`. `.velocity()` returns a velocity feedforward controller, while `.position()` returns a position feedforward controller, and `.angle()` returns an angle feedforward controller. These methods differ on what the controller's setpoint unit is.
For example, the velocity feedforward controller takes in velocity setpoints, which are directly passed to the model. On the other hand, a position feedforward controller takes in positional setpoints, which are then differentiated to get velocity and then fed to the feedforward controller. An angle feedforward controller is a positional controller that is forced to use angular units, so angular velocity is calculated and then fed to the feedforward model.
-
Constructor Summary
ConstructorDescriptionMotorFeedforward
(Number kS, Number kV, Number kA) Create a feedforward model for a motor -
Method Summary
Modifier and TypeMethodDescriptionfinal AngleController
angle()
Creates a controller that uses this feedforward model to calculate a motor output given angle setpoints.final double
calculate
(double velocity) Calculates a motor output given a desired velocityfinal Controller
position()
Creates a controller that uses this feedforward model to calculate a motor output given positional setpoints.final Controller
velocity()
Creates a controller that uses this feedforward model to calculate a motor output given velocity setpoints.
-
Constructor Details
-
MotorFeedforward
Create a feedforward model for a motor- Parameters:
kS
- volts, describes portion of voltage to overcome static frictionkV
- volts * seconds / distance, describes voltage needed to hold constant velocitykA
- volts * seconds^2 / distance, describes voltage needed to move at an acceleration
-
-
Method Details
-
velocity
Creates a controller that uses this feedforward model to calculate a motor output given velocity setpoints.- Returns:
- a velocity controller for this feedforward model
-
position
Creates a controller that uses this feedforward model to calculate a motor output given positional setpoints.NOTE: The derivative of the position setpoints is calculated and then plugged into this model.
- Returns:
- the position controller for this feedforward model
-
angle
Creates a controller that uses this feedforward model to calculate a motor output given angle setpoints.NOTE: the angular velocity of the angle setpoints is calculated and then plugged into this model.
- Returns:
- the angle controller for this feedforward model
-
calculate
public final double calculate(double velocity) Calculates a motor output given a desired velocityImplicitly determines acceleration by taking the derivative of velocity.
- Parameters:
velocity
- desired velocity- Returns:
- motor output, often in volts
-