Skip to content

Commit b375ed9

Browse files
committed
document units, ftc, and pedro
1 parent 1e296bc commit b375ed9

File tree

10 files changed

+815
-10
lines changed

10 files changed

+815
-10
lines changed

.vitepress/config.mts

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,34 +59,34 @@ export default defineConfig({
5959
]
6060
},
6161
{
62-
text: "Core Components",
62+
text: "Core concepts",
6363
items: [
6464
{
6565
text: "Commands",
66-
link: "/components/commands"
67-
},
68-
{
69-
text: "Command Groups",
70-
link: "/components/commandgroups"
66+
link: "/concepts/commands"
7167
},
7268
{
7369
text: "Hardware",
7470
items: [
7571
{
7672
text: "Motors",
77-
link: "/components/hardware/motors"
73+
link: "/concepts/hardware/motors"
7874
}
7975
]
8076
},
8177
{
82-
text: "Controllers",
83-
link: "/components/controllers"
78+
text: "Units",
79+
link: "/concepts/units"
8480
}
8581
]
8682
},
8783
{
8884
text: "Built-In Commands",
8985
items: [
86+
{
87+
text: "Command Groups",
88+
link: "/builtin-commands/commandgroups"
89+
},
9090
{
9191
text: "Utilities",
9292
link: "/builtin-commands/utilities"
@@ -116,6 +116,36 @@ export default defineConfig({
116116
link: "/builtin-commands/drivetrain-commands/differential"
117117
}
118118
]
119+
},
120+
{
121+
text: "Hardware Commands",
122+
items: [
123+
{
124+
text: "Motor Commands",
125+
link: "/builtin-commands/hardware/motors"
126+
},
127+
{
128+
text: "Servo Commands",
129+
link: "/builtin-commands/hardware/servos"
130+
}
131+
]
132+
},
133+
{
134+
text: "PedroPathing",
135+
items: [
136+
{
137+
text: "Movement",
138+
link: "/builtin-commands/pedro/movement"
139+
},
140+
{
141+
text: "Delays",
142+
link: "/builtin-commands/pedro/delays"
143+
}
144+
]
145+
},
146+
{
147+
text: "Miscellanous",
148+
link: "/builtin-commands/misc"
119149
}
120150
]
121151
}
File renamed without changes.

builtin-commands/delays.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ In NextFTC there are two types of delays.
44

55
## `Delay`
66

