Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/guide/opmodes/teleop.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ public class TeleOpProgram extends NextFTCOpMode {
Just like for autonomous, we need to add the required subsystems as a
`SubsystemComponent`. We will also add a
`BulkReadComponent`. Additionally, we will add a `BindingsComponent`, which
allows us to use gamepads from [NextBindings](/bindings).
allows us to use gamepads from [NextBindings](/bindings). You could also
choose to add an instance of the LoopTimeComponent which will log your
looptimes to your telemetry periodically.

:::tabs key:code

Expand All @@ -49,7 +51,8 @@ class TeleOpProgram : NextFTCOpMode() {
addComponents(
SubsystemComponent(Lift, Claw),
BulkReadComponent,
BindingsComponent
BindingsComponent,
LoopTimeComponent()
)
}
}
Expand All @@ -63,7 +66,8 @@ public class TeleOpProgram extends NextFTCOpMode {
addComponents(
new SubsystemComponent(Lift.INSTANCE, Claw.INSTANCE),
BulkReadComponent.INSTANCE,
BindingsComponent.INSTANCE
BindingsComponent.INSTANCE,
new LoopTimeComponent()
);
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/nextftc/concepts/components.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ NextFTC has several built-in components, including:

- `BulkReadComponent`
- `BindingsComponent` (for [NextBindings](/bindings))
- `LoopTimeComponent`
- `PedroComponent` (for the PedroPathing Extension)
- `SubsystemComponent`
- `CommandManager`
Expand Down Expand Up @@ -90,4 +91,4 @@ init {
:::

Components' `pre`- functions are called in the order they're set and `post`-
functions are called in the reverse order.
functions are called in the reverse order.
16 changes: 0 additions & 16 deletions src/nextftc/hardware/motors-and-servos/feedback-servos.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,35 +52,19 @@ The caching tolerance is the same for any normal `ServoEx` or other implementati
== Kotlin

```kotlin
val servo: FeedbackCRServoEx = FeedbackCRServoEx("analog-name", "servo-name", 0.01)

// Alternatively
val servo: FeedbackCRServoEx = FeedbackCRServoEx {
cacheTolerance = 0.01, // Or whatever you'd like to use
feedbackFactory = { ActiveOpMode.hardwareMap.analogInput.get("analog-name") },
servoFactory = { ActiveOpMode.hardwareMap.crservo.get("servo-name") }
}

// Alternatively
val analogInput: AnalogInput = ActiveOpMode.hardwareMap.analogInput.get("analog-name")
val servoFactory: CRServo = ActiveOpMode.hardwareMap.crservo.get("servo-name")
val servo: FeedbackCRServoEx = FeedbackCRServoEx(analogInput, servoFactory, 0.01) // Using cache tolerance = 0.01
```
== Java
```java
FeedbackCRServoEx servo = new FeedbackCRServoEx("analog-name", "servo-name", 0.01);

// Alternatively
FeedbackCRServoEx servo = new FeedbackCRServoEx(
0.01, // Or your preferred cache tolerance
() -> { ActiveOpMode.hardwareMap().analogInput.get("analog-name") },
() -> { ActiveOpMode.hardwareMap().crservo.get("servo-name") }
);

// Alternatively
AnalogInput analogInput = ActiveOpMode.hardwareMap.analogInput.get("analog-name");
CRServo servoFactory = ActiveOpMode.hardwareMap.crservo.get("servo-name");
FeedbackCRServoEx servo = new FeedbackCRServoEx(analogInput, servoFactory, 0.01);
```
==
:::
Expand Down
37 changes: 36 additions & 1 deletion src/nextftc/hardware/motors-and-servos/motors.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,39 @@ MotorGroup myMotorGroup = new MotorGroup(
);
```

:::
:::

## `VoltageCompensatingMotor`

`VoltageCompensatingMotor` is a class that takes into consideration the voltage
of the robot to set the power of a `MotorEx`, allowing the system to set power to
more or less than the user input, increasing the motor's consistency/stability
to perform in abnormal voltage levels. NextFTC allows for easy use of the
`VoltageCompensatingMotor` as shown below:

:::tabs key:code
== Kotlin

```kotlin
val myMotorEx = MotorEx("motor_name")

val myVoltageCompensatingMotor = VoltageCompensatingMotor(myMotorEx)

// or with "ideal" voltage(Volts) and voltage caching time(seconds/Duration) specifications
val myVoltageCompensatingMotor = VoltageCompensatingMotor(myMotorEx, 500.milliseconds, 12.0)
val myVoltageCompensatingMotor = VoltageCompensatingMotor(myMotorEx, 0.5, 12.0)
```

== Java

```java
MotorEx myMotor = new MotorEx("motor_name")

VoltageCompensatingMotor myVoltageCompensatingMotor = new VoltageCompensatingMotor(myMotorEx)

// or with "ideal" voltage(Volts) and voltage caching time(seconds) specifications
VoltageCompensatingMotor myVoltageCompensatingMotor = new VoltageCompensatingMotor(myMotorEx, 0.5, 12.0)
VoltageCompensatingMotor myVoltageCompensatingMotor = new VoltageCompensatingMotor(myMotorEx, "500ms", 12.0)
```

:::