|
1 | 1 | # Pedro Pathing Extension |
2 | 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. |
| 3 | +This is our extension to add built-in support |
| 4 | +for [Pedro Pathing](https://pedropathing.com), a GVF-based path-planning and |
| 5 | +following library for FTC. |
11 | 6 |
|
12 | 7 | ## Installation |
13 | 8 |
|
14 | | -To install the Pedro Pathing extension, |
15 | | -add the following line to your `build.gradle` file: |
| 9 | +In the TeamCode `build.gradle`, go to the `dependencies` block. |
| 10 | +Add the following lines: |
| 11 | + |
| 12 | +::: tabs key:gradle |
| 13 | + |
| 14 | +== .gradle |
16 | 15 |
|
17 | 16 | ```groovy |
18 | 17 | implementation 'dev.nextftc.extensions:pedro:1.0.0' |
19 | 18 | ``` |
20 | 19 |
|
21 | | -::: warning |
22 | | -Version `1.0.0` supports Pedro Pathing `2.0.0`, |
23 | | -and is not compatible with earlier versions. |
24 | | - |
25 | | -This guide also assumes you are using |
26 | | -the QuickStart for Pedro Pathing. |
27 | | -::: |
28 | | - |
29 | | -## Usage |
| 20 | +== .gradle.kts |
30 | 21 |
|
31 | | -### `PedroComponent` |
32 | | - |
33 | | -To use the Pedro Pathing extension, |
34 | | -add a `PedroComponent` object to the `addComponents` call |
35 | | -in your `NextFtcOpMode`, using `createFollower` from your |
36 | | -`Constants` class. |
37 | | - |
38 | | -::: tabs key:code |
39 | | - |
40 | | -== Kotlin |
41 | 22 | ```kotlin |
42 | | -class MyOpModeKt : NextFTCOpMode() { |
43 | | - init { |
44 | | - addComponents( |
45 | | - PedroComponent(Constants::createFollower) |
46 | | - ) |
47 | | - } |
48 | | -} |
| 23 | +implementation("dev.nextftc.extensions:pedro:1.0.0") |
49 | 24 | ``` |
50 | 25 |
|
51 | | -== Java |
52 | | -```java |
53 | | -public class MyOpModeJava extends NextFTCOpMode { |
54 | | - public MyOpModeJava() { |
55 | | - addComponents( |
56 | | - new PedroComponent(Constants::createFollower) |
57 | | - ); |
58 | | - } |
59 | | -} |
60 | | -``` |
61 | 26 | ::: |
62 | 27 |
|
63 | | -### The Follower |
64 | | - |
65 | | -Once you've added the `PedroComponent`, |
66 | | -you can access the `Follower` instance |
67 | | -as a static property of the `PedroComponent` class |
68 | | -(`PedroComponent.follower` in Kotlin, or `PedroComponent.follower()` in Java). |
69 | | - |
70 | | -### Creating Path Commands |
| 28 | +Then, press the `Sync Now` button that appeared as a banner at the top of your |
| 29 | +Gradle file. |
71 | 30 |
|
72 | | -To create path commands, you can use the `FollowPath` command, |
73 | | -passing in a `Path` or a `PathChain` argument. |
74 | | - |
75 | | -::: tabs key:code |
76 | | -== Kotlin |
77 | | -```kotlin |
78 | | -private val startPose = Pose(9.0, 111.0, Math.Math.toRadians(-90.0)) |
79 | | -private val scorePose = Pose(16.0, 128.0, Math.Math.toRadians(-45.0)) |
80 | | -private val pickup1Pose = Pose(30.0, 121.0, Math.Math.toRadians(0.0)) |
81 | | -private val pickup2Pose = Pose(30.0, 131.0, Math.Math.toRadians(0.0)) |
82 | | -private val pickup3Pose = Pose(45.0, 128.0, Math.Math.toRadians(90.0)) |
83 | | -private val parkPose = Pose(68.0, 96.0, Math.Math.toRadians(-90.0)) |
84 | | - |
85 | | -class MyOpModeKt : NextFTCOpMode() { |
86 | | - init { |
87 | | - addComponents( |
88 | | - PedroComponent(Constants::createFollower) |
89 | | - ) |
90 | | - } |
91 | | - |
92 | | - val pathCommand by onInit { |
93 | | - FollowPath(PedroComponent.follower.pathBuilder() |
94 | | - .addPath(BezierLine(startPose, scorePose)) |
95 | | - .setLinearHeadingInterpolation(startPose.heading, scorePose.heading) |
96 | | - .build()) |
97 | | - } |
98 | | - |
99 | | - override fun onWaitForStart() { |
100 | | - pathCommand.schedule() |
101 | | - } |
102 | | -} |
103 | | -``` |
104 | | - |
105 | | -== Java |
106 | | -```java |
107 | | -public class MyOpMode extends NextFTCOpMode { |
108 | | - private final Pose startPose = new Pose(9.0, 111.0, Math.toRadians(-90.0)); |
109 | | - private final Pose scorePose = new Pose(16.0, 128.0, Math.toRadians(-45.0)); |
110 | | - private final Pose pickup1Pose = new Pose(30.0, 121.0, Math.toRadians(0.0)); |
111 | | - private final Pose pickup2Pose = new Pose(30.0, 131.0, Math.toRadians(0.0)); |
112 | | - private final Pose pickup3Pose = new Pose(45.0, 128.0, Math.toRadians(90.0)); |
113 | | - private final Pose parkPose = new Pose(68.0, 96.0, Math.toRadians(-90.0)); |
114 | | - |
115 | | - private FollowPath pathCommand; |
116 | | - |
117 | | - public MyOpMode() { |
118 | | - addComponents( |
119 | | - new PedroComponent(Constants::createFollower) |
120 | | - ); |
121 | | - } |
122 | | - |
123 | | - @Override |
124 | | - public void onInit() { |
125 | | - pathCommand = new FollowPath(PedroComponent.follower().pathBuilder() |
126 | | - .addPath(new BezierLine(startPose, scorePose)) |
127 | | - .setLinearHeadingInterpolation(startPose.getHeading(), scorePose.getHeading()) |
128 | | - .build()); |
129 | | - } |
130 | | - |
131 | | - @Override |
132 | | - public void onWaitForStart() { |
133 | | - pathCommand.schedule(); |
134 | | - } |
135 | | -} |
136 | | -``` |
137 | | - |
138 | | -::: |
| 31 | +*You're good to go!* |
139 | 32 |
|
140 | | -## KDoc |
| 33 | +## Credit |
141 | 34 |
|
142 | | -This guide is a work-in-progress, |
143 | | -so we recommend checking the KDoc [here](https://javadoc.io/doc/dev.nextftc.extensions/pedro/latest/index.html). |
| 35 | +Thanks so much to the Pedro Pathing team for creating such an amazing pathing |
| 36 | +library! |
0 commit comments