diff --git a/.project b/.project index dc4fc5e..f6c755e 100644 --- a/.project +++ b/.project @@ -1,6 +1,6 @@ - RoboLib + potential-octo-eureka-RoboLib Project RoboLib created by Buildship. diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..49abf93 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,5 @@ +wpiVersion = 2025.3.1 + +ctreVersion = 25.1.0 + +advantageKitVersion = 4.0.0 diff --git a/lib/.classpath b/lib/.classpath new file mode 100644 index 0000000..a99ea3b --- /dev/null +++ b/lib/.classpath @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/lib/.project b/lib/.project new file mode 100644 index 0000000..cd81445 --- /dev/null +++ b/lib/.project @@ -0,0 +1,34 @@ + + + lib + Project lib created by Buildship. + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.buildship.core.gradleprojectbuilder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.buildship.core.gradleprojectnature + + + + 1743377880685 + + 30 + + org.eclipse.core.resources.regexFilterMatcher + node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ + + + + diff --git a/lib/build.gradle b/lib/build.gradle index c0e34dd..2618b96 100644 --- a/lib/build.gradle +++ b/lib/build.gradle @@ -25,9 +25,8 @@ repositories { mavenLocal() gradlePluginPortal() - maven {url "https://maven.photonvision.org/repository/snapshots"} - maven {url "https://maven.photonvision.org/repository/internal"} maven {url "https://maven.ctr-electronics.com/release/"} + maven {url "https://frcmaven.wpi.edu/artifactory/littletonrobotics-mvn-release/"} } dependencies { @@ -48,6 +47,9 @@ dependencies { // CTRE Phoenix 6 implementation "com.ctre.phoenix6:wpiapi-java:${ctreVersion}" + // AdvantageKit + implementation "org.littletonrobotics.akit:akit-java:${advantageKitVersion}" + } tasks.named('test') { diff --git a/lib/src/main/java/org/fairportrobotics/frc/robolib/DriveSystems/SwerveDrive/SwerveDriveSubsystem.java b/lib/src/main/java/org/fairportrobotics/frc/robolib/DriveSystems/SwerveDrive/SwerveDriveSubsystem.java index 243bf5f..34ac849 100644 --- a/lib/src/main/java/org/fairportrobotics/frc/robolib/DriveSystems/SwerveDrive/SwerveDriveSubsystem.java +++ b/lib/src/main/java/org/fairportrobotics/frc/robolib/DriveSystems/SwerveDrive/SwerveDriveSubsystem.java @@ -1,11 +1,68 @@ package org.fairportrobotics.frc.robolib.DriveSystems.SwerveDrive; +import org.littletonrobotics.junction.Logger; + +import com.ctre.phoenix6.hardware.Pigeon2; + +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.SwerveModuleState; import edu.wpi.first.wpilibj2.command.SubsystemBase; public class SwerveDriveSubsystem extends SubsystemBase{ - + + private SwerveDriveKinematics driveKiniematics; + private ChassisSpeeds chassisSpeeds; + private Translation2d centerOfRotation; + + private SwerveModule[] modules; + + private final double MAX_LINEAR_SPEED = 3.9; + private final double MAX_ANGULAR_SPEED = Math.PI * 2; + + private Pigeon2 gyro; + public SwerveDriveSubsystem(){ - + + driveKiniematics = new SwerveDriveKinematics( + modules[0].getModuleLocation(), + modules[1].getModuleLocation(), + modules[2].getModuleLocation(), + modules[3].getModuleLocation() + ); + + } + + @Override + public void periodic() { + SwerveModuleState[] moduleStates = driveKiniematics.toSwerveModuleStates(chassisSpeeds, centerOfRotation); + Logger.recordOutput("Un-Optimized Swerve States", moduleStates); + + for(int i=0; i