- Introductory information explaining Feedforward and PID
In FRC, control applications center around two things. You have your control effort and your output. Your control effort is what you’re applying to your system (i.e., volts, amps, power), and your output is what’s being affected (position in meters, angle of the mechanism, the linear velocity at which it's traveling, etc.). For our purposes, let’s denote control effort as E
and output as O
.
Throughout this document you’re going to see there’s a large focus how we control the motor, not the mechanism. This is because from a control perspective, the motor is all we can see and control, which means that’s pretty much all we care about. The dynamics of the system ultimately tell us how we need to control our motor, which in turn controls the system.
Feedforward
- Different types of Feedforward
- The goal of using Feedforward
In its simplest form, the Feedforward model can be represented by an equation that’s shown below. Keep track of the units as we go.
$$
V = K_ssgn(v)+ K_vv + K_a*a
$$
where
- $V$ is a voltage (our control effort that’ll be applied).
- Its units are
ElectricPotential
(or in other words (Volts
)
- $K_S$ is the voltage needed to overcome static friction, or in simpler terms just get the motor spinning. In a mechanism, there’s going to be friction produced by your bearings, gears, belts, etc. that you need to overcome — luckily for us it’s all constant regardless of the velocity or acceleration we’re trying to hit. Think about it like this: before you start walking, jogging or sprinting, there’s a certain amount of force you push off with just to get you to start moving: this is constant for all three forms of movement.
- Its units are
ElectricPotential
(or in other words Volts
)
- $sgn(v)$ is the sign of velocity (if we’re doing in the positive direction this will equal 1, negative direction will be -1, and stationary will be 0).
- $K_v$ is the voltage you need to stay at a steady velocity. In the real world, there are other forces such as drag, kinetic friction, counter-electromotive forces (forces that oppose your motor) that need to be counteracted so your motor can stay at the same velocity. The amount of voltage needed to stay at a steady-velocity scales up linearly with the velocity you’re travelling at: think back to the running example, you output less force to stay the same speed while you’re walking compared to when you’re sprinting.
- Its units are
volts / velocity
(this can be angular velocity or linear velocity and depends on use case)
- $v$ is the desired velocity of the system. Note that this is not the current velocity. Our Feedforward model tells us the control effort that needs to be applied in order to achieve a desired velocity, feeding in our current velocity is just going to keep it where it is.
- Its units are
meters / second
or radians / second
or any other form (inches per second, degrees per second, rotations per minute, etc.).
- $K_a$ is the voltage needed to induce an acceleration. You need to apply some sort of control effort to accelerate.
- Its units are
volts / acceleration
- $a$ is the acceleration of your system.
- Its units are
meters / second^2
or radians / second^2
or any other form
Let’s do some dimensional analysis!
- Starting off with the equation, the white $V$ is what we’re solving for. Remember that’s the control effort we’ll be applying.
- $V = K_s * sgn(v) + K_v * v + K_a *a$ can be broken up into smaller parts. Each of these parts is labelled with a color and the goal for a colored part is to have it simplify to an answer whose units is in
volts
- $K_s * sgn(v)$ in units is
volts * unitless
. Recall that all sgn(v)
returns is 1, 0, or -1, neither of which have units. volts * unitless
just simplifies to volts
which means we’ve succeeded in having this colored part’s answer’s units be volts
. This also means that we’ve proved that unit of $K_s$ is volts
.
- $K_v * v$ in the dimensional analysis is $\frac{volts}{velocity} * velocity$ which just simplifies to
volts
because the velocity cancels out. This makes this part’s units volts
and means that we’ve proved the units of $K_v$ is $\frac{volts}{velocity}$
- $K_a * a$ in dimensional analysis is $\frac{volts}{acceleration} * acceleration$ which just simplifies to
volts
because the acceleration cancels out. The makes this part’s units volts
and means we’ve proved that the units of $K_a$ have to be $\frac{volts}{acceleration}$
Let’s do an example! Where our control effort is in Volts
and our output is LinearVelocity
. Note that the output is what we desire to achieve, as in we want our mechanism to achieve a certain linear velocity.
- $V = K_s * sgn(v) + K_v * v + K_a *a$ splits up into
- $K_s * sgn(v)$ → $volts * unitless$ → $volts$ ✅
- $K_v * v$ → $\frac{volts}{\frac{meters}{second}} * \frac{meters}{second}$ → $volts$ ✅
- $K_a * a$ → $\frac{volts}{\frac{meters}{second^2}} * \frac{meters}{second^2}$ → $volts$ ✅
- Which turns into $volts = volts + volts + volts$ in terms of units, which matches up!
SimpleMotorFeedForward