[wpimath] Remove WheelPositions interface/concept (#6771)

This commit is contained in:
Christopher Mahoney
2024-07-16 15:39:24 -04:00
committed by GitHub
parent 7d64d4e24c
commit 6c0429c263
10 changed files with 8 additions and 67 deletions

View File

@@ -8,7 +8,6 @@ import static edu.wpi.first.units.Units.Meters;
import edu.wpi.first.math.MathSharedStore;
import edu.wpi.first.math.MathUsageId;
import edu.wpi.first.math.MathUtil;
import edu.wpi.first.math.geometry.Twist2d;
import edu.wpi.first.math.kinematics.proto.DifferentialDriveKinematicsProto;
import edu.wpi.first.math.kinematics.struct.DifferentialDriveKinematicsStruct;
@@ -132,8 +131,6 @@ public class DifferentialDriveKinematics
DifferentialDriveWheelPositions startValue,
DifferentialDriveWheelPositions endValue,
double t) {
return new DifferentialDriveWheelPositions(
MathUtil.interpolate(startValue.leftMeters, endValue.leftMeters, t),
MathUtil.interpolate(startValue.rightMeters, endValue.rightMeters, t));
return startValue.interpolate(endValue, t);
}
}

View File

@@ -7,6 +7,7 @@ package edu.wpi.first.math.kinematics;
import static edu.wpi.first.units.Units.Meters;
import edu.wpi.first.math.MathUtil;
import edu.wpi.first.math.interpolation.Interpolatable;
import edu.wpi.first.math.kinematics.proto.DifferentialDriveWheelPositionsProto;
import edu.wpi.first.math.kinematics.struct.DifferentialDriveWheelPositionsStruct;
import edu.wpi.first.units.Distance;
@@ -15,7 +16,7 @@ import java.util.Objects;
/** Represents the wheel positions for a differential drive drivetrain. */
public class DifferentialDriveWheelPositions
implements WheelPositions<DifferentialDriveWheelPositions> {
implements Interpolatable<DifferentialDriveWheelPositions> {
/** Distance measured by the left side. */
public double leftMeters;
@@ -69,11 +70,6 @@ public class DifferentialDriveWheelPositions
"DifferentialDriveWheelPositions(Left: %.2f m, Right: %.2f m", leftMeters, rightMeters);
}
@Override
public DifferentialDriveWheelPositions copy() {
return new DifferentialDriveWheelPositions(leftMeters, rightMeters);
}
@Override
public DifferentialDriveWheelPositions interpolate(
DifferentialDriveWheelPositions endValue, double t) {

View File

@@ -6,7 +6,6 @@ package edu.wpi.first.math.kinematics;
import edu.wpi.first.math.MathSharedStore;
import edu.wpi.first.math.MathUsageId;
import edu.wpi.first.math.MathUtil;
import edu.wpi.first.math.geometry.Translation2d;
import edu.wpi.first.math.geometry.Twist2d;
import edu.wpi.first.math.kinematics.proto.MecanumDriveKinematicsProto;
@@ -277,10 +276,6 @@ public class MecanumDriveKinematics
@Override
public MecanumDriveWheelPositions interpolate(
MecanumDriveWheelPositions startValue, MecanumDriveWheelPositions endValue, double t) {
return new MecanumDriveWheelPositions(
MathUtil.interpolate(startValue.frontLeftMeters, endValue.frontLeftMeters, t),
MathUtil.interpolate(startValue.frontRightMeters, endValue.frontRightMeters, t),
MathUtil.interpolate(startValue.rearLeftMeters, endValue.rearLeftMeters, t),
MathUtil.interpolate(startValue.rearRightMeters, endValue.rearRightMeters, t));
return startValue.interpolate(endValue, t);
}
}

View File

@@ -7,6 +7,7 @@ package edu.wpi.first.math.kinematics;
import static edu.wpi.first.units.Units.Meters;
import edu.wpi.first.math.MathUtil;
import edu.wpi.first.math.interpolation.Interpolatable;
import edu.wpi.first.math.kinematics.proto.MecanumDriveWheelPositionsProto;
import edu.wpi.first.math.kinematics.struct.MecanumDriveWheelPositionsStruct;
import edu.wpi.first.units.Distance;
@@ -17,7 +18,7 @@ import java.util.Objects;
/** Represents the wheel positions for a mecanum drive drivetrain. */
public class MecanumDriveWheelPositions
implements WheelPositions<MecanumDriveWheelPositions>,
implements Interpolatable<MecanumDriveWheelPositions>,
ProtobufSerializable,
StructSerializable {
/** Distance measured by the front left wheel. */
@@ -99,12 +100,6 @@ public class MecanumDriveWheelPositions
frontLeftMeters, frontRightMeters, rearLeftMeters, rearRightMeters);
}
@Override
public MecanumDriveWheelPositions copy() {
return new MecanumDriveWheelPositions(
frontLeftMeters, frontRightMeters, rearLeftMeters, rearRightMeters);
}
@Override
public MecanumDriveWheelPositions interpolate(MecanumDriveWheelPositions endValue, double t) {
return new MecanumDriveWheelPositions(

View File

@@ -1,21 +0,0 @@
// 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 edu.wpi.first.math.kinematics;
import edu.wpi.first.math.interpolation.Interpolatable;
/**
* Interface for wheel positions.
*
* @param <T> Wheel positions type.
*/
public interface WheelPositions<T extends WheelPositions<T>> extends Interpolatable<T> {
/**
* Returns a copy of this instance.
*
* @return A copy.
*/
T copy();
}