Skip to content

Commit 0c39e4a

Browse files
authored
Merge pull request #26 from KavinSandking/main
Added feedforward control to flywheel documentation in nextControl
2 parents 43cacdc + 5884530 commit 0c39e4a

1 file changed

Lines changed: 14 additions & 10 deletions

File tree

src/control/examples/flywheels.md

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Flywheel Example
22

33
Flywheels are a commonly used mechanism in FTC for launching game elements,
4-
and most often controlled with a velocity PID feedback controller.
4+
and most often controlled with a feedforward controller and a velocity PID controller.
55

66
With NextControl, that would be implemented like this (using hypothetical constants):
77

@@ -12,15 +12,17 @@ With NextControl, that would be implemented like this (using hypothetical consta
1212
```kotlin
1313
controlSystem {
1414
velPid(0.001, 0.0, 0.0)
15+
basicFF(0.003, 0.08, 0.0)
1516
}
1617
```
1718

1819
== Java
1920

2021
```java
2122
ControlSystem.builder()
22-
.velPid(0.001, 0.0, 0.0)
23-
.build();
23+
.velPid(0.001, 0.0, 0.0)
24+
.basicFF(0.003, 0.08, 0.0)
25+
.build();
2426
```
2527

2628
:::
@@ -43,10 +45,11 @@ class FlywheelExample() : OpMode() {
4345
val flywheelMotor by lazy { hardwareMap.get(DcMotorEx::class.java, "flywheel") }
4446
val controller = controlSystem {
4547
velPid(0.001, 0.0, 0.0)
48+
basicFF(0.003, 0.08, 0.0)
4649
}
4750

4851
override fun init() {
49-
controller.goal = KineticState(0.0)
52+
controller.goal = KineticState(0.0, 0.0)
5053
}
5154

5255
override fun loop() {
@@ -78,20 +81,21 @@ public class FlywheelExample extends OpMode {
7881
flywheelMotor = hardwareMap.get(DcMotorEx.class, "flywheel");
7982

8083
controller = ControlSystem.builder()
81-
.velPid(0.001, 0.0, 0.0)
82-
.build();
84+
.velPid(0.001, 0.0, 0.0)
85+
.basicFF(0.003, 0.08, 0.0)
86+
.build();
8387

84-
controller.setGoal(new KineticState(0.0));
88+
controller.setGoal(new KineticState(0.0, 0.0));
8589
}
8690

8791
@Override
8892
public void loop() {
8993
if (gamepad1.aWasPressed()) {
90-
controller.setGoal(new KineticState(2000.0));
94+
controller.setGoal(new KineticState(0.0, 2000.0));
9195
} else if (gamepad1.bWasPressed()) {
92-
controller.setGoal(new KineticState(0.0));
96+
controller.setGoal(new KineticState(0.0, 0.0));
9397
} else if (gamepad1.xWasPressed()) {
94-
controller.setGoal(new KineticState(1000.0));
98+
controller.setGoal(new KineticState(0.0, 1000.0));
9599
}
96100

97101
flywheelMotor.setPower(controller.calculate(new KineticState(

0 commit comments

Comments
 (0)