Skip to content
This repository was archived by the owner on Jan 16, 2025. It is now read-only.

Commit a35b961

Browse files
committed
Merge branch 'Amrit-S' of https://github.com/frc-7419/FinalAssessment2024 into Amrit-S
2 parents 5a52fdc + 8207dd3 commit a35b961

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

src/main/java/frc/robot/subsystems/drive/DrivebaseSubsytem.java

+3-16
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
package frc.robot.subsystems.drive;
22

3-
import com.kauailabs.vmx.AHRSJNI;
43
import edu.wpi.first.math.kinematics.SwerveDriveOdometry;
54
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
65
import edu.wpi.first.wpilibj2.command.SubsystemBase;
76

87
import frc.Constants.SwerveConstants;
9-
import com.kauailabs.navx.frc.AHRS;
108

119
public class DrivebaseSubsytem extends SubsystemBase {
1210
/** Creates a new DriveBase. */
@@ -15,10 +13,10 @@ public class DrivebaseSubsytem extends SubsystemBase {
1513
private final SwerveModule backRight;
1614
private final SwerveModule backLeft;
1715
public final SwerveDriveOdometry odometry;
18-
private final AHRS ahrs;
16+
1917
public DrivebaseSubsytem() {
2018
this.odometry = new SwerveDriveOdometry(null, null, null);
21-
this.ahrs = new AHRS();
19+
2220
frontRight = new SwerveModule(SwerveConstants.frontRightTurnMotorID, SwerveConstants.frontRightDriveMotorID, SwerveConstants.frontRightTurnEncoderID,SwerveConstants.frontRightEncoderOffset);
2321
frontLeft = new SwerveModule(SwerveConstants.frontLeftTurnMotorID, SwerveConstants.frontLeftDriveMotorID, SwerveConstants.frontLeftTurnEncoderID, SwerveConstants.frontLeftEncoderOffset);
2422
backRight = new SwerveModule(SwerveConstants.backRightTurnMotorID, SwerveConstants.backRightDriveMotorID, SwerveConstants.backRightTurnEncoderID, SwerveConstants.backRightEncoderOffset);
@@ -31,18 +29,7 @@ public DrivebaseSubsytem() {
3129
public void periodic() {
3230

3331
}
34-
public double getPitch(){
35-
return ahrs.getPitch();
36-
}
37-
public void resetYaw(){
38-
ahrs.zeroYaw();
39-
}
40-
public double getYaw(){
41-
return ahrs.getYaw();
42-
}
43-
public double getRoll(){
44-
return ahrs.getRoll();
45-
}
32+
4633
public Boolean distanceReached(double distance){
4734
return backLeft.reachedDistanced(distance) && frontRight.reachedDistanced(distance) && backRight.reachedDistanced(distance) && frontLeft.reachedDistanced(distance);
4835
//why is the and && in java :(

src/main/java/frc/robot/subsystems/drive/SwerveModule.java

+14
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public class SwerveModule {
3030

3131

3232
//to be frank this code is pretty chopped
33+
//i take that back this code is horrendous but it functions so i will not be touching it.
3334
public SwerveModule(int turnMotorId, int driveMotorId, int turnEncoderId, double turnEncoderOffset){
3435
this.angleController = new PIDController(SwerveConstants.anglekP, SwerveConstants.anglekI, SwerveConstants.anglekD);
3536

@@ -65,6 +66,19 @@ public void setPower(double power){
6566
turnMotor.setVoltage(power);
6667
driveMotor.setVoltage(power);
6768

69+
70+
71+
72+
}
73+
public void setModuleState(SwerveModuleState state){
74+
double speed = state.speedMetersPerSecond;
75+
angleController.setSetpoint(state.angle.getDegrees());
76+
driveMotor.set(speed);
77+
angleController.calculate(state.angle.getDegrees());
78+
79+
80+
81+
6882

6983

7084
}

0 commit comments

Comments
 (0)