From af0e77bc4b7dc7592ae5f260fafaed133ad5d3dc Mon Sep 17 00:00:00 2001 From: Rohit Shetty <138729620+28shettr@users.noreply.github.com> Date: Fri, 5 Jun 2026 19:15:37 -0500 Subject: [PATCH 1/5] Added documentation for distance, color, and digital sensors --- src/nextftc/hardware/sensors/color-sensors.md | 113 ++++++++++++++++++ .../hardware/sensors/digital-sensors.md | 76 ++++++++++++ .../hardware/sensors/distance-sensors.md | 53 ++++++++ 3 files changed, 242 insertions(+) create mode 100644 src/nextftc/hardware/sensors/color-sensors.md create mode 100644 src/nextftc/hardware/sensors/digital-sensors.md create mode 100644 src/nextftc/hardware/sensors/distance-sensors.md diff --git a/src/nextftc/hardware/sensors/color-sensors.md b/src/nextftc/hardware/sensors/color-sensors.md new file mode 100644 index 0000000..cbfa9ef --- /dev/null +++ b/src/nextftc/hardware/sensors/color-sensors.md @@ -0,0 +1,113 @@ +# Color Sensor + +`NextColorDistanceSensor` wraps a `NormalizedColorSensor` and an optional `DistanceSensor` to allow for color and distance readings; with the ability to use color matching in different color spaces. + +## Declarations + +:::tabs key:code + +== Kotlin +```kotlin +// Color only +val sensor = NextColorDistanceSensor("sensor_name") + +// With distance +val sensor = NextColorDistanceSensor("sensor_name", true) +``` + +== Java +```java +// Color only +NextColorDistanceSensor sensor = new NextColorDistanceSensor("sensor_name"); + +// With distance +NextColorDistanceSensor sensor = new NextColorDistanceSensor("sensor_name", true); +``` + +::: + +## Usage + +**Call `update()` once per loop before reading any values:** + +:::tabs key:code + +== Kotlin +```kotlin +override fun periodic() { + sensor.update() +} +``` + +== Java +```java +@Override +public void periodic() { + sensor.update(); +} +``` + +::: + + +### Distance + +See [Distance Sensor](./distance-sensors.md#usage) for usage — `NextColorDistanceSensor` exposes the same methods. + + +### Debug + +You can use `debug()` in telemetry to calibrate a `ColorProfile`: + +:::tabs key:code + +== Kotlin +```kotlin +// Outputs: RGB=(r,g,b) HSV=(h,s,v) Dist=d +telemetry.addLine(sensor.debug()) +``` + +== Java +```java +// Outputs: RGB=(r,g,b) HSV=(h,s,v) Dist=d +telemetry.addLine(sensor.debug()); +``` + +::: + +## ColorProfile + +`ColorProfile` describes a target color and per-channel tolerances. HSV is recommended as it is more stable under different lighting conditions. + +:::tabs key:code + +== Kotlin +```kotlin +val green = ColorProfile( + space = ColorSpace.HSV, //Desired Color Space (.HSV and .RGB both work) + color = NextColor.hsv(130f, 0.7f, 0.6f), //The target color you want (use desired space) + tolerance = NextColor.hsv(20f, 0.3f, 1f), //The tolerance of the target (use desired space) +) + +override fun periodic() { + sensor.update() + if (sensor.isColor(green)) { ... } +} +``` + +== Java +```java +ColorProfile green = new ColorProfile( + ColorSpace.HSV, //Desired Color Space (.HSV and .RGB both work) + NextColor.hsv(130f, 0.7f, 0.6f), //The target color you want (use desired space) + NextColor.hsv(20f, 0.3f, 1f) //The tolerance of the target (use desired space) +); + +@Override +public void periodic() { + sensor.update(); + if (sensor.isColor(green)) { ... } +} +``` + +::: diff --git a/src/nextftc/hardware/sensors/digital-sensors.md b/src/nextftc/hardware/sensors/digital-sensors.md new file mode 100644 index 0000000..5ed29a5 --- /dev/null +++ b/src/nextftc/hardware/sensors/digital-sensors.md @@ -0,0 +1,76 @@ +# Digital Sensor + +`NextDigitalSensor` wraps a `DigitalChannel` for reading digital sensors like limit switches, magnetic switches, +and beam breaks. + + +## Declarations +Most digital sensors are "active low" which means they read `false` +when triggered and `true` when idle. `NextDigitalSensor` handles this inversion automatically, +though it can be reverted if needed. Check your specific sensor specs for more info on it. + + +:::tabs key:code + +== Kotlin +```kotlin +val sensor = NextDigitalSensor("sensor_name") + +// Not inverted means active true +val sensor = NextDigitalSensor("sensor_name", inverted = false) +``` + +== Java +```java +NextDigitalSensor sensor = new NextDigitalSensor("sensor_name"); + +// Not inverted +NextDigitalSensor sensor = new NextDigitalSensor("sensor_name", false); +``` + +::: + +## Usage +`isTriggered` returns true when the sensor is activated, and `rawState` returns the raw state of the sensor +(raw state does not account for inversion). + +:::tabs key:code + +== Kotlin +```kotlin +if (sensor.isTriggered) { ... } + +// Raw state if needed +val raw = sensor.rawState +``` + +== Java +```java +if (sensor.isTriggered()) { ... } + +// Raw state if needed +boolean raw = sensor.getRawState(); +``` + +::: + +### Debug +Use `debug()` in telemetry to see the current triggered state, raw state, and whether inversion is enabled. +This is useful for verifying your sensor is wired and configured correctly. + + +:::tabs key:code + +== Kotlin +```kotlin +// Outputs: Sensor State: boolean, Raw State: boolean, Inverted: boolean +telemetry.addLine(sensor.debug()) +``` + +== Java +```java +// Outputs: Sensor State: boolean, Raw State: boolean, Inverted: boolean +telemetry.addLine(sensor.debug()); +``` + +::: \ No newline at end of file diff --git a/src/nextftc/hardware/sensors/distance-sensors.md b/src/nextftc/hardware/sensors/distance-sensors.md new file mode 100644 index 0000000..14d5215 --- /dev/null +++ b/src/nextftc/hardware/sensors/distance-sensors.md @@ -0,0 +1,53 @@ +# Distance Sensor + +`NextDistanceSensor` wraps a `DistanceSensor` to allow for readings and includes useful features. + +## Declarations + +:::tabs key:code + +== Kotlin +```kotlin +val sensor = NextDistanceSensor("sensor_name") +``` + +== Java +```java +NextDistanceSensor sensor = new NextDistanceSensor("sensor_name"); +``` + +::: + +## Usage +**Call `update()` once per loop before reading any values:** + +:::tabs key:code + +== Kotlin +```kotlin +override fun periodic() { + sensor.update() + + val cm = sensor.distance() + val inches = sensor.distance(DistanceUnit.INCH) + + if (sensor.isWithinDistance(2.0)) { ... } + if (sensor.isWithinDistance(2.0, DistanceUnit.INCH)) { ... } +} +``` + +== Java +```java +@Override +public void periodic() { + sensor.update(); + + double cm = sensor.distance(); + double inches = sensor.distance(DistanceUnit.INCH); + + if (sensor.isWithinDistance(2.0)) { ... } + if (sensor.isWithinDistance(2.0, DistanceUnit.INCH)) { ... } +} +``` + +::: \ No newline at end of file From da0b0586160b74a0655ab5b52458f23ebf040519 Mon Sep 17 00:00:00 2001 From: Rohit Shetty <138729620+28shettr@users.noreply.github.com> Date: Sat, 6 Jun 2026 11:14:41 -0500 Subject: [PATCH 2/5] Should be clean now --- .vitepress/sidebar/nextftc.mts | 17 ++++ src/nextftc/hardware/sensors/color-sensors.md | 82 +++++++++++++------ .../hardware/sensors/distance-sensors.md | 13 +-- 3 files changed, 79 insertions(+), 33 deletions(-) diff --git a/.vitepress/sidebar/nextftc.mts b/.vitepress/sidebar/nextftc.mts index 4f90130..6ffd21c 100644 --- a/.vitepress/sidebar/nextftc.mts +++ b/.vitepress/sidebar/nextftc.mts @@ -119,6 +119,23 @@ export default [ link: "/nextftc/hardware/motor-and-servo-commands/runtostate" } ] + }, + { + text: "Sensors and Webcams", + items: [ + { + text: "Color Sensors", + link: "/nextftc/hardware/sensors/color-sensors" + }, + { + text: "Distance Sensors", + link: "/nextftc/hardware/sensors/distance-sensors" + }, + { + text: "Digital Sensors", + link: "/nextftc/hardware/sensors/digital-sensors" + } + ] } ] }] satisfies SidebarItem[] \ No newline at end of file diff --git a/src/nextftc/hardware/sensors/color-sensors.md b/src/nextftc/hardware/sensors/color-sensors.md index cbfa9ef..73fdaf3 100644 --- a/src/nextftc/hardware/sensors/color-sensors.md +++ b/src/nextftc/hardware/sensors/color-sensors.md @@ -50,34 +50,8 @@ public void periodic() { ::: -### Distance - -See [Distance Sensor](./distance-sensors.md#usage) for usage — `NextColorDistanceSensor` exposes the same methods. - - -### Debug - -You can use `debug()` in telemetry to calibrate a `ColorProfile`: - -:::tabs key:code - -== Kotlin -```kotlin -// Outputs: RGB=(r,g,b) HSV=(h,s,v) Dist=d -telemetry.addLine(sensor.debug()) -``` - -== Java -```java -// Outputs: RGB=(r,g,b) HSV=(h,s,v) Dist=d -telemetry.addLine(sensor.debug()); -``` - -::: - ## ColorProfile - -`ColorProfile` describes a target color and per-channel tolerances. HSV is recommended as it is more stable under different lighting conditions. +`ColorProfile` defines a target color and tolerances for that target color. HSV is recommended because it is more stable under different lighting conditions, however RGB is also supported. :::tabs key:code @@ -109,5 +83,59 @@ public void periodic() { if (sensor.isColor(green)) { ... } } ``` +In this example, `.isColor(green)` returns true if the detected color falls within the target color's tolerance and false otherwise. You can use `debug()` to calibrate a target color and determine appropriate tolerance values. +::: + +### Color and Distance Features + +See [Distance Sensor](./distance-sensors.md#usage) for usage of distance methods, `NextColorDistanceSensor` exposes the same methods. + +:::tabs key:code + +== Kotlin +```kotlin +// Checks if the reading is within the tolerance of green +val isGreen = sensor.isColor(green) + +// Checks if the reading is within the tolerance of green and the object is within 4 cm +val isCloseToGreen = sensor.isColorWithinDistance(green, 4.0) + +// Checks if the reading is within the tolerance of green and the object is within 2 inches +val isCloseToGreenInches = sensor.isColorWithinDistance(green, 2.0, DistanceUnit.INCH) +``` + +== Java +```java +// Checks if the reading is within the tolerance of green +boolean isGreen = sensor.isColor(green); + +// Checks if the reading is within the tolerance of green and the object is within 4 cm +boolean isCloseToGreen = sensor.isColorWithinDistance(green, 4.0); + +// Checks if the reading is within the tolerance of green and the object is within 2 inches +boolean isCloseToGreenInches = sensor.isColorWithinDistance(green, 2.0, DistanceUnit.INCH); +``` +Any distance features will use centimeters by default ::: + +### Debug + +You can use `debug()` in telemetry to calibrate a `ColorProfile`: + +:::tabs key:code + +== Kotlin +```kotlin +// Outputs: RGB=(r,g,b) HSV=(h,s,v) Dist=d +telemetry.addLine(sensor.debug()) +``` + +== Java +```java +// Outputs: RGB=(r,g,b) HSV=(h,s,v) Dist=d +telemetry.addLine(sensor.debug()); +``` + +::: + diff --git a/src/nextftc/hardware/sensors/distance-sensors.md b/src/nextftc/hardware/sensors/distance-sensors.md index 14d5215..be03fc2 100644 --- a/src/nextftc/hardware/sensors/distance-sensors.md +++ b/src/nextftc/hardware/sensors/distance-sensors.md @@ -1,6 +1,6 @@ # Distance Sensor -`NextDistanceSensor` wraps a `DistanceSensor` to allow for readings and includes useful features. +`NextDistanceSensor` wraps a `DistanceSensor` and provides easy-to-use distance readings with built-in utility features. ## Declarations @@ -28,8 +28,8 @@ NextDistanceSensor sensor = new NextDistanceSensor("sensor_name"); override fun periodic() { sensor.update() - val cm = sensor.distance() - val inches = sensor.distance(DistanceUnit.INCH) + val cm = sensor.getDistance() + val inches = sensor.getDistance(DistanceUnit.INCH) if (sensor.isWithinDistance(2.0)) { ... } if (sensor.isWithinDistance(2.0, DistanceUnit.INCH)) { ... } @@ -42,12 +42,13 @@ override fun periodic() { public void periodic() { sensor.update(); - double cm = sensor.distance(); - double inches = sensor.distance(DistanceUnit.INCH); + double cm = sensor.getDistance(); + double inches = sensor.getDistance(DistanceUnit.INCH); if (sensor.isWithinDistance(2.0)) { ... } if (sensor.isWithinDistance(2.0, DistanceUnit.INCH)) { ... } } ``` - +`sensor.isWithinDistance(2.0)` returns true if the distance is within 2 cm, if a unit is specified, it will use that unit. +Any distance features will use centimeters by default ::: \ No newline at end of file From 3b6f03bed3d0a55d837287b1f75efe72bfa06864 Mon Sep 17 00:00:00 2001 From: Rohit Shetty <138729620+28shettr@users.noreply.github.com> Date: Sat, 6 Jun 2026 11:25:24 -0500 Subject: [PATCH 3/5] updated package name --- .../hardware/{sensors => sensors-and-webcams}/color-sensors.md | 0 .../hardware/{sensors => sensors-and-webcams}/digital-sensors.md | 0 .../hardware/{sensors => sensors-and-webcams}/distance-sensors.md | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename src/nextftc/hardware/{sensors => sensors-and-webcams}/color-sensors.md (100%) rename src/nextftc/hardware/{sensors => sensors-and-webcams}/digital-sensors.md (100%) rename src/nextftc/hardware/{sensors => sensors-and-webcams}/distance-sensors.md (100%) diff --git a/src/nextftc/hardware/sensors/color-sensors.md b/src/nextftc/hardware/sensors-and-webcams/color-sensors.md similarity index 100% rename from src/nextftc/hardware/sensors/color-sensors.md rename to src/nextftc/hardware/sensors-and-webcams/color-sensors.md diff --git a/src/nextftc/hardware/sensors/digital-sensors.md b/src/nextftc/hardware/sensors-and-webcams/digital-sensors.md similarity index 100% rename from src/nextftc/hardware/sensors/digital-sensors.md rename to src/nextftc/hardware/sensors-and-webcams/digital-sensors.md diff --git a/src/nextftc/hardware/sensors/distance-sensors.md b/src/nextftc/hardware/sensors-and-webcams/distance-sensors.md similarity index 100% rename from src/nextftc/hardware/sensors/distance-sensors.md rename to src/nextftc/hardware/sensors-and-webcams/distance-sensors.md From 8692ba787b5a2403a954e95c2b80f407aacf799d Mon Sep 17 00:00:00 2001 From: Rohit Shetty <138729620+28shettr@users.noreply.github.com> Date: Sat, 6 Jun 2026 12:26:35 -0500 Subject: [PATCH 4/5] Added limelight.md and cleaned up sensors files --- .vitepress/sidebar/nextftc.mts | 11 ++- .../sensors-and-webcams/color-sensors.md | 10 ++- .../sensors-and-webcams/digital-sensors.md | 11 ++- .../sensors-and-webcams/distance-sensors.md | 4 +- .../hardware/sensors-and-webcams/limelight.md | 89 +++++++++++++++++++ 5 files changed, 113 insertions(+), 12 deletions(-) create mode 100644 src/nextftc/hardware/sensors-and-webcams/limelight.md diff --git a/.vitepress/sidebar/nextftc.mts b/.vitepress/sidebar/nextftc.mts index 6ffd21c..8e3d171 100644 --- a/.vitepress/sidebar/nextftc.mts +++ b/.vitepress/sidebar/nextftc.mts @@ -125,16 +125,21 @@ export default [ items: [ { text: "Color Sensors", - link: "/nextftc/hardware/sensors/color-sensors" + link: "/nextftc/hardware/sensors-and-webcams/color-sensors" }, { text: "Distance Sensors", - link: "/nextftc/hardware/sensors/distance-sensors" + link: "/nextftc/hardware/sensors-and-webcams/distance-sensors" }, { text: "Digital Sensors", - link: "/nextftc/hardware/sensors/digital-sensors" + link: "/nextftc/hardware/sensors-and-webcams/digital-sensors" + }, + { + text: "Limelight", + link: "/nextftc/hardware/sensors-and-webcams/limelight" } + ] } ] diff --git a/src/nextftc/hardware/sensors-and-webcams/color-sensors.md b/src/nextftc/hardware/sensors-and-webcams/color-sensors.md index 73fdaf3..e95da6a 100644 --- a/src/nextftc/hardware/sensors-and-webcams/color-sensors.md +++ b/src/nextftc/hardware/sensors-and-webcams/color-sensors.md @@ -1,6 +1,6 @@ # Color Sensor -`NextColorDistanceSensor` wraps a `NormalizedColorSensor` and an optional `DistanceSensor` to allow for color and distance readings; with the ability to use color matching in different color spaces. +`NextColorDistanceSensor` wraps a `NormalizedColorSensor` and an optional `DistanceSensor` providing color and distance readings with support for color matching in multiple color spaces. ## Declarations @@ -53,6 +53,7 @@ public void periodic() { ## ColorProfile `ColorProfile` defines a target color and tolerances for that target color. HSV is recommended because it is more stable under different lighting conditions, however RGB is also supported. + :::tabs key:code == Kotlin @@ -68,6 +69,7 @@ override fun periodic() { if (sensor.isColor(green)) { ... } } ``` +In this example, `.isColor(green)` returns true if the detected color falls within the target color's tolerance and false otherwise. == Java ```java @@ -83,9 +85,12 @@ public void periodic() { if (sensor.isColor(green)) { ... } } ``` -In this example, `.isColor(green)` returns true if the detected color falls within the target color's tolerance and false otherwise. You can use `debug()` to calibrate a target color and determine appropriate tolerance values. +In this example, `.isColor(green)` returns true if the detected color falls within the target color's tolerance and false otherwise. ::: +You can use [`debug()`](./color-sensors.md#debug) to calibrate a target color and determine appropriate tolerance values. + + ### Color and Distance Features See [Distance Sensor](./distance-sensors.md#usage) for usage of distance methods, `NextColorDistanceSensor` exposes the same methods. @@ -103,6 +108,7 @@ val isCloseToGreen = sensor.isColorWithinDistance(green, 4.0) // Checks if the reading is within the tolerance of green and the object is within 2 inches val isCloseToGreenInches = sensor.isColorWithinDistance(green, 2.0, DistanceUnit.INCH) ``` +Any distance features will use centimeters by default == Java ```java diff --git a/src/nextftc/hardware/sensors-and-webcams/digital-sensors.md b/src/nextftc/hardware/sensors-and-webcams/digital-sensors.md index 5ed29a5..96ac41f 100644 --- a/src/nextftc/hardware/sensors-and-webcams/digital-sensors.md +++ b/src/nextftc/hardware/sensors-and-webcams/digital-sensors.md @@ -7,7 +7,7 @@ and beam breaks. ## Declarations Most digital sensors are "active low" which means they read `false` when triggered and `true` when idle. `NextDigitalSensor` handles this inversion automatically, -though it can be reverted if needed. Check your specific sensor specs for more info on it. +though it can be reverted if needed. Check your sensors documentation for more info on it. :::tabs key:code @@ -16,7 +16,7 @@ though it can be reverted if needed. Check your specific sensor specs for more i ```kotlin val sensor = NextDigitalSensor("sensor_name") -// Not inverted means active true +// Not inverted (active high) val sensor = NextDigitalSensor("sensor_name", inverted = false) ``` @@ -24,14 +24,14 @@ val sensor = NextDigitalSensor("sensor_name", inverted = false) ```java NextDigitalSensor sensor = new NextDigitalSensor("sensor_name"); -// Not inverted +// Not inverted (active high) NextDigitalSensor sensor = new NextDigitalSensor("sensor_name", false); ``` ::: ## Usage -`isTriggered` returns true when the sensor is activated, and `rawState` returns the raw state of the sensor +`isTriggered` returns `true` when the sensor is activated, and `rawState` returns the raw state of the sensor (raw state does not account for inversion). :::tabs key:code @@ -55,8 +55,7 @@ boolean raw = sensor.getRawState(); ::: ### Debug -Use `debug()` in telemetry to see the current triggered state, raw state, and whether inversion is enabled. -This is useful for verifying your sensor is wired and configured correctly. +Use `debug()` in telemetry to see the current triggered state, raw state, and whether inversion is `true`. :::tabs key:code diff --git a/src/nextftc/hardware/sensors-and-webcams/distance-sensors.md b/src/nextftc/hardware/sensors-and-webcams/distance-sensors.md index be03fc2..afcd629 100644 --- a/src/nextftc/hardware/sensors-and-webcams/distance-sensors.md +++ b/src/nextftc/hardware/sensors-and-webcams/distance-sensors.md @@ -35,6 +35,7 @@ override fun periodic() { if (sensor.isWithinDistance(2.0, DistanceUnit.INCH)) { ... } } ``` +`sensor.isWithinDistance(2.0)` returns true if the distance is within 2 cm, if a unit is specified, it will use that unit. == Java ```java @@ -50,5 +51,6 @@ public void periodic() { } ``` `sensor.isWithinDistance(2.0)` returns true if the distance is within 2 cm, if a unit is specified, it will use that unit. +::: + Any distance features will use centimeters by default -::: \ No newline at end of file diff --git a/src/nextftc/hardware/sensors-and-webcams/limelight.md b/src/nextftc/hardware/sensors-and-webcams/limelight.md new file mode 100644 index 0000000..7b14144 --- /dev/null +++ b/src/nextftc/hardware/sensors-and-webcams/limelight.md @@ -0,0 +1,89 @@ +# Limelight + +`NextLimelight` wraps a `Limelight3A` making it easier to start the camera, switch pipelines, and retrieve robot pose and target data. + + +## Declarations + +:::tabs key:code + +== Kotlin +```kotlin +val limelight = NextLimelight("limelight") +``` + +== Java +```java +NextLimelight limelight = new NextLimelight("limelight"); +``` + +::: + +## Usage + +### Starting and Stopping + +:::tabs key:code + +== Kotlin +```kotlin +limelight.startReading(pipeline = 0) // default 100 Hz +limelight.startReading(pipeline = 0, hz = 50) + +limelight.stop() +``` + +== Java +```java +limelight.startReading(0); //sets pipeline to 0 and defaults 100 Hz +limelight.startReading(0, 50); //sets pipeline to 0 and 50 Hz + +limelight.stop(); +``` + +::: + +### Distance + +Returns the straight-line distance (hypotenuse) to an AprilTag. +If no unit is specified, inches are used by default. + +:::tabs key:code + +== Kotlin +```kotlin +val dist = limelight.getDistance() // default: inches +val cm = limelight.getDistance(DistanceUnit.CM) +val inches = limelight.getDistance(id = 20) // specific tag, inches +val cm3 = limelight.getDistance(DistanceUnit.CM, id = 3) +``` + +== Java +```java +double dist = limelight.getDistance(); // default: inches +double cm = limelight.getDistance(DistanceUnit.CM); +double inches = limelight.getDistance(DistanceUnit.CM, 20); // specific tag, and in CM +``` +::: +If a specfic ID is not given the distance will be calculated using any detected april tag. + + +## Relocalization + +`getPedroPoseFromLimelight()` returns the robot's field position as a `Pose2d` in [Pedro coordinates](https://pedropathing.com/docs/pathing/reference/coordinates), or `null` if no valid pose is available. + +:::tabs key:code + +== Kotlin +```kotlin +val pose = limelight.getPedroPoseFromLimelight() ?: return +``` +This method uses any detected AprilTag. It is recommended to exclude unwanted tags in the Limelight pipeline. + +== Java +```java +Pose2d pose = limelight.getPedroPoseFromLimelight(); +if (pose == null) return; +``` +This method uses any detected AprilTag. It is recommended to exclude unwanted tags in the Limelight pipeline. +::: \ No newline at end of file From fdb8713e0460b4eb9e94dfb3c8125dc0ea21c965 Mon Sep 17 00:00:00 2001 From: Rohit Shetty <138729620+28shettr@users.noreply.github.com> Date: Sat, 6 Jun 2026 13:11:08 -0500 Subject: [PATCH 5/5] husky-lens.md added --- .vitepress/sidebar/nextftc.mts | 5 ++ .../sensors-and-webcams/husky-lens.md | 60 +++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 src/nextftc/hardware/sensors-and-webcams/husky-lens.md diff --git a/.vitepress/sidebar/nextftc.mts b/.vitepress/sidebar/nextftc.mts index 8e3d171..26ccbc4 100644 --- a/.vitepress/sidebar/nextftc.mts +++ b/.vitepress/sidebar/nextftc.mts @@ -138,8 +138,13 @@ export default [ { text: "Limelight", link: "/nextftc/hardware/sensors-and-webcams/limelight" + }, + { + text: "HuskyLens", + link: "/nextftc/hardware/sensors-and-webcams/husky-lens" } + ] } ] diff --git a/src/nextftc/hardware/sensors-and-webcams/husky-lens.md b/src/nextftc/hardware/sensors-and-webcams/husky-lens.md new file mode 100644 index 0000000..c428ac8 --- /dev/null +++ b/src/nextftc/hardware/sensors-and-webcams/husky-lens.md @@ -0,0 +1,60 @@ +# HuskyLens +`NextHuskyLens` wraps a `HuskyLens`, providing convenient methods for selecting algorithms and reading detecting objects. + +## Declarations + +:::tabs key:code + +== Kotlin +```kotlin +val huskyLens = NextHuskyLens("husky_lens") +``` + +== Java +```java +NextHuskyLens huskyLens = new NextHuskyLens("husky_lens"); +``` + +::: + +## Usage + +### Setup + +Call `selectAlgorithm()` once on startup to set the recognition mode, and `knock()` to verify the sensor is responding: + +:::tabs key:code + +== Kotlin +```kotlin +huskyLens.selectAlgorithm(HuskyLens.Algorithm.TAG_RECOGNITION) // or any desired algorithm +val connected = huskyLens.knock() +``` + +== Java +```java +huskyLens.selectAlgorithm(HuskyLens.Algorithm.TAG_RECOGNITION); // or any desired algorithm +boolean connected = huskyLens.knock(); +``` + +::: + +### Blocks and Arrows + +`blocks()` and `arrows()` return up to 6 currently visible results. Pass an ID to filter for a specific learned object. + +:::tabs key:code + +== Kotlin +```kotlin +val all = huskyLens.blocks() +val filtered = huskyLens.blocks(1) +``` + +== Java +```java +HuskyLens.Block[] all = huskyLens.blocks(); +HuskyLens.Block[] filtered = huskyLens.blocks(1); +``` +::: +