Skip to content

Commit

Permalink
created interpolationUtil
Browse files Browse the repository at this point in the history
  • Loading branch information
Owen756 committed May 18, 2024
1 parent 7710add commit 23ae571
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/main/java/frc/robot/localization/InterpolationData.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.

package frc.robot.localization;

import edu.wpi.first.math.geometry.Pose2d;
import edu.wpi.first.math.geometry.Transform2d;

public record InterpolationData(
Pose2d measuredPose, Pose2d visionPose, Transform2d transform, String label) {
public InterpolationData(Pose2d measuredPose, Pose2d visionPose, String label) {
this(measuredPose, visionPose, new Transform2d(visionPose, measuredPose), label);
}
}
30 changes: 30 additions & 0 deletions src/main/java/frc/robot/localization/InterpolationUtil.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.

package frc.robot.localization;

import edu.wpi.first.math.geometry.Pose2d;
import java.util.List;

public class InterpolationUtil {
private static final InterpolationData SUBWOOFER = new InterpolationData(null, null, "Subwoofer");
private static final InterpolationData STAGE_FRONT =
new InterpolationData(null, null, "StageFront");
private static final InterpolationData STAGE_RIGHT =
new InterpolationData(null, null, "StageRight");
private static final InterpolationData STAGE_MIDDLE =
new InterpolationData(null, null, "StageMiddle");

private static final List<InterpolationData> DATA_POINTS =
List.of(SUBWOOFER, STAGE_FRONT, STAGE_RIGHT, STAGE_MIDDLE);

public static Pose2d interpolatePose(Pose2d visionInput) {
for (var dataPoint : DATA_POINTS) {
double distancePoint =
dataPoint.visionPose().getTranslation().getDistance(visionInput.getTranslation());
}

return new Pose2d();
}
}

0 comments on commit 23ae571

Please sign in to comment.