From 4bbefbbec187363f0f1eecad6ec2db12ae880f83 Mon Sep 17 00:00:00 2001 From: AchintyaAkula Date: Tue, 28 Jul 2026 17:23:14 -0700 Subject: [PATCH 1/7] Almost done with motor, two more sections left --- .idea/workspace.xml | 12 +- .../docs/hardware/actuators/cr-servos.mdx | 12 +- .../hardware/actuators/feedback-servos.mdx | 21 +- .../docs/hardware/actuators/motors.mdx | 211 ++++++++++++++++++ .../docs/hardware/actuators/servos.mdx | 14 +- 5 files changed, 246 insertions(+), 24 deletions(-) create mode 100644 src/content/docs/hardware/actuators/motors.mdx diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 3e2c3fa..8376c58 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -17,12 +17,11 @@ - - - - - - + + + + + diff --git a/src/content/docs/hardware/actuators/cr-servos.mdx b/src/content/docs/hardware/actuators/cr-servos.mdx index dde7c0f..5162ec2 100644 --- a/src/content/docs/hardware/actuators/cr-servos.mdx +++ b/src/content/docs/hardware/actuators/cr-servos.mdx @@ -16,16 +16,20 @@ There are two ways to construct a `NextCRServo`, depending on what you desire. ```kotlin -val intakeServo = NextCRServo(RobotController.controlHub, 0) // By Lynx Module and port, recommended +// By Lynx Module and port, recommended +val intakeServo = NextCRServo(RobotController.controlHub, 0) -val intakeServo = NextCRServo("intakeServo") // Using your configuration name +// Using a configuration name +val intakeServo = NextCRServo("intakeServo") ``` ```java -NextCRServo intakeServo = new NextCRServo(RobotController.getControlHub(), 0); // By Lynx Module and port, recommended +// By Lynx Module and port, recommended +NextCRServo intakeServo = new NextCRServo(RobotController.getControlHub(), 0); -NextCRServo intakeServo = new NextCRServo("intakeServo"); // Using your configuration name +// Using a configuration name +NextCRServo intakeServo = new NextCRServo("intakeServo"); ``` diff --git a/src/content/docs/hardware/actuators/feedback-servos.mdx b/src/content/docs/hardware/actuators/feedback-servos.mdx index 8809eb9..aaa70b2 100644 --- a/src/content/docs/hardware/actuators/feedback-servos.mdx +++ b/src/content/docs/hardware/actuators/feedback-servos.mdx @@ -7,7 +7,7 @@ sidebar: import { Tabs, TabItem } from '@astrojs/starlight/components'; -`NextFeedbackServo` and `NextFeedbackCRServo` pair a [`NextServo`](/reference/servos) or [`NextCRServo`](/reference/cr-servos) with an analog feedback input, for servos with a feedback wire (e.g. Axon). They inherit everything from their base class and add `angle` for reading the servo's actual physical angle. +`NextFeedbackServo` and `NextFeedbackCRServo` pair a [`NextServo`](/hardware/actuators/servos) or [`NextCRServo`](/hardware/actuators/cr-servos) with an analog feedback input, for servos with a feedback wire (e.g. Axon). They inherit everything from their base class and add `angle` for reading the servo's actual physical angle. ## Creating a feedback servo @@ -17,21 +17,26 @@ All of these below are interchangeable with `NextFeedbackCRServo`. ```kotlin -val armServo = NextFeedbackServo("armServo", AnalogFeedback(name = "armEncoder")) // By configuration name +// By configuration name +val armServo = NextFeedbackServo("armServo", NextAnalogInput("armEncoder")) -val armServo = NextFeedbackServo(RobotController.expansionHub, 0, AnalogFeedback(name = "armEncoder")) // By Lynx Module and port - -val armServo = NextFeedbackServo(RobotController.expansionHub, 0, NextAnalogInput(RobotController.expansionHub, 0)) // Full LynxModule +// By Lynx Module and port + NextAnalogInput +val armServo = NextFeedbackServo(RobotController.expansionHub, 0, NextAnalogInput("armEncoder")) +// Additionally, using a custom feedback method +val armServo = NextFeedbackServo("armServo", AnalogFeedback(voltageSupplier = { /* custom method here */ } )) ``` ```java -NextFeedbackServo armServo = new NextFeedbackServo("armServo", new AnalogFeedback("armEncoder")); // By configuration name +// By configuration name +NextFeedbackServo armServo = new NextFeedbackServo("armServo", new NextAnalogInput("armEncoder")); -NextFeedbackServo armServo = new NextFeedbackServo(RobotController.getExpansionHub(), 0, new AnalogFeedback("armEncoder")); // By Lynx Module and port +// By Lynx Module and port +NextFeedbackServo armServo = new NextFeedbackServo(RobotController.getExpansionHub(), 0, new NextAnalogInput("armEncoder")); -NextFeedbackServo armServo = new NextFeedbackServo(RobotController.getExpansionHub(), 0, new NextAnalogInput(RobotController.getExpansionHub(), 0)); // Full LynxModule +// Additionally, using a custom feedback method +NextFeedbackServo armServo = new NextFeedbackServo("armServo", new AnalogFeedback(/* tbd, idk java*/)) ``` diff --git a/src/content/docs/hardware/actuators/motors.mdx b/src/content/docs/hardware/actuators/motors.mdx new file mode 100644 index 0000000..d50537b --- /dev/null +++ b/src/content/docs/hardware/actuators/motors.mdx @@ -0,0 +1,211 @@ +--- +title: Motors +description: Control motors with NextMotor +sidebar: + order: 1 +--- + +import { Tabs, TabItem } from '@astrojs/starlight/components'; + +`NextMotor` is a lightweight wrapper around the standard FTC motor (`DcMotor` or `DcMotorEx`) that provides standard easy-to-use interface for throttling, voltage control, PIDS, and more + +## Creating a NextMotor +There are two main ways to construct a `NextMotor`, depending on what you desire. + + + +```kotlin +// By Lynx Module and port, recommended +val intakeMotor = NextMotor(RobotController.controlHub, 0) + +// Using a configuration name +val intakeMotor = NextMotor("intakeMotor") +``` + + +```java +// By Lynx Module and port, recommended +NextMotor intakeMotor = new NextMotor(RobotController.getControlHub(), 0); + +// Using a configuration name +NextMotor intakeMotor = new NextMotor("intakeMotor"); +``` + + + +All constructors accept two optional parameters: + +| Parameter | Type | Default | Description | +|---|---|---|---| +| `anglePerCount` | `Angle` | 1.0 rad | The angle that a motor's shaft rotates by for every 'tick' or 'count'. Used for calculations that directly convert 'ticks' to the number of rotations the motor has spun. | +| `cacheTolerance` | `Double` | `0.01` | Minimum change in `throttle` required before a new value is written to the motor. | + +## Usage +### Throttle Control + +Throttle Control allows the motor to be throttled from -1.0 (reverse) to 1.0 (full power). +The value represents a fraction of the robot's total voltage. + + + +```kotlin +// Adjust 1.0 to be what value you would like it to be +myMotor.throttle = 1.0 +``` + + +```java +// Adjust 1.0 to be what value you would like it to be +myMotor.setThrottle(1.0) +``` + + + +### Voltage Control + +Voltage Control allows the motor's power to be controlled more accurately and set to a specific voltage. + + + +```kotlin +// This function takes in a 'Voltage' +myMotor.voltage = 12.0.volts +``` + + +```java +// This function takes in a 'Voltage' +myMotor.setVoltage(volts.of(12)) +``` + + + +### Positional Control + +Positional control allows the motor's position to be controlled using a `PID` Controller + +You can change the default positional PID constants by doing: + + + +```kotlin +myMotor.positionConstants.apply { + kP = 0.1 +} +// Like kP, other positional PID constants include: +// kP, kI, kD, kS, kV, kA, kG, kCos, kCosRatio +``` + + +```java +myMotor.getPositionConstants() + .withP(0.1) +// Like kP, other positional PID constants include: +// kP, kI, kD, kS, kV, kA, kG, kCos, kCosRatio +``` + + + +#### Relative Positional Control +This moves the motor to the designated position **relative** to the position of the motor during the robot's startup. + + + +```kotlin +// Increase the target to be your desired angle from the initial position +myMotor.setPositionSetpoint(90.degrees) +``` + + +```java +// Increase the target to be your desired angle from the initial position +myMotor.setPositionSetpoint(degrees.of(90)) +``` + + + +#### Absolute Positional Control +This makes the motor take the shortest path, regardless of rotations to an angle in the range [-180, 180] degrees. + + + +```kotlin +// Increase the target to be your desired angle +myMotor.setAbsolutePositionSetpoint(90.degrees) +``` + + +```java +// Increase the target to be your desired angle +myMotor.setAbsolutePositionSetpoint(degrees.of(90)) +``` + + + +### Velocity Control +Similar to [Positional Control](#positional-control) velocity control allows the motor's velocity to be controlled using a `PID` Controller + + + +```kotlin +// Increase the target to be your desired angular velocity +myMotor.setVelocitySetpoint(30.degreesPerSecond) +``` + + +```java +// Increase the target to be your desired angular velocity +myMotor.setVelocitySetpoint(DegreesPerSecond.of(30)) +``` + + + +You can change the default velocity PID constants by doing: + + + +```kotlin +myMotor.velocityConstants.apply { + kP = 0.1 +} +// Like kP, other velocity PID constants include: +// kP, kI, kD, kS, kV, kA +``` + + +```java +myMotor.getVelocityConstants() + .withP(0.1) +// Like kP, other velocity PID constants include: +// kP, kI, kD, kS, kV, kA +``` + + + +### Following other motors +`NextMotor`'s have a helpful feature that allows one motor to 'follow' or mimic another motor. + +You can use this feature by doing: + + +```kotlin +myFollowerMotor.follow(myLeaderMotor) + +// Optional direction to specify whether it should follow in the same +// or opposite direction. +myFollowerMotor.follow(myLeaderMotor, Direction.REVERSE) +``` + + +```java +myFollowerMotor.follow(myLeaderMotor) + +// Optional direction to specify whether it should follow in the same +// or opposite direction. +myFollowerMotor.follow(myLeaderMotor, Direction.REVERSE) +``` + + + +### `Direction` +### `ZeroPowerBehaviour` \ No newline at end of file diff --git a/src/content/docs/hardware/actuators/servos.mdx b/src/content/docs/hardware/actuators/servos.mdx index 89b08f0..6477e63 100644 --- a/src/content/docs/hardware/actuators/servos.mdx +++ b/src/content/docs/hardware/actuators/servos.mdx @@ -11,21 +11,25 @@ import { Tabs, TabItem } from '@astrojs/starlight/components'; ## Creating a NextServo -There are three ways to construct a `NextServo`, depending on what you desire. +There are two main ways to construct a `NextServo`, depending on what you desire. ```kotlin -val armServo = NextServo(RobotController.controlHub, 0) // By Lynx Module and port, recommended + // By Lynx Module and port, recommended +val armServo = NextServo(RobotController.controlHub, 0) -val armServo = NextServo("armServo") // Using your configuration name +// Using a configuration name +val armServo = NextServo("armServo") ``` ```java -NextServo armServo = new NextServo(RobotController.getControlHub(), 0); // By Lynx Module and port, recommended + // By Lynx Module and port, recommended +NextServo armServo = new NextServo(RobotController.getControlHub(), 0); -NextServo armServo = new NextServo("armServo"); // Using your configuration name +// Using a configuration name +NextServo armServo = new NextServo("armServo"); ``` From 009f02a006b09310fcfd85123b6b7d92550e2e09 Mon Sep 17 00:00:00 2001 From: AchintyaAkula Date: Tue, 28 Jul 2026 18:41:36 -0700 Subject: [PATCH 2/7] Finished motor --- .idea/workspace.xml | 5 +---- src/content/docs/hardware/actuators/motors.mdx | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 8376c58..e394da0 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -17,11 +17,8 @@ - - - - + - - + Add a comment on line L20Add diff commentMarkdown input: edit mode selected.WritePreviewHeadingBoldItalicQuoteCodeLinkUnordered listNumbered listTask listMentionReferenceMore itemsSaved repliesAdd FilesPaste, drop, or click to add filesCancelCommentStart a review + + + + + From 2a3a73c59016b0325918ce11e76576b03aed609a Mon Sep 17 00:00:00 2001 From: AchintyaAkula Date: Tue, 28 Jul 2026 18:48:26 -0700 Subject: [PATCH 5/7] idea being bum --- .idea/workspace.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index f5acb8a..3e2c3fa 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -17,7 +17,7 @@ - Add a comment on line L20Add diff commentMarkdown input: edit mode selected.WritePreviewHeadingBoldItalicQuoteCodeLinkUnordered listNumbered listTask listMentionReferenceMore itemsSaved repliesAdd FilesPaste, drop, or click to add filesCancelCommentStart a review + From c849e0dadab4b0d008fb617292e17ed2a785fc77 Mon Sep 17 00:00:00 2001 From: AchintyaAkula Date: Tue, 28 Jul 2026 18:58:17 -0700 Subject: [PATCH 6/7] Fixed comments --- .idea/workspace.xml | 27 ++++++++++++++----- .../hardware/actuators/feedback-servos.mdx | 19 ++++++++----- .../hardware/miscellaneous/husky-lens.mdx | 6 +++-- .../hardware/miscellaneous/limelights.mdx | 6 +++-- .../hardware/miscellaneous/rgb-indicator.mdx | 12 ++++++--- .../docs/hardware/sensors/analog-inputs.mdx | 12 ++++++--- .../docs/hardware/sensors/color-sensor.mdx | 12 ++++++--- .../docs/hardware/sensors/digital-sensor.mdx | 12 ++++++--- .../docs/hardware/sensors/distance-sensor.mdx | 12 ++++++--- src/content/docs/hardware/sensors/imu.mdx | 12 ++++++--- .../docs/hardware/sensors/pinpoint.mdx | 12 ++++++--- 11 files changed, 97 insertions(+), 45 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 3e2c3fa..146e9ff 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -17,12 +17,17 @@ - - + + + + - - - + + + + + + - - - - + + - - - - - - + + +