Skip to content

Commit b04af3c

Browse files
committed
feat(extensions): add documentation for Pedro Pathing + extensions sidebar
1 parent cdf2c13 commit b04af3c

4 files changed

Lines changed: 166 additions & 5 deletions

File tree

.vitepress/config.mts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import guide from "./sidebar/guide.mts";
44
import nextftc from "./sidebar/nextftc.mts";
55
import bindings from "./sidebar/bindings.mts";
66
import control from "./sidebar/control.mts";
7-
import nextrunner from "./sidebar/nextrunner.mts";
7+
import extensions from "./sidebar/extensions.mts";
88
import llmstxt from 'vitepress-plugin-llms'
99

1010
// https://vitepress.dev/reference/site-config
@@ -43,10 +43,9 @@ export default defineConfig({
4343
{text: "NextFTC", link: "/nextftc/", activeMatch: "^/nextftc/"},
4444
{text: "NextControl", link: "/control/", activeMatch: "^/control/"},
4545
{text: "NextBindings", link: "/bindings/", activeMatch: "^/bindings/"},
46-
{text: "NextPedro", link: "/pedro/", activeMatch: "^/pedro/"},
47-
{text: "NextRunner", link: "/nextrunner/", activeMatch: "^/nextrunner/"}
46+
{text: "Extensions", link: "/extensions/", activeMatch: "^/extensions/"},
4847
],
49-
activeMatch: "^/(nextftc|control|bindings|pedro)/"
48+
activeMatch: "^/(nextftc|control|bindings|extensions)/"
5049

5150
},
5251
{
@@ -68,7 +67,7 @@ export default defineConfig({
6867
'/nextftc/': nextftc,
6968
'/bindings/': bindings,
7069
'/control/': control,
71-
'/nextrunner/': nextrunner
70+
'/extensions/': extensions
7271
},
7372

7473
socialLinks:

.vitepress/sidebar/extensions.mts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import {DefaultTheme} from "vitepress";
2+
3+
type SidebarItem = DefaultTheme.SidebarItem;
4+
5+
export default [
6+
{
7+
text: "Overview", link: '/extensions/'
8+
},
9+
{
10+
text: "PedroPathing", items: [
11+
{text: "PedroPathing Extension", link: "/extensions/pedro/pedro"},
12+
]
13+
}
14+
] satisfies SidebarItem[]

src/extensions/index.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# NextFTC Extensions
2+
3+
NextFTC Extensions are a set of libraries that extend the functionality of NextFTC.
4+
5+
## Pedro Pathing
6+
7+
This extension provides integration with the
8+
[Pedro Pathing Library](https://pedropathing.com/).
9+
More information about the extension can be found [here](pedro/pedro).
10+
11+
## RoadRunner
12+
13+
This extension provides integration with the
14+
[RoadRunner Library](https://rr.brott.dev/).
15+
Docs are coming soon!

src/extensions/pedro/pedro.md

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
# Pedro Pathing Extension
2+
3+
::: info
4+
This guide is a work-in-progress.
5+
Check back later for updates!
6+
:::
7+
8+
This extension provides integration with the
9+
[Pedro Pathing Library](https://pedropathing.com/),
10+
allowing you to use its features within your NextFTC projects.
11+
12+
## Installation
13+
14+
To install the Pedro Pathing extension,
15+
add the following line to your `build.gradle` file:
16+
17+
```groovy
18+
implementation 'dev.nextftc.extensions:pedro:1.0.0'
19+
```
20+
21+
::: warning
22+
Version `1.0.0` supports Pedro Pathing `2.0.0`,
23+
and is not compatible with earlier versions.
24+
:::
25+
26+
## Usage
27+
28+
### `PedroComponent`
29+
30+
To use the Pedro Pathing extension,
31+
add a `PedroComponent` object to the `addComponents` call
32+
in your `NextFtcOpMode`, using `createFollower` from your
33+
`Constants` class.
34+
35+
::: tabs key:code
36+
37+
== Kotlin
38+
```kotlin
39+
class MyOpModeKt : NextFTCOpMode() {
40+
init {
41+
addComponents(
42+
PedroComponent(Constants::createFollower)
43+
)
44+
}
45+
}
46+
```
47+
48+
== Java
49+
```java
50+
public class MyOpModeJava extends NextFTCOpMode {
51+
public MyOpModeJava() {
52+
addComponents(
53+
new PedroComponent(Constants::createFollower)
54+
);
55+
}
56+
}
57+
```
58+
:::
59+
60+
### The Follower
61+
62+
Once you've added the `PedroComponent`,
63+
you can access the `Follower` instance
64+
as a static property of the `PedroComponent` class
65+
(`PedroComponent.follower` in Kotlin, or `PedroComponent.follower()` in Java).
66+
67+
### Creating Path Commands
68+
69+
To create path commands, you can use the `FollowPath` command,
70+
passing in a `Path` or a `PathChain` argument.
71+
72+
::: tabs key:code
73+
== Kotlin
74+
```kotlin
75+
private val startPose = Pose(9.0, 111.0, Math.Math.toRadians(-90.0))
76+
private val scorePose = Pose(16.0, 128.0, Math.Math.toRadians(-45.0))
77+
private val pickup1Pose = Pose(30.0, 121.0, Math.Math.toRadians(0.0))
78+
private val pickup2Pose = Pose(30.0, 131.0, Math.Math.toRadians(0.0))
79+
private val pickup3Pose = Pose(45.0, 128.0, Math.Math.toRadians(90.0))
80+
private val parkPose = Pose(68.0, 96.0, Math.Math.toRadians(-90.0))
81+
82+
class MyOpModeKt : NextFTCOpMode() {
83+
init {
84+
addComponents(
85+
PedroComponent(Constants::createFollower)
86+
)
87+
}
88+
89+
val pathCommand = FollowPath(PedroComponent.follower.pathBuilder()
90+
.addPath(BezierLine(startPose, scorePose))
91+
.setLinearHeadingInterpolation(startPose.heading, scorePose.heading)
92+
.build())
93+
94+
override fun onWaitForStart() {
95+
pathCommand.schedule()
96+
}
97+
}
98+
```
99+
100+
== Java
101+
```java
102+
public class MyOpMode extends NextFTCOpMode {
103+
private final Pose startPose = new Pose(9.0, 111.0, Math.toRadians(-90.0));
104+
private final Pose scorePose = new Pose(16.0, 128.0, Math.toRadians(-45.0));
105+
private final Pose pickup1Pose = new Pose(30.0, 121.0, Math.toRadians(0.0));
106+
private final Pose pickup2Pose = new Pose(30.0, 131.0, Math.toRadians(0.0));
107+
private final Pose pickup3Pose = new Pose(45.0, 128.0, Math.toRadians(90.0));
108+
private final Pose parkPose = new Pose(68.0, 96.0, Math.toRadians(-90.0));
109+
110+
public MyOpMode() {
111+
addComponents(
112+
new PedroComponent(Constants::createFollower)
113+
);
114+
}
115+
116+
private final FollowPath pathCommand = new FollowPath(PedroComponent.follower().pathBuilder()
117+
.addPath(new BezierLine(startPose, scorePose))
118+
.setLinearHeadingInterpolation(startPose.getHeading(), scorePose.getHeading())
119+
.build());
120+
121+
@Override
122+
public void onWaitForStart() {
123+
pathCommand.schedule();
124+
}
125+
}
126+
```
127+
128+
:::
129+
130+
## KDoc
131+
132+
This guide is a work-in-progress,
133+
so we recommend checking the KDoc [here](https://javadoc.io/doc/dev.nextftc.extensions/pedro/latest/index.html).

0 commit comments

Comments
 (0)