Skip to content

Commit 5d0efe6

Browse files
committed
Implement drive.getPoseEstimate()
1 parent fbaac4a commit 5d0efe6

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/main/kotlin/com/noahbres/meepmeep/roadrunner/DriveShim.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import com.acmerobotics.roadrunner.trajectory.constraints.*
66
import com.noahbres.meepmeep.roadrunner.trajectorysequence.TrajectorySequenceBuilder
77
import java.util.*
88

9-
class DriveShim(driveTrainType: DriveTrainType, private val constraints: Constraints) {
9+
class DriveShim(driveTrainType: DriveTrainType, private val constraints: Constraints, var poseEstimate: Pose2d) {
1010
private val velConstraint = when (driveTrainType) {
1111
DriveTrainType.MECANUM -> MinVelocityConstraint(
1212
listOf(

src/main/kotlin/com/noahbres/meepmeep/roadrunner/entity/RoadRunnerBotEntity.kt

+5-3
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class RoadRunnerBotEntity(
3232
override var zIndex: Int = 0
3333

3434
private var driveTrainType = DriveTrainType.MECANUM
35-
var drive = DriveShim(driveTrainType, constraints)
35+
var drive = DriveShim(driveTrainType, constraints, pose)
3636

3737
var currentTrajectorySequence: TrajectorySequence? = null
3838

@@ -101,6 +101,8 @@ class RoadRunnerBotEntity(
101101
else -> currentTrajectorySequence!!.end
102102
}
103103

104+
drive.poseEstimate = pose;
105+
104106
trajectorySequenceEntity!!.markerEntityList.forEach { if (trajectorySequenceElapsedTime >= it.time) it.passed() }
105107

106108
progressSlider.progress = (trajectorySequenceElapsedTime / currentTrajectorySequence!!.duration)
@@ -152,13 +154,13 @@ class RoadRunnerBotEntity(
152154
fun setConstraints(constraints: Constraints) {
153155
this.constraints = constraints
154156

155-
drive = DriveShim(driveTrainType, constraints)
157+
drive = DriveShim(driveTrainType, constraints, pose)
156158
}
157159

158160
fun setDriveTrainType(driveTrainType: DriveTrainType) {
159161
this.driveTrainType = driveTrainType
160162

161-
drive = DriveShim(driveTrainType, constraints)
163+
drive = DriveShim(driveTrainType, constraints, pose)
162164
}
163165

164166
override fun switchScheme(scheme: ColorScheme) {

0 commit comments

Comments
 (0)