Skip to content

Commit a21214d

Browse files
added feedforward intro and the dc motor equation
1 parent 553b751 commit a21214d

1 file changed

Lines changed: 54 additions & 0 deletions

File tree

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<script
2+
src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"
3+
type="text/javascript">
4+
</script>
5+
6+
## Feedforward Control
7+
8+
Feedforward control means providing the mechanism with the control signal you think it needs to make the mechanism do what you want, without any knowledge of where the mechanism currently is. If you ever used a joystick to "directly" control the speed of a motor through applied voltage, maybe like this:
9+
10+
```java
11+
Joystick stick = new Joystick(0);
12+
public void robotPeriodic() {
13+
motor.set(stick.getY());
14+
}
15+
```
16+
That is feedforward control! You are giving the motor the amount of voltage needed to move at the desired speed which is determined by how you move the joystick.
17+
18+
Now, if you wanted to have the motor to move at a certain velocity rather than a percentage of full power like the case shown above, you will need to determine a mathematical model that can calculate the voltage needed to move at a certain velocity.
19+
20+
Feedforward isn't limited to controlling velocity, you can determine the voltage necessary to drive a motor at a certain velocity, acceleration, current, and many other factors. And it doesn't have to be voltage, it can be the air pressure released by a pneumatic actuator. And it isn't limited to just motors, feedforward applies to an entire arm subsystem, drivetrain, and many other mechanisms, but only if you can determine an accurate model for these mechanisms.
21+
22+
We will first learn about the most common feedforward model used for motors, then show how the model can be used to control motor velocity and acceleration. Afterwards, we will cover more complicated mechanisms such as the arm subsystem.
23+
24+
## The Permanent-Magnet DC Motor Feedforward Equation
25+
[Click here to read about the equation](https://docs.wpilib.org/en/stable/docs/software/advanced-controls/introduction/introduction-to-feedforward.html). Don't read past the "Variants of the Feedforward Equation".
26+
27+
For those that only want a quick summary. Here is the equation:
28+
29+
$$ V = K_{s} \cdot sgn(\dot{d}) + K_{v} \cdot \dot{d} + K_{a} \cdot \ddot{d} $$
30+
31+
where \\(V\\) is the applied voltage, \\(d\\) is the displacement (position) of the motor, \\(\dot{d}\\) is its velocity, and \\(\ddot{d}\\) is its acceleration (the “overdot” notation traditionally denotes the derivative with respect to time). \\(K_{s}\\), \\(K_{v}\\), and \\(K_{a}\\) are all constants that are tuned.
32+
33+
- \\(k_{s} \cdot sgn(\dot{d})\\) is the amount of voltage needed to overcome the motor's static friction, or in other words to just barely get it moving.
34+
- \\(k_{v} \cdot \dot{d}\\) is the amount of voltage needed to hold the motor at a given constant velocity.
35+
- \\(k_{a} \cdot \ddot{d}\\) is the amount of voltage needed to drive the motor at a given constant acceleration.
36+
37+
When you add up all these values which equals \\(V\\), that is voltage needed to keep a motor at velocity \\(\dot{d}\\) and acceleration \\(\ddot{d}\\).
38+
39+
Then, to drive the motor at the desired velocity and acceleration, it is as easy as writing:
40+
```java
41+
// assume kS, kV, and kA are defined
42+
double vel = 5;
43+
double accel = 1;
44+
double feedforwardVolts = kS * Math.signum(vel) + kV * vel + kA * accel;
45+
motor.setVoltage(feedforwardVolts);
46+
```
47+
!!! warning
48+
The amount of voltage calculated is the amount of voltage used to **MAINTAIN** the motor at the specified velocity and acceleration. When `motor.setVoltage(feedforwardVolts)` is run, that does not automatically drive the motor to the specified velocity and acceleration. If the code was run when the motor is at rest, then the voltage will be used the overcome the static friction and accelerate the motor, not to maintain the motor at the specified velocity and acceleration as the motor is not at the specified velocity.
49+
50+
## System Idenfication
51+
52+
## Implementation
53+
54+
## Conclusion

0 commit comments

Comments
 (0)