Skip to content

Commit 4f92daa

Browse files
Added combining feedforward + feedback
1 parent c098a6a commit 4f92daa

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

docs/section-7/feedforward-control.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
type="text/javascript">
44
</script>
55

6-
## Feedforward Control
7-
86
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:
97

108
```java
@@ -194,4 +192,13 @@ motor.setVoltage(volts);
194192
That's it!
195193
Similarly WPILIB provides a `ArmFeedforward` and an `ElevatorFeedforward` class whose only difference from `SimpleFeedforward` is that it accepts a \\(k_{g}\\) value.
196194

197-
## Conclusion
195+
## Combining Feedforward and Feedback Control
196+
197+
[Read WPILIB's article](https://docs.wpilib.org/en/stable/docs/software/advanced-controls/controllers/combining-feedforward-feedback.html)
198+
(It is as easy as just adding them together)
199+
```java
200+
// Adds a feedforward to the loop output before sending it to the motor
201+
motor.setVoltage(pid.calculate(encoder.getDistance(), setpoint) + feedforward);
202+
```
203+
204+
## Conclusion

0 commit comments

Comments
 (0)