Skip to content

Commit f8eb0b6

Browse files
made all math equations into images + latex into code
1 parent 34e93d6 commit f8eb0b6

2 files changed

Lines changed: 13 additions & 13 deletions

File tree

docs/section-7/feedforward-control.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ We will first learn about the most common feedforward model used for motors, the
2424

2525
For those that only want a quick summary. Here is the equation:
2626

27-
$$ V = K_{s} \cdot sgn(\dot{d}) + K_{v} \cdot \dot{d} + K_{a} \cdot \ddot{d} $$
27+
![Motor Feedforward Equation](motor_feedforward_equation.PNG)
2828

29-
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.
29+
where `V` is the applied voltage, `d` is the displacement (position) of the motor, `d` with a single dot is its velocity, and `d` with a double dot is its acceleration (the “overdot” notation traditionally denotes the derivative with respect to time). `kS`, `kV`, and `kA` are all constants that are tuned.
3030

31-
- \\(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.
32-
- \\(k_{v} \cdot \dot{d}\\) is the amount of voltage needed to hold the motor at a given constant velocity.
33-
- \\(k_{a} \cdot \ddot{d}\\) is the amount of voltage needed to drive the motor at a given constant acceleration.
31+
- The `kS` term (including the `sgn(d)` part) is the amount of voltage needed to overcome the motor's static friction, or in other words to just barely get it moving.
32+
- The `kV` term (including the `d` dot part) is the amount of voltage needed to hold the motor at a given constant velocity.
33+
- The `kA` term (incluidng the `d` double dot part) is the amount of voltage needed to drive the motor at a given constant acceleration.
3434

35-
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}\\).
35+
When you add up all these values which equals `V`, that is voltage needed to keep a motor at velocity (`d` with dot) and acceleration (`d` with two dots).
3636

3737
Then, to drive the motor at the desired velocity and acceleration, it is as easy as writing:
3838
```java
@@ -48,7 +48,7 @@ motor.setVoltage(feedforwardVolts);
4848
!!! warning
4949
The code excerpt is only meant to show how feedforward works. This is not how we actually implement feedforward, but should give you a better idea of the inner workings of feedforward.
5050

51-
In addition, feedforward can also be used for elevators and arms. There is one additional constant \\(k_{g}\\) which is used to counteract the force of gravity.
51+
In addition, feedforward can also be used for elevators and arms. There is one additional constant `kG` which is used to counteract the force of gravity.
5252

5353
## Tuning and System Idenfication
5454
Similar to PID, you can tune values by manually guessing and checking.
@@ -57,12 +57,12 @@ Similar to PID, you can tune values by manually guessing and checking.
5757

5858
Follow the instructions and see if you can get the optimal tuning solution. The model simulates a flywheel shooter mechanism and halfway through the simulation it shoots a ball. **DO NOT SKIP THIS PRACTICE**
5959

60-
While manual tuning works, WPILIB provides a way to generate kS, kV, and kA, called System Identification, or SysID for short.
60+
While manual tuning works, WPILIB provides a way to generate `kS`, `kV`, and `kA`, called System Identification, or SysID for short.
6161

6262
!!! warning
6363
Do not move on if you don't know how [lambdas/consumers](https://docs.wpilib.org/en/stable/docs/software/basic-programming/functions-as-data.html) work and the [Java Unit library](https://docs.wpilib.org/en/stable/docs/software/basic-programming/java-units.html).
6464

65-
System Identification is the process of determining a mathematical model for the behavior of a system through statistical anaylsis of its inputs and outputs. SysID has a process to determine kS, kV, and kA for the motor, so you don't have to do any tuning! They also provide PID values, but treat them as a "starting point" for further tuning.
65+
System Identification is the process of determining a mathematical model for the behavior of a system through statistical anaylsis of its inputs and outputs. SysID has a process to determine `kS`, `kV`, and `kA` for the motor, so you don't have to do any tuning! They also provide PID values, but treat them as a "starting point" for further tuning.
6666

6767
Read the following WPILIB articles:
6868

@@ -133,7 +133,7 @@ Note that [SysIdRoutineLog](https://github.wpilib.org/allwpilib/docs/release/jav
133133
You may also notice that the only values that the logger logs are of instances that must be of `MutableMeasure<(insert measure)>`. This records the values along with its units. You can't just log a value.
134134

135135
!!! note
136-
Notice that you can write anything in the `driveMotor()` and `logMotor()` methods. You are not limited to only powering a single motor but can power an entire elevator, arm, etc. SysID also analyzes elevators and arms which calculate the \\(k_{g}\\) constant.
136+
Notice that you can write anything in the `driveMotor()` and `logMotor()` methods. You are not limited to only powering a single motor but can power an entire elevator, arm, etc. SysID also analyzes elevators and arms which calculate the `kG` constant.
137137

138138
After you set up the testing parameters and mechanism to test, the SysIdRoutine provides functions that return a command to run the test.
139139

@@ -167,14 +167,14 @@ Afterwards, put them into the SysID tool which can be opened by `Ctrl + Shift +
167167
- [Analyzing Data](https://docs.wpilib.org/en/stable/docs/software/advanced-controls/system-identification/analyzing-gains.html)
168168
- [Additional Utilities and Tools](https://docs.wpilib.org/en/stable/docs/software/advanced-controls/system-identification/additional-utils.html)
169169

170-
Once you have gotten good data and analysis, you should obtain kS, kV, kA and PID constants.
170+
Once you have gotten good data and analysis, you should obtain `kS`, `kV`, `kA` and PID constants.
171171

172172
!!! warning
173173
The PID constants are only a starting point and should be tuned more.
174174

175175
## Implementation
176176

177-
WPILIB provides a [SimpleMotorFeedforward](https://github.wpilib.org/allwpilib/docs/release/java/edu/wpi/first/math/controller/SimpleMotorFeedforward.html) class that runs feedforward for a motor. After you obtain your feedforward constants (kS, kV, kA) from SysID, you put them into the constructor of the `SimpleMotorFeedforward` and use the listed methods.
177+
WPILIB provides a [SimpleMotorFeedforward](https://github.wpilib.org/allwpilib/docs/release/java/edu/wpi/first/math/controller/SimpleMotorFeedforward.html) class that runs feedforward for a motor. After you obtain your feedforward constants (`kS`, `kV`, `kA`) from SysID, you put them into the constructor of the `SimpleMotorFeedforward` and use the listed methods.
178178
```java
179179
// Create a new SimpleMotorFeedforward with gains kS, kV, and kA
180180
SimpleMotorFeedforward feedforward = new SimpleMotorFeedforward(kS, kV, kA);
@@ -190,7 +190,7 @@ motor.setVoltage(volts);
190190
```
191191

192192
That's it!
193-
Similarly WPILIB provides a `ArmFeedforward` and an `ElevatorFeedforward` class whose only difference from `SimpleFeedforward` is that it accepts a \\(k_{g}\\) value.
193+
Similarly WPILIB provides a `ArmFeedforward` and an `ElevatorFeedforward` class whose only difference from `SimpleFeedforward` is that it accepts a `kG` value.
194194

195195
## Combining Feedforward and Feedback Control
196196

5.31 KB
Loading

0 commit comments

Comments
 (0)