Skip to content

Commit c4cc897

Browse files
committed
feat: add more docs
Signed-off-by: BeepBot99 <74377508+BeepBot99@users.noreply.github.com>
1 parent 1b9c2b1 commit c4cc897

13 files changed

Lines changed: 645 additions & 147 deletions

File tree

.idea/vcs.xml

Lines changed: 0 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/workspace.xml

Lines changed: 15 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.vitepress/sidebar/control.mts

Lines changed: 42 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,59 @@ type SidebarItem = DefaultTheme.SidebarItem;
55
export default [
66
{
77
text: "Overview",
8-
link: "/control/",
8+
link: "/control/"
99
},
1010
{
11-
text: "Kinetic States",
12-
link: "/control/kineticstates",
11+
text: "Getting Started",
12+
link: "/control/getting-started"
1313
},
1414
{
15-
text: "Control Systems",
16-
link: "/control/controlsystem",
15+
text: "Configuring with the FTC Dashboard",
16+
link: "/control/dashboard"
17+
},
18+
{
19+
text: "Reference",
20+
items: [
21+
{
22+
text: "Control Systems",
23+
link: "/control/usage/control-systems",
24+
},
25+
{
26+
text: "Kinetic States",
27+
link: "/control/usage/kinetic-states",
28+
},
29+
{
30+
text: "Feedback Elements",
31+
link: "/control/usage/feedback-elements"
32+
},
33+
{
34+
text: "Feedforward Elements",
35+
link: "/control/usage/feedforward-elements"
36+
},
37+
{
38+
text: "Filter Elements",
39+
link: "/control/usage/filter-elements"
40+
},
41+
{
42+
text: "Interpolator Elements",
43+
link: "/control/usage/interpolator-elements"
44+
}
45+
]
1746
},
1847
{
1948
text: "Examples",
2049
items: [
2150
{
22-
text: "Index",
23-
link: "/control/examples/",
51+
text: "Slides",
52+
link: "/control/examples/slides"
53+
},
54+
{
55+
text: "Arms",
56+
link: "/control/examples/arms"
2457
},
2558
{
26-
text: "Linear Slides",
27-
link: "/control/examples/slides",
59+
text: "Flywheels",
60+
link: "/control/examples/flywheels"
2861
}
2962
]
3063
}

src/control/controlsystem.md

Lines changed: 0 additions & 76 deletions
This file was deleted.

src/control/dashboard.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Configuring with the FTC Dashboard
2+
3+
It is common to tune your controllers with the
4+
[FTC Dashboard](https://acmerobotics.github.io/ftc-dashboard). To support
5+
this, NextControl allows passing a coefficients/parameters object for each
6+
element instead of directly passing the coefficients.
7+
8+
For example:
9+
10+
:::tabs key:code
11+
12+
== Kotlin
13+
14+
```kotlin
15+
// in a class with @Config
16+
17+
companion object Constants {
18+
@JvmField
19+
val coefficients = PIDCoefficients(p, i, d)
20+
}
21+
22+
val controlSystem = controlSystem {
23+
posPid(coefficients)
24+
}
25+
```
26+
27+
== Java
28+
29+
```java
30+
// in a class with @Config
31+
32+
public static PIDCoefficients coefficients = new PIDCoefficients(p, i, d);
33+
34+
ControlSystem controlSystem = ControlSystem.builder()
35+
.posPid(coefficients)
36+
.build();
37+
```
38+
39+
:::
40+
41+
Now, our PID is configurable from the dashboard.
42+
43+
Although this example is for a PID element, every other element in NextControl
44+
has a coefficients/parameters object as well.

src/control/examples/slides.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Linear slides are a commonly used mechanism in FTC,
44
and most often controlled with a positional PID feedback
5-
controller and a static feedforward term to account for gravity.
5+
controller and a constant feedforward term to account for gravity.
66

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

@@ -36,8 +36,8 @@ An example of a Linear Slides subsystem using NextControl can be found
3636
[here](../../guide/subsystems/lift.md).
3737

3838
If not, we can create OpModes that use our controllers directly.
39-
For example, lets say we wanted to change the target of our slides using a button press.
40-
We can easily do that by simply changing the `goal` of our ControlSystem:
39+
For example, let's say we wanted to change the target of our slides using a button press.
40+
We can easily do that by simply changing the `goal` of our `ControlSystem`:
4141

4242
::: tabs key:code
4343

@@ -52,16 +52,16 @@ class SlideExample() : OpMode() {
5252
}
5353

5454
override fun init() {
55-
controller.goal = KineticState(0.0, 0.0, 0.0)
55+
controller.goal = KineticState(0.0)
5656
}
5757

5858
override fun loop() {
5959
if (gamepad1.a) {
60-
controller.goal = KineticState(1000.0, 0.0, 0.0)
60+
controller.goal = KineticState(1000.0)
6161
} else if (gamepad1.b) {
62-
controller.goal = KineticState(0.0, 0.0, 0.0)
62+
controller.goal = KineticState(0.0)
6363
} else if (gamepad1.x) {
64-
controller.goal = KineticState(500.0, 0.0, 0.0)
64+
controller.goal = KineticState(500.0)
6565
}
6666

6767
slideMotor.power = controller.calculate(
@@ -88,17 +88,17 @@ public class SlideExample extends OpMode {
8888
.elevatorFF(0.04)
8989
.build();
9090

91-
controller.goal = new KineticState(0.0, 0.0, 0.0);
91+
controller.goal = new KineticState(0.0);
9292
}
9393

9494
@Override
9595
public void loop() {
9696
if (gamepad1.a) {
97-
controller.goal = new KineticState(1000.0, 0.0, 0.0);
97+
controller.goal = new KineticState(1000.0);
9898
} else if (gamepad1.b) {
99-
controller.goal = new KineticState(0.0, 0.0, 0.0);
99+
controller.goal = new KineticState(0.0);
100100
} else if (gamepad1.x) {
101-
controller.goal = new KineticState(500.0, 0.0, 0.0);
101+
controller.goal = new KineticState(500.0);
102102
}
103103

104104
slideMotor.setPower(controller.calculate(

src/control/getting-started.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Getting Started
2+
3+
The simplest control system is a PID. Creating one is simple:
4+
5+
:::tabs key:code
6+
7+
== Kotlin
8+
9+
```kotlin
10+
val controlSystem = controlSystem {
11+
posPid(p, i, d)
12+
}
13+
```
14+
15+
== Java
16+
17+
```java
18+
ControlSystem controlSystem = ControlSystem.builder()
19+
.posPid(p, i, d)
20+
.build();
21+
```
22+
23+
:::
24+
25+
To run the control system's calculations, call `calculate` every loop. Pass
26+
a `KineticState` consisting of the current position and velocity, and
27+
optionally, the acceleration. Calling `calculate` returns the motor power to
28+
set.
29+
30+
:::tabs key:code
31+
32+
== Kotlin
33+
34+
```kotlin
35+
motor.power = controlSystem.calculate(
36+
KineticState(motor.position, motor.velocity)
37+
);
38+
```
39+
40+
== Java
41+
42+
```java
43+
motor.setPower(
44+
controlSystem.calculate(
45+
KineticState(motor.getPosition(), motor.getVelocity())
46+
)
47+
);
48+
```
49+
50+
:::

0 commit comments

Comments
 (0)