From dfa05d79a75a4a6c1c750a554ae419b4523cfbdc Mon Sep 17 00:00:00 2001 From: samuel desharnais Date: Wed, 23 Oct 2024 19:31:48 -0400 Subject: [PATCH 1/2] YAGLS --- src/main/java/frc/robot/Subsystems/Drive.java | 38 ++++++++++++++++++- vendordeps/PathplannerLib.json | 38 +++++++++++++++++++ 2 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 vendordeps/PathplannerLib.json diff --git a/src/main/java/frc/robot/Subsystems/Drive.java b/src/main/java/frc/robot/Subsystems/Drive.java index 2715574..076ada3 100644 --- a/src/main/java/frc/robot/Subsystems/Drive.java +++ b/src/main/java/frc/robot/Subsystems/Drive.java @@ -4,12 +4,46 @@ package frc.robot.Subsystems; +import java.io.File; +import java.io.IOException; + +import com.ctre.phoenix6.hardware.Pigeon2; + +import edu.wpi.first.math.geometry.Translation2d; +import edu.wpi.first.math.kinematics.SwerveModulePosition; +import edu.wpi.first.wpilibj.Filesystem; import edu.wpi.first.wpilibj2.command.SubsystemBase; +import swervelib.SwerveDrive; +import swervelib.parser.SwerveParser; + public class Drive extends SubsystemBase { - /** Creates a new Drive. */ - public Drive() {} + SwerveDrive swerveDrive; + + File swerveJsonDirectory = new File(Filesystem.getDeployDirectory(),"swerve"); + + Pigeon2 Gyro = new Pigeon2(0); + + public void drive(double x, double y, double zRotation){ + swerveDrive.drive(new Translation2d(x*5, y*5), zRotation*4, true, false); + } + + public Drive() { + try { + this.swerveDrive = new SwerveParser(swerveJsonDirectory).createSwerveDrive(5); + swerveDrive.setHeadingCorrection(true); + } catch (IOException e) { + e.printStackTrace(); + } + } + public void restgyroscope(){ + Gyro.reset(); + } + public SwerveModulePosition[] distance(){ + return swerveDrive.getModulePositions(); + } + @Override public void periodic() { diff --git a/vendordeps/PathplannerLib.json b/vendordeps/PathplannerLib.json new file mode 100644 index 0000000..6dc648d --- /dev/null +++ b/vendordeps/PathplannerLib.json @@ -0,0 +1,38 @@ +{ + "fileName": "PathplannerLib.json", + "name": "PathplannerLib", + "version": "2024.2.8", + "uuid": "1b42324f-17c6-4875-8e77-1c312bc8c786", + "frcYear": "2024", + "mavenUrls": [ + "https://3015rangerrobotics.github.io/pathplannerlib/repo" + ], + "jsonUrl": "https://3015rangerrobotics.github.io/pathplannerlib/PathplannerLib.json", + "javaDependencies": [ + { + "groupId": "com.pathplanner.lib", + "artifactId": "PathplannerLib-java", + "version": "2024.2.8" + } + ], + "jniDependencies": [], + "cppDependencies": [ + { + "groupId": "com.pathplanner.lib", + "artifactId": "PathplannerLib-cpp", + "version": "2024.2.8", + "libName": "PathplannerLib", + "headerClassifier": "headers", + "sharedLibrary": false, + "skipInvalidPlatforms": true, + "binaryPlatforms": [ + "windowsx86-64", + "linuxx86-64", + "osxuniversal", + "linuxathena", + "linuxarm32", + "linuxarm64" + ] + } + ] +} \ No newline at end of file From ea96a168641c2735c9354641473d78d1b7648963 Mon Sep 17 00:00:00 2001 From: samuel desharnais Date: Wed, 23 Oct 2024 19:34:20 -0400 Subject: [PATCH 2/2] swerve --- src/main/deploy/swerve/modules/backleft.json | 4 ++-- src/main/deploy/swerve/modules/frontleft.json | 4 ++-- src/main/deploy/swerve/modules/frontright.json | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/deploy/swerve/modules/backleft.json b/src/main/deploy/swerve/modules/backleft.json index 0d3c214..a80513d 100644 --- a/src/main/deploy/swerve/modules/backleft.json +++ b/src/main/deploy/swerve/modules/backleft.json @@ -5,12 +5,12 @@ }, "absoluteEncoderOffset":209.443, "drive": { - "type": "sparkmax", + "type": "talonFX", "id": 8, "canbus": null }, "angle": { - "type": "sparkmax", + "type": "talonFX", "id": 9, "canbus": null }, diff --git a/src/main/deploy/swerve/modules/frontleft.json b/src/main/deploy/swerve/modules/frontleft.json index 5cd53a4..8a46421 100644 --- a/src/main/deploy/swerve/modules/frontleft.json +++ b/src/main/deploy/swerve/modules/frontleft.json @@ -5,12 +5,12 @@ }, "absoluteEncoderOffset":258.223 , "drive": { - "type": "sparkmax", + "type": "talonFX", "id": 2, "canbus": null }, "angle": { - "type": "sparkmax", + "type": "talonFX", "id": 3, "canbus": null }, diff --git a/src/main/deploy/swerve/modules/frontright.json b/src/main/deploy/swerve/modules/frontright.json index cd1f7a6..9945196 100644 --- a/src/main/deploy/swerve/modules/frontright.json +++ b/src/main/deploy/swerve/modules/frontright.json @@ -5,12 +5,12 @@ }, "absoluteEncoderOffset": 110.215, "drive": { - "type": "sparkmax", + "type": "talonFX", "id": 18, "canbus": null }, "angle": { - "type": "sparkmax", + "type": "talonFX", "id": 17, "canbus": null },