Skip to content

Commit f09a09b

Browse files
committed
rely far less on limelighthelpers
1 parent acab603 commit f09a09b

File tree

1 file changed

+12
-18
lines changed
  • src/main/kotlin/com/frcteam3636/bunnybots2025/subsystems/drivetrain

1 file changed

+12
-18
lines changed

src/main/kotlin/com/frcteam3636/bunnybots2025/subsystems/drivetrain/AbsolutePose.kt

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ package com.frcteam3636.bunnybots2025.subsystems.drivetrain
66
//import org.photonvision.PhotonPoseEstimator
77
import com.frcteam3636.bunnybots2025.Robot
88
import com.frcteam3636.bunnybots2025.RobotState
9-
import com.frcteam3636.bunnybots2025.utils.LimelightHelpers
109
import com.frcteam3636.bunnybots2025.utils.LimelightHelpers.convertToLLPoseEstimate
1110
import com.frcteam3636.bunnybots2025.utils.math.degrees
1211
import com.frcteam3636.bunnybots2025.utils.math.inSeconds
@@ -84,7 +83,7 @@ data class LimelightMeasurement(
8483
} /* --- END KOTLIN COMPILER GENERATED CODE ---- */
8584

8685
class LimelightPoseProvider(
87-
private val name: String,
86+
name: String,
8887
private val yawGetter: () -> Rotation2d,
8988
private val velocityGetter: () -> AngularVelocity,
9089
private val isLL4: Boolean
@@ -107,6 +106,9 @@ class LimelightPoseProvider(
107106
private var megatag1Subscriber = table.getDoubleArrayTopic("botpose_wpiblue").subscribe(doubleArrayOf())
108107
private var megatag2Subscriber =
109108
table.getDoubleArrayTopic("botpose_orb_wpiblue").subscribe(doubleArrayOf())
109+
private val gyroPublisher = table.getDoubleArrayTopic("robot_orientation_set").publish()
110+
private val throttlePublisher = table.getIntegerTopic("throttle_set").publish()
111+
private val imuModePublisher = table.getIntegerTopic("imumode_set").publish()
110112
private var loopsSinceLastSeen: Int = 0
111113

112114
private var isThrottled = false
@@ -143,33 +145,25 @@ class LimelightPoseProvider(
143145
var measurements: Array<LimelightMeasurement> = emptyArray()
144146

145147
if (!isLL4) {
146-
LimelightHelpers.SetRobotOrientation(
147-
name,
148-
gyroAngle.degrees,
149-
// The Limelight sample code leaves these as zero, and the API docs call them "Unnecessary."
150-
0.0, 0.0, 0.0, 0.0, 0.0
151-
)
148+
gyroPublisher.accept(doubleArrayOf(gyroAngle.degrees, 0.0, 0.0, 0.0, 0.0, 0.0))
149+
NetworkTableInstance.getDefault().flush()
152150
} else {
153151
if (RobotState.beforeFirstEnable) {
154-
LimelightHelpers.SetIMUMode(name, 1)
155-
LimelightHelpers.SetRobotOrientation(
156-
name,
157-
gyroAngle.degrees,
158-
// The Limelight sample code leaves these as zero, and the API docs call them "Unnecessary."
159-
0.0, 0.0, 0.0, 0.0, 0.0
160-
)
152+
imuModePublisher.accept(1.toLong())
153+
gyroPublisher.accept(doubleArrayOf(gyroAngle.degrees, 0.0, 0.0, 0.0, 0.0, 0.0))
154+
NetworkTableInstance.getDefault().flush()
161155
}
162156
if (Robot.isDisabled && !isThrottled) {
163-
LimelightHelpers.SetThrottle(name, 100)
157+
throttlePublisher.accept(100.toLong())
164158
isThrottled = true
165159
} else if (Robot.isEnabled && isThrottled) {
166-
LimelightHelpers.SetThrottle(name, 0)
160+
throttlePublisher.accept(0.toLong())
167161
}
168162
}
169163

170164
if ((!RobotState.beforeFirstEnable)) {
171165
if (isLL4 && !wasIMUChanged) {
172-
LimelightHelpers.SetIMUMode(name, 3)
166+
imuModePublisher.accept(3.toLong())
173167
wasIMUChanged = true
174168
}
175169
}

0 commit comments

Comments
 (0)