Skip to content

Commit 4eccb54

Browse files
committed
feat: more changes
Signed-off-by: BeepBot99 <74377508+BeepBot99@users.noreply.github.com>
1 parent 390e31b commit 4eccb54

11 files changed

Lines changed: 150 additions & 168 deletions

File tree

.idea/workspace.xml

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

.vitepress/sidebar/nextftc.mts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,6 @@ export default [
4949
{
5050
text: "Delays",
5151
link: "/nextftc/helpful-commands/delays"
52-
},
53-
{
54-
text: "Miscellaneous",
55-
link: "/nextftc/helpful-commands/misc"
5652
}
5753
]
5854
},

src/nextftc/concepts/commands.md

Lines changed: 36 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,44 @@
11
# Commands
22

3-
_Why use commands?_ Commands allow you to **organize your code** much more efficiently than you could otherwise. They are an excellent alternative to [finite state machines](https://gm0.org/en/latest/docs/software/concepts/finite-state-machines.html), but are a lot easier to create and modify, and can reach higher levels of complexity than a finite state machine can.
3+
_Why use commands?_ Commands allow you to **organize your code** much more
4+
efficiently than you could otherwise. They are an excellent alternative
5+
to [finite state machines](https://gm0.org/en/latest/docs/software/concepts/finite-state-machines.html),
6+
are a lot easier to create and modify, and can reach higher levels of complexity
7+
than a finite state machine can.
48

59
## Parts of a Command
610

711
A command has four main components: `isDone`, `start`, `update`, and `stop`.
812

9-
- `isDone` is checked every loop. If it ever evaluates to `true`, the command will stop running.
10-
- `start` is run once, when the command is scheduled. It is used for setting up starting states and doing other things that should only happen once.
11-
- `update` runs every loop, many times per second. Because of this, it is crucial that it never takes more than a trivial amount of time to execute. You should be extremely careful of looping or doing anything else that could take significant amounts of time
12-
- `stop` runs once when the command ends, and recieves a parameter of whether or not it was interrupted by a different command.
13+
- `isDone` is checked every loop. If it ever evaluates to `true`, the command
14+
will stop running.
15+
- `start` is run once, when the command is scheduled. It is used for setting up
16+
starting states and doing other things that should only happen once.
17+
- `update` runs every loop, many times per second. Because of this, it is
18+
crucial that it never takes more than a trivial amount of time to execute. You
19+
should be extremely careful of looping or doing anything else that could take
20+
significant amounts of time
21+
- `stop` runs once when the command ends, and receives a parameter of
22+
whether it was interrupted by a different command.
1323

1424
Additionally, it has two more properties:
1525

16-
- `interruptible` determines whether or not the command is able to be interrupted. A command is interrupted when another command is scheduled that requires a subsystem the command is using. If a command is not interruptible, then the new command will not run.
17-
- `subsystems` is a set of all the subsystems a command uses. This is used for determing when two commands requrie the same subsystem. This is passed to the constructor of most premade commands.
26+
- `interruptible` determines whether the command is able to be
27+
interrupted. A command is interrupted when another command is scheduled that
28+
requires a subsystem the command is using. If a command is not interruptible,
29+
then the new command will not run.
30+
- `requirements` is a set of all the requirements a command has. This is
31+
used to determine when two commands require the same resource.
1832

1933
## Creating Commands
2034

21-
There are two ways to create a command: a `LambdaCommand` and by creating your own command class.
35+
There are two ways to create a command: a `LambdaCommand` and by creating your
36+
own command class.
2237

2338
### Lambda Commands
2439

25-
A lambda command is the main way to create a command in NextFTC. A lambda command can be created as follows:
40+
A lambda command is the main way to create a command in NextFTC. A lambda
41+
command can be created as follows:
2642

2743
:::tabs key:code
2844
== Kotlin
@@ -39,7 +55,7 @@ val myLambdaCommand = LambdaCommand()
3955
// Runs on stop
4056
}
4157
.setIsDone { true } // Returns if the commmand has finished
42-
.setRequirements(/* subsystems the command implements */)
58+
.requires(/* subsystems the command implements */)
4359
.setInterruptible(true)
4460
```
4561

@@ -57,18 +73,21 @@ Command myLambdaCommand = new LambdaCommand()
5773
// Runs on stop
5874
})
5975
.setIsDone(() -> true) // Returns if the command has finished
60-
.setRequirements(/* subsystems the command implements */)
76+
.requires(/* subsystems the command implements */)
6177
.setInterruptible(true)
6278
```
6379

6480
:::
6581

6682
> [!TIP]
67-
> All functions are completely optional. You only need to call the ones you will use. They can be called in any order.
83+
> All functions are completely optional. You only need to call the ones you will
84+
> use. They can be called in any order.
6885
6986
## Commands as Classes
7087

71-
It is unlikely that you will need to use this very often, but you can also create a command as a class. This is useful for cases where you need to reuse your command a lot. An command can be created as a class as follows:
88+
It is unlikely that you will need to use this very often, but you can also
89+
create a command as a class. This is useful for cases where you need to reuse
90+
your command a lot. An command can be created as a class as follows:
7291

7392
:::tabs key:code
7493
== Kotlin
@@ -77,7 +96,7 @@ It is unlikely that you will need to use this very often, but you can also creat
7796
class MyCommand(): Command() {
7897

7998
init {
80-
setRequirements(/* subsystems */) // you can make this a constructor parameter, if needed
99+
requires(/* subsystems */)
81100
setInterruptible(true) // this is the default, so you don't need to specify
82101
}
83102

@@ -104,7 +123,7 @@ class MyCommand(): Command() {
104123
public class MyCommand extends Command {
105124

106125
public MyCommand() {
107-
setRequirements(/* subsystems */); // you can make this a constructor parameter, if needed
126+
requires(/* subsystems */);
108127
setInterrptuptible(true); // this is the default, so you don't need to specify
109128
}
110129

@@ -134,9 +153,8 @@ public class MyCommand extends Command {
134153

135154
## Executing Commands
136155

137-
There are two ways to schedule a command.
156+
There are two ways to schedule a command. You can either call:
138157

139-
You can either call:
140158
:::tabs key:code
141159
== Kotlin
142160

@@ -155,6 +173,7 @@ CommandManager.INSTANCE.scheduleCommand(myCommand);
155173
:::
156174

157175
Or just:
176+
158177
:::tabs key:code
159178
== Kotlin
160179

src/nextftc/concepts/components.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ accomplish a wide range of functions when they're used in your OpModes.
99
NextFTC has several built-in components, including:
1010

1111
- `BulkReadComponent`
12-
- `BindingsComponent` (for NextBindings)
13-
- `PedroComponent` (for NextPedro)
12+
- `BindingsComponent` (for [NextBindings](/bindings))
1413
- `SubsystemComponent`
1514
- `CommandManager`
1615

@@ -71,7 +70,7 @@ For example:
7170
init {
7271
addComponents(
7372
MyComponent(),
74-
BindingComponent()
73+
BindingsComponent
7574
)
7675
}
7776
```
@@ -82,7 +81,7 @@ init {
8281
{
8382
addComponents(
8483
new MyComponent(),
85-
new BindingComponent()
84+
BindingsComponent.INSTANCE
8685
);
8786
}
8887
```

src/nextftc/concepts/subsystems.md

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -65,47 +65,42 @@ in that subsystem. For example:
6565
== Kotlin
6666

6767
```kotlin
68-
val open = SetPositon(claw, 1.0).setRequirements(this)
68+
val open = SetPositon(claw, 1.0).requires(this)
6969
```
7070

7171
== Java
7272

7373
```java
74-
public Command open = new SetPosition(claw, 1).setRequirements(this);
74+
public Command open = new SetPosition(claw, 1).requires(this);
7575
```
7676

7777
:::
7878

7979
However, if you have multiple degrees of freedom in one subsystem, commands
8080
for each degree of freedom should get its own requirement. A simple way to
81-
do this is as follows.
81+
do this is by using the hardware objects as requirements. See the following
82+
example.
8283

8384
:::tabs key:code
8485

8586
== Kotlin
8687

8788
```kotlin
88-
private val claw = Any()
89-
private val pivot = Any()
89+
val openClaw = SetPosition(clawServo, 1.0).requires(clawServo)
90+
val closeClaw = SetPosition(clawServo, 0.0).requires(clawServo)
9091

91-
val openClaw = SetPosition(clawServo, 1.0).setRequirements(claw)
92-
val closeClaw = SetPosition(clawServo, 0.0).setRequirements(claw)
93-
94-
val pivotLeft = SetPosition(pivotServo, 0.0).setRequirements(pivot)
95-
val pivotRight = SetPostion(pivotServo, 1.0).setRequirements(left)
92+
val pivotLeft = SetPosition(pivotServo, 0.0).requires(pivotServo)
93+
val pivotRight = SetPostion(pivotServo, 1.0).requires(pivotServo)
9694
```
9795

9896
== Java
9997

10098
```java
101-
private Object claw = new Object();
102-
private Object pivot = new Object();
103-
104-
public Command openClaw = new SetPosition(clawServo, 1).setRequirements(claw);
105-
public Command closeClaw = new SetPosition(clawServo, 0).setRequirements(claw);
99+
public Command openClaw = new SetPosition(clawServo, 1).requires(clawSerov);
100+
public Command closeClaw = new SetPosition(clawServo, 0).requires(clawServo);
106101

107-
public Command pivotLeft = new SetPosition(pivotServo, 0.0).setRequirements(pivot);
108-
public Command pivotRight = new SetPosition(pivotServo, 0.0).setRequirements(pivot);
102+
public Command pivotLeft = new SetPosition(pivotServo, 0.0).requires(pivotServo);
103+
public Command pivotRight = new SetPosition(pivotServo, 0.0).requires(pivotServo);
109104
```
110105

111106
:::

src/nextftc/concepts/units.md

Lines changed: 12 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
# Units
22

3-
NextFTC has an immutable, type-safe units system that allows you to pass quantities in any unit. It also prevents you from mixing up units accidentally. NextFTC has three types of units: `Distance`, `Angle`, and `TimeSpan`. All units extend the `Quantity` abstract class.
3+
NextFTC has an immutable, type-safe units system that allows you to pass
4+
quantities in any unit. It also prevents you from mixing up units accidentally.
5+
NextFTC has two types of units: `Distance` and `Angle`. All units extend the
6+
`Quantity` abstract class.
47

58
## `Distance`
69

7-
The first unit we'll look at is `Distance`. There are six units `Distance` accepts: millimeters, centimeters, meters, inches, feet, and yards. Internally it is stored in millimeters.
10+
The first unit we'll look at is `Distance`. There are six units `Distance`
11+
accepts: millimeters, centimeters, meters, inches, feet, and yards. Internally
12+
it is stored in millimeters.
813

914
Creating a `Distance` is simple:
1015

@@ -83,7 +88,6 @@ val inch = 1.inch
8388

8489
val sum = foot + inch // 13 in
8590
val difference = foot - inch // 11 in
86-
val product = foot * inch // 12 in (should be in^2 but NextFTC isn't THAT complicated)
8791
val quotient = foot / inch // 12
8892

8993
val bigger = foot * 2 // 24 in
@@ -115,7 +119,6 @@ Distance inch = Distance.fromIn(1);
115119

116120
Distance sum = foot.plus(inch); // 13 in
117121
Distance difference = foot.minus(inch); // 11 in
118-
Distance product = foot.times(inch); // 12 in (should be in^2 but NextFTC isn't THAT complicated)
119122
double quotient = foot.div(inch); // 12
120123

121124
Distance bigger = foot.times(2); // 24 in
@@ -140,42 +143,11 @@ boolean isNaN = foot.isNaN(); // false
140143

141144
:::
142145

143-
## `TimeSpan`
144-
145-
`TimeSpan` is very similar to `Distance`, only with different units. Supported units are microseconds, milliseconds, and seconds. Internally it is stored in microseconds.
146-
147-
Using `TimeSpans` is simple:
148-
149-
:::tabs key:code
150-
== Kotlin
151-
152-
```kotlin
153-
val seconds = 1.sec
154-
val milliseconds = 5.ms
155-
val microseconds = 70000000.us
156-
157-
val secondsInMilliseconds = seconds.inMs // 1,000
158-
val millisecondsInMicroseconds = milliseconds.inUs // 5,000
159-
val microsecondsInSeconds = microseconds.inSec // 70
160-
```
161-
162-
== Java
163-
164-
```java
165-
TimeSpan seconds = TimeSpan.fromSec(1);
166-
TimeSpan milliseconds = TimeSpan.fromMs(5);
167-
TimeSpan microseconds = TimeSpan.fromUs(70000000);
168-
169-
double secondsInMilliseconds = seconds.inMs; // 1,000
170-
double millisecondsInMicroseconds = milliseconds.inUs; // 5,000
171-
double microsecondsInSeconds = microseconds.inSec; // 70
172-
```
173-
174-
:::
175-
176146
## `Angle`
177147

178-
An `Angle` is very similar to `Distance` and `TimeSpan`, but it also has functionality for wrapping and normalizing. Angles can be in radians, degrees, or full revolutions, and are stored internally as radians.
148+
`Angle` is very similar to `Distance`, but it also has
149+
functionality for wrapping and normalizing. Angles can be in radians, degrees,
150+
or full revolutions, and are stored internally as radians.
179151

180152
:::tabs key:code
181153
== Kotlin
@@ -204,7 +176,8 @@ Double quarterRadians = quarterCircle.inRad; // pi/2
204176

205177
:::
206178

207-
You can also wrap and normalize angles. Below is a table of what wrapping and normalizing does for angles in different units.
179+
You can also wrap and normalize angles. Below is a table of what wrapping and
180+
normalizing does for angles in different units.
208181

209182
| Unit | Wrapping | Normalizing |
210183
|-------------|----------|-------------|

0 commit comments

Comments
 (0)