|
| 1 | +--- |
| 2 | +title: Pinpoint |
| 3 | +description: Reading odometry with NextPinpoint |
| 4 | +sidebar: |
| 5 | + order: 4 |
| 6 | +--- |
| 7 | + |
| 8 | +import { Tabs, TabItem } from '@astrojs/starlight/components'; |
| 9 | + |
| 10 | +`NextPinpoint` is a wrapper for the [goBILDA Pinpoint Odometry Computer](https://www.gobilda.com/pinpoint-odometry-computer-imu-sensor-fusion-for-2-wheel-odometry/) that uses lazy initialization. |
| 11 | + |
| 12 | +## Creating a NextPinpoint |
| 13 | + |
| 14 | +<Tabs syncKey="language"> |
| 15 | +<TabItem label="Kotlin"> |
| 16 | +```kotlin |
| 17 | +val pinpoint = NextPinpoint(RobotController.controlHub, 0) // By Lynx Module and I2C bus |
| 18 | + |
| 19 | +val pinpoint = NextPinpoint("pinpoint") // Using your configuration name |
| 20 | +``` |
| 21 | +</TabItem> |
| 22 | +<TabItem label="Java"> |
| 23 | +```java |
| 24 | +NextPinpoint pinpoint = new NextPinpoint(RobotController.getControlHub(), 0); // By Lynx Module and I2C bus |
| 25 | + |
| 26 | +NextPinpoint pinpoint = new NextPinpoint("pinpoint"); // Using your configuration name |
| 27 | +``` |
| 28 | +</TabItem> |
| 29 | +</Tabs> |
| 30 | + |
| 31 | + |
| 32 | +## Usage |
| 33 | + |
| 34 | +### `update()` |
| 35 | + |
| 36 | +Updates the position data from the device. Call this each loop, you can put this in your `periodic` for your `Mechanism`. |
| 37 | + |
| 38 | +<Tabs syncKey="language"> |
| 39 | +<TabItem label="Kotlin"> |
| 40 | +```kotlin |
| 41 | +pinpoint.update() |
| 42 | +``` |
| 43 | +</TabItem> |
| 44 | +<TabItem label="Java"> |
| 45 | +```java |
| 46 | +pinpoint.update(); |
| 47 | +``` |
| 48 | +</TabItem> |
| 49 | +</Tabs> |
| 50 | + |
| 51 | +### `pose` |
| 52 | + |
| 53 | +`Pose2d` this is the robot's current position and heading, in inches and radians. |
| 54 | + |
| 55 | +<Tabs syncKey="language"> |
| 56 | +<TabItem label="Kotlin"> |
| 57 | +```kotlin |
| 58 | +val currentPose = pinpoint.pose |
| 59 | +``` |
| 60 | +</TabItem> |
| 61 | +<TabItem label="Java"> |
| 62 | +```java |
| 63 | +Pose2d currentPose = pinpoint.getPose(); |
| 64 | +``` |
| 65 | +</TabItem> |
| 66 | +</Tabs> |
| 67 | + |
| 68 | +### `velocity` |
| 69 | + |
| 70 | +`PoseVelocity2d` this is the robot's current translational and heading velocity. |
| 71 | + |
| 72 | +<Tabs syncKey="language"> |
| 73 | +<TabItem label="Kotlin"> |
| 74 | +```kotlin |
| 75 | +val currentVelocity = pinpoint.velocity |
| 76 | +``` |
| 77 | +</TabItem> |
| 78 | +<TabItem label="Java"> |
| 79 | +```java |
| 80 | +PoseVelocity2d currentVelocity = pinpoint.getVelocity(); |
| 81 | +``` |
| 82 | +</TabItem> |
| 83 | +</Tabs> |
| 84 | + |
| 85 | +### `resetPosAndIMU()` |
| 86 | + |
| 87 | +Resets the odometry position tracking. |
| 88 | + |
| 89 | +<Tabs syncKey="language"> |
| 90 | +<TabItem label="Kotlin"> |
| 91 | +```kotlin |
| 92 | +pinpoint.resetPosAndIMU() |
| 93 | +``` |
| 94 | +</TabItem> |
| 95 | +<TabItem label="Java"> |
| 96 | +```java |
| 97 | +pinpoint.resetPosAndIMU(); |
| 98 | +``` |
| 99 | +</TabItem> |
| 100 | +</Tabs> |
0 commit comments