7-
A `Delay` is a command that waits a certain amount of time before finishing. It takes a `TimeSpan` (see the units page for more information) to determine how long it will take. Alternatively, it can take a time in seconds.
7+
A `Delay` is a command that waits a certain amount of time before finishing. It takes a [`TimeSpan`](/concepts/units#timespan) to determine how long it will take. Alternatively, it can take a time in seconds.
88

99
:::tabs key:code
1010
== Kotlin
Lines changed: 233 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,233 @@
1+
# Motor Commands
2+
3+
NextFTC has a bunch of motor commands so that you don't have to write your own!
4+
5+
## `RunToPosition`
6+
7+
`RunToPosition` is likely the most common motor command you will use. It takes a `Controllable` (like a `MotorEx` or a `MotorGroup`), a `Controller`, and a target. It finishes once the motor is in a tolerable distance of the target.
8+
9+
:::tabs key:code
10+
== Kotlin
11+
12+
```kotlin
13+
RunToPosition(motor, target, controller, setOf(subsystems))
14+
15+
// or in a subsystem:
16+
RunToPosition(motor, target, controller, this)
17+
```
18+
19+
== Java
20+
21+
```java
22+
new RunToPosition(motor, target, controller, Set.of(subsystems))
23+
24+
// or in a subsystem:
25+
new RunToPosition(motor, target, controller, this)
26+
```
27+
28+
:::
29+
30+
The tolerance of the controller can be set with `controller.setPointTolerance` as follows:
31+
32+
:::tabs key:code
33+
== Kotlin
34+
35+
```kotlin
36+
controller.setPointTolerance(20.0) // default is 10
37+
```
38+
39+
== Java
40+
41+
```java
42+
controller.setPointTolerance(20.0); // default is 10
43+
```
44+
45+
:::
46+
47+
## `HoldPosition`
48+
49+
`HoldPosition` holds a motor at the position it was at when the command was scheduled.
50+
51+
:::tabs key:code
52+
== Kotlin
53+
54+
```kotlin
55+
HoldPosition(motor, controller, setOf(subsystems))
56+
```
57+
58+
== Java
59+
60+
```java
61+
new HoldPosition(motor, controller, Set.of(subsystems))
62+
```
63+
64+
:::
65+
66+
It is mostly commonly used as the default command in a subsystem, which means it will run when no other command is being run.
67+
68+
:::tabs key:code
69+
== Kotlin
70+
71+
```kotlin
72+
override val defaultCommand: Command
73+
get() = HoldPosition(motor, controller, this)
74+
```
75+
76+
== Java
77+
78+
```java
79+
@Override
80+
public Command getDefaultCommand() {
81+
return new HoldPosition(motor, controller, this);
82+
}
83+
```
84+
85+
:::
86+
87+
## `SetPower`
88+
89+
`SetPower` is very simple: it sets the power and ends instantly.
90+
91+
:::tabs key:code
92+
== Kotlin
93+
94+
```kotlin
95+
SetPower(motor, power, setOf(subsystems))
96+
97+
// or in a subsystem:
98+
SetPower(motor, power, this)
99+
```
100+
101+
== Java
102+
103+
```java
104+
new SetPower(motor, power, Set.of(subsystems))
105+
106+
// or in a subsystem:
107+
new SetPower(motor, power, this)
108+
```
109+
110+
:::
111+
112+
## `RunToVelocity`
113+
114+
`RunToVelocity` uses a controller on a motor until it reaches a set velocity and then *depowers the motor*.
115+
116+
:::tabs key:code
117+
== Kotlin
118+
119+
```kotlin
120+
RunToVelocity(motor, velocity, controller, setOf(subsystems))
121+
122+
// or in a subsystem:
123+
RunToVelocity(motor, velocity, controller, this)
124+
```
125+
126+
== Java
127+
128+
```java
129+
new RunToVelocity(motor, velocity, controller, Set.of(subsystems))
130+
131+
// or in a subsystem:
132+
new RunToVelocity(motor, velocity, controller, this)
133+
```
134+
135+
:::
136+
137+
Optionally, you can pass the condition when it ends as well.
138+
139+
:::tabs key:code
140+
== Kotlin
141+
142+
```kotlin
143+
RunToVelocity(
144+
motor,
145+
velocity,
146+
controller,
147+
setOf(subsystems),
148+
{ abs(motor.velocity) - velocity < 10 } // this is the default
149+
)
150+
```
151+
152+
== Java
153+
154+
```java
155+
new RunToVelocity(
156+
motor,
157+
velocity,
158+
controller,
159+
Set.of(subsystems),
160+
() -> Math.abs(motor.getVelocity()) - velocity < 10 // this is the default
161+
)
162+
```
163+
164+
:::
165+
166+
## `HoldVelocity`
167+
168+
`HoldVelocity` is like a combination of `RunToVelocity` and `HoldPosition`: it keeps a motor at the velocity it was at when the command was scheduled.
169+
170+
171+
:::tabs key:code
172+
== Kotlin
173+
174+
```kotlin
175+
HoldVelocity(motor, controller, setOf(subsystems))
176+
```
177+
178+
== Java
179+
180+
```java
181+
new HoldVelocity(motor, controller, Set.of(subsystems))
182+
```
183+
184+
:::
185+
186+
Like `HoldPosition`, `HoldVelocity` is most commonly used as the default command in a subsystem. This is useful for something like a flywheel. You can have `RunToVelocity` commands that bring it to a velocity (spinning or stopped), and the `HoldVelocity` command will run when those stop to keep it at that velocity.
187+
188+
:::tabs key:code
189+
== Kotlin
190+
191+
```kotlin
192+
override val defaultCommand: Command
193+
get() = HoldVelocity(motor, controller, this)
194+
```
195+
196+
== Java
197+
198+
```java
199+
@Override
200+
public Command getDefaultCommand() {
201+
return new HoldVelocity(motor, controller, this);
202+
}
203+
```
204+
205+
:::
206+
207+
## `ResetEncoder`
208+
209+
`ResetEncoder` does exactly what it sounds like: it resets the encoder.
210+
211+
:::tabs key:code
212+
== Kotlin
213+
214+
```kotlin
215+
ResetEncoder(motor, setOf(subsystems))
216+
217+
// or in a subsystem:
218+
ResetEncoder(motor, this)
219+
```
220+
221+
== Java
222+
223+
```java
224+
new ResetEncoder(motor, Set.of(subsystems))
225+
226+
// or in a subsystem:
227+
new ResetEncoder(motor, this)
228+
```
229+
230+
:::
231+
232+
> [!NOTE]
233+
> See the [controllables reference](https://docs.rowanmcalpin.com/reference/ftc/com.rowanmcalpin.nextftc.ftc.hardware.controllables/) for more information.

0 commit comments

Comments
 (0)