|
| 1 | +--- |
| 2 | +title: Limelights |
| 3 | +description: Reading AprilTags and pose data with NextLimelight |
| 4 | +sidebar: |
| 5 | + order: 1 |
| 6 | +--- |
| 7 | + |
| 8 | +import { Tabs, TabItem } from '@astrojs/starlight/components'; |
| 9 | + |
| 10 | +`NextLimelight` is a wrapper around the [Limelight3A](https://limelightvision.io/products/limelight-3a) that initializes the device lazily from the hardware map. While creating many useful methods. Any data that is not wrapped can be accessed through `camera`. |
| 11 | + |
| 12 | + |
| 13 | +## Creating a NextLimelight |
| 14 | + |
| 15 | +<Tabs syncKey="language"> |
| 16 | +<TabItem label="Kotlin"> |
| 17 | +```kotlin |
| 18 | +val limelight = NextLimelight("limelight") // Using your configuration name |
| 19 | +``` |
| 20 | +</TabItem> |
| 21 | +<TabItem label="Java"> |
| 22 | +```java |
| 23 | +NextLimelight limelight = new NextLimelight("limelight"); // Using your configuration name |
| 24 | +``` |
| 25 | +</TabItem> |
| 26 | +</Tabs> |
| 27 | + |
| 28 | +## Usage |
| 29 | + |
| 30 | +### `startReading(pipeline, hz)` |
| 31 | + |
| 32 | +Sets the poll rate and pipeline, then starts polling, all in one call. |
| 33 | + |
| 34 | +<Tabs syncKey="language"> |
| 35 | +<TabItem label="Kotlin"> |
| 36 | +```kotlin |
| 37 | +limelight.startReading(pipeline = 0, hz = 100) |
| 38 | +``` |
| 39 | +</TabItem> |
| 40 | +<TabItem label="Java"> |
| 41 | +```java |
| 42 | +limelight.startReading(0, 100); |
| 43 | +``` |
| 44 | +</TabItem> |
| 45 | +</Tabs> |
| 46 | + |
| 47 | +### `getDistance(unit, id)` |
| 48 | + |
| 49 | +Returns the straight-line distance (hypotenuse) from the robot to the AprilTag for the matching `id` (or any visible tag if `id` is `null`), in the given unit or `null` if no valid tag is available. |
| 50 | + |
| 51 | +<Tabs syncKey="language"> |
| 52 | +<TabItem label="Kotlin"> |
| 53 | +```kotlin |
| 54 | +val distance = limelight.getDistance(id = 7) //Defaults to Inches |
| 55 | +if (distance != null) { |
| 56 | + // ... |
| 57 | +} |
| 58 | +``` |
| 59 | +</TabItem> |
| 60 | +<TabItem label="Java"> |
| 61 | +```java |
| 62 | +Distance distance = limelight.getDistance(Inches.INSTANCE, 7); //Defaults to Inches |
| 63 | +if (distance != null) { |
| 64 | + // ... |
| 65 | +} |
| 66 | +``` |
| 67 | +</TabItem> |
| 68 | +</Tabs> |
| 69 | + |
| 70 | +### `getPose()` |
| 71 | + |
| 72 | +Returns the robot's field position in [FTC coordinates](https://ftc-docs.firstinspires.org/en/latest/game_specific_resources/field_coordinate_system/field-coordinate-system.html), or `null` if no valid pose is available. |
| 73 | + |
| 74 | +<Tabs syncKey="language"> |
| 75 | +<TabItem label="Kotlin"> |
| 76 | +```kotlin |
| 77 | +val pose = limelight.getPose() |
| 78 | +if (pose != null) { |
| 79 | + // ... |
| 80 | +} |
| 81 | +``` |
| 82 | +</TabItem> |
| 83 | +<TabItem label="Java"> |
| 84 | +```java |
| 85 | +Pose2d pose = limelight.getPose(); |
| 86 | +if (pose != null) { |
| 87 | + // ... |
| 88 | +} |
| 89 | +``` |
| 90 | +</TabItem> |
| 91 | +</Tabs> |
| 92 | + |
| 93 | +### `getPedroPose()` |
| 94 | + |
| 95 | +Returns the robot's field position in [Pedro coordinates](https://pedropathing.com/docs/pathing/reference/coordinates), or `null` if no valid pose is available. |
| 96 | + |
| 97 | +<Tabs syncKey="language"> |
| 98 | +<TabItem label="Kotlin"> |
| 99 | +```kotlin |
| 100 | +val pose = limelight.getPedroPose() |
| 101 | +if (pose != null) { |
| 102 | + // ... |
| 103 | +} |
| 104 | +``` |
| 105 | +</TabItem> |
| 106 | +<TabItem label="Java"> |
| 107 | +```java |
| 108 | +Pose2d pose = limelight.getPedroPose(); |
| 109 | +if (pose != null) { |
| 110 | + // ... |
| 111 | +} |
| 112 | +``` |
| 113 | +</TabItem> |
| 114 | +</Tabs> |
0 commit comments