From 96a0e18dc998421ce87f7095425528529e4b593c Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Tue, 23 Jan 2024 16:59:39 -0500 Subject: [PATCH] Expose required methods --- .../subsystems/swerve/AbstractSwerveDrive.java | 7 ++++++- .../robot/subsystems/swerve/SwerveDrive.java | 14 ++++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/stuypulse/robot/subsystems/swerve/AbstractSwerveDrive.java b/src/main/java/com/stuypulse/robot/subsystems/swerve/AbstractSwerveDrive.java index 0b1970dd..52ab631e 100644 --- a/src/main/java/com/stuypulse/robot/subsystems/swerve/AbstractSwerveDrive.java +++ b/src/main/java/com/stuypulse/robot/subsystems/swerve/AbstractSwerveDrive.java @@ -6,8 +6,10 @@ import com.stuypulse.robot.constants.Settings.Swerve.FrontLeft; import com.stuypulse.robot.constants.Settings.Swerve.FrontRight; +import edu.wpi.first.math.geometry.Rotation2d; import edu.wpi.first.math.geometry.Translation2d; import edu.wpi.first.math.kinematics.ChassisSpeeds; +import edu.wpi.first.math.kinematics.SwerveDriveKinematics; import edu.wpi.first.math.kinematics.SwerveModulePosition; import edu.wpi.first.math.kinematics.SwerveModuleState; import edu.wpi.first.wpilibj.smartdashboard.Field2d; @@ -31,7 +33,8 @@ public static AbstractSwerveDrive getInstance() { } public abstract void initFieldObject(Field2d field); - + + public abstract SwerveDriveKinematics getKinematics(); public abstract SwerveModuleState[] getModuleStates(); public abstract SwerveModulePosition[] getModulePositions(); public abstract Translation2d[] getModuleOffsets(); @@ -41,4 +44,6 @@ public static AbstractSwerveDrive getInstance() { public abstract void setModuleStates(SwerveModuleState[] states); public abstract void drive(Vector2D velocity, double Rotation2D); public abstract void stop(double Rotation2D); + + public abstract Rotation2d getGyroAngle(); } diff --git a/src/main/java/com/stuypulse/robot/subsystems/swerve/SwerveDrive.java b/src/main/java/com/stuypulse/robot/subsystems/swerve/SwerveDrive.java index a93f62ed..45ef63dd 100644 --- a/src/main/java/com/stuypulse/robot/subsystems/swerve/SwerveDrive.java +++ b/src/main/java/com/stuypulse/robot/subsystems/swerve/SwerveDrive.java @@ -77,6 +77,7 @@ public void initFieldObject(Field2d field) { } } + @Override public SwerveDriveKinematics getKinematics() { return kinematics; } @@ -169,21 +170,18 @@ public void stop(double Rotation2D) { } /*Gyro */ - public Rotation2d getGyroPitch() { - return Rotation2d.fromDegrees(gyro.getPitch()); - } - + @Override public Rotation2d getGyroAngle() { return gyro.getRotation2d(); } + + public Rotation2d getGyroPitch() { + return Rotation2d.fromDegrees(gyro.getPitch()); + } public Rotation2d getGyroRoll() { return Rotation2d.fromDegrees(gyro.getRoll()); } - - public Rotation2d getGyroYaw() { - return Rotation2d.fromDegrees(gyro.getYaw()); - } public double getForwardAccelerationGs() { return gyro.getWorldLinearAccelY();