This commit is contained in:
samuel desharnais
2023-12-05 18:18:45 -05:00
parent 5fc179a598
commit 5fa7666976
4 changed files with 69 additions and 5 deletions

View File

@@ -7,17 +7,32 @@ package frc.robot.subsystems;
import java.io.File;
import java.io.IOException;
import com.revrobotics.CANSparkMax;
import com.revrobotics.CANSparkMaxLowLevel.MotorType;
import edu.wpi.first.math.geometry.Translation2d;
import edu.wpi.first.math.kinematics.SwerveModulePosition;
import edu.wpi.first.wpilibj.Filesystem;
import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard;
import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
import frc.robot.Constants;
import swervelib.SwerveDrive;
import swervelib.encoders.CanAndCoderSwerve;
import swervelib.parser.SwerveParser;
public class Drive extends SubsystemBase {
ShuffleboardTab dashboard = Shuffleboard.getTab("Dashboard");
SwerveDrive swerveDrive;
File swerveJsonDirectory = new File(Filesystem.getDeployDirectory(),"swerve");
/* final CanAndCoderSwerve avantdroitdrive = new CanAndCoderSwerve(Constants.avantdroitDrive);
final CanAndCoderSwerve avantgauchedrive = new CanAndCoderSwerve(Constants.avantgaucheDrive);
final CanAndCoderSwerve arrieregauchedrive = new CanAndCoderSwerve(Constants.arrieregaucheDrive);
final CanAndCoderSwerve arrieredroitdrive = new CanAndCoderSwerve(Constants.arrieredroitDrive);
final CanAndCoderSwerve avantdroitangle = new CanAndCoderSwerve(Constants.avantdroitAngle);
final CanAndCoderSwerve avantgaucheangle = new CanAndCoderSwerve(Constants.avantgaucheAngle);
final CanAndCoderSwerve arrieregaucheangle = new CanAndCoderSwerve(Constants.arrieregaucheAngle);
final CanAndCoderSwerve arrieredroitangle = new CanAndCoderSwerve(Constants.arrieredroitAngle); */
public void drive(double x, double y, double zRotation){
swerveDrive.drive(new Translation2d(x, y), zRotation, false, false);
}
@@ -25,6 +40,7 @@ public class Drive extends SubsystemBase {
/** Creates a new Drive. */
public Drive() {
try {
this.swerveDrive = new SwerveParser(swerveJsonDirectory).createSwerveDrive();
} catch (IOException e) {
@@ -34,6 +50,9 @@ public class Drive extends SubsystemBase {
public SwerveModulePosition[] distance(){
return swerveDrive.getModulePositions();
}
public void reset(){
}
@Override
public void periodic() {
// This method will be called once per scheduler run