From f268c659ff99b078952320148357c408ce89b053 Mon Sep 17 00:00:00 2001 From: Jack Lingle Date: Wed, 13 Nov 2024 19:03:43 -0500 Subject: [PATCH] make drive template extend subsystem --- .../wpilib_interface/DriveTemplate.java | 3 ++- .../wpilib_interface/DriveWithJoysticks.java | 19 ++++++++++---- .../main/java/frc/robot/BuildConstants.java | 26 +++++++++---------- 3 files changed, 28 insertions(+), 20 deletions(-) diff --git a/wpilib_interface/src/main/java/coppercore/wpilib_interface/DriveTemplate.java b/wpilib_interface/src/main/java/coppercore/wpilib_interface/DriveTemplate.java index 2e1007a..66ddcc2 100644 --- a/wpilib_interface/src/main/java/coppercore/wpilib_interface/DriveTemplate.java +++ b/wpilib_interface/src/main/java/coppercore/wpilib_interface/DriveTemplate.java @@ -1,7 +1,8 @@ package coppercore.wpilib_interface; import edu.wpi.first.math.kinematics.ChassisSpeeds; +import edu.wpi.first.wpilibj2.command.Subsystem; -public interface DriveTemplate { +public interface DriveTemplate extends Subsystem { public void setGoalSpeeds(ChassisSpeeds goalSpeeds, boolean fieldCentric); } diff --git a/wpilib_interface/src/main/java/coppercore/wpilib_interface/DriveWithJoysticks.java b/wpilib_interface/src/main/java/coppercore/wpilib_interface/DriveWithJoysticks.java index e9f9053..c738e4c 100644 --- a/wpilib_interface/src/main/java/coppercore/wpilib_interface/DriveWithJoysticks.java +++ b/wpilib_interface/src/main/java/coppercore/wpilib_interface/DriveWithJoysticks.java @@ -17,24 +17,33 @@ public class DriveWithJoysticks extends Command { private double maxAngularVelocity; public DriveWithJoysticks( - DriveTemplate drive, CommandJoystick leftJoystick, CommandJoystick rightJoystick, double maxLinearVelocity, double maxAngularVelocity) { + DriveTemplate drive, + CommandJoystick leftJoystick, + CommandJoystick rightJoystick, + double maxLinearVelocity, + double maxAngularVelocity) { this.drive = drive; this.leftJoystick = leftJoystick; this.rightJoystick = rightJoystick; this.maxLinearVelocity = maxLinearVelocity; this.maxAngularVelocity = maxAngularVelocity; - + addRequirements(this.drive); } @Override public void execute() { - Translation2d linearSpeeds = getLinearVelocity(leftJoystick.getX(), leftJoystick.getY()); + Translation2d linearSpeeds = getLinearVelocity(-leftJoystick.getX(), -leftJoystick.getY()); - double omega = Deadband.oneAxisDeadband(rightJoystick.getX(), 0.1); + double omega = Deadband.oneAxisDeadband(-rightJoystick.getX(), 0.1); omega = Math.copySign(omega * omega, omega); - drive.setGoalSpeeds(new ChassisSpeeds(linearSpeeds.getX() * maxLinearVelocity, linearSpeeds.getY() * maxLinearVelocity, omega * maxAngularVelocity), true); + drive.setGoalSpeeds( + new ChassisSpeeds( + linearSpeeds.getX() * maxLinearVelocity, + linearSpeeds.getY() * maxLinearVelocity, + omega * maxAngularVelocity), + true); } public Translation2d getLinearVelocity(double x, double y) { diff --git a/wpilib_interface/src/main/java/frc/robot/BuildConstants.java b/wpilib_interface/src/main/java/frc/robot/BuildConstants.java index 1875024..bc28a5b 100644 --- a/wpilib_interface/src/main/java/frc/robot/BuildConstants.java +++ b/wpilib_interface/src/main/java/frc/robot/BuildConstants.java @@ -1,19 +1,17 @@ package frc.robot; -/** - * Automatically generated file containing build version information. - */ +/** Automatically generated file containing build version information. */ public final class BuildConstants { - public static final String MAVEN_GROUP = "com.github.team401"; - public static final String MAVEN_NAME = "wpi_interface"; - public static final String VERSION = "0.0"; - public static final int GIT_REVISION = 31; - public static final String GIT_SHA = "6665ac076ea8c0effafb5558d88433ff386cf7b6"; - public static final String GIT_DATE = "2024-10-07 18:03:40 EDT"; - public static final String GIT_BRANCH = "drive-command"; - public static final String BUILD_DATE = "2024-11-11 19:38:24 EST"; - public static final long BUILD_UNIX_TIME = 1731371904305L; - public static final int DIRTY = 1; + public static final String MAVEN_GROUP = "com.github.team401"; + public static final String MAVEN_NAME = "wpilib_interface"; + public static final String VERSION = "0.0"; + public static final int GIT_REVISION = 35; + public static final String GIT_SHA = "497822ac6367923d18b42fc721160171e690af59"; + public static final String GIT_DATE = "2024-11-13 18:53:56 EST"; + public static final String GIT_BRANCH = "drive-command"; + public static final String BUILD_DATE = "2024-11-13 19:02:59 EST"; + public static final long BUILD_UNIX_TIME = 1731542579980L; + public static final int DIRTY = 1; - private BuildConstants(){} + private BuildConstants() {} }