FINALLY FIXED SWERVE

This commit is contained in:
2026-01-31 17:03:35 -05:00
parent 95108b7da7
commit 66049f1357
3 changed files with 23 additions and 17 deletions

View File

@@ -50,10 +50,14 @@ public class RobotContainer {
)
);
driver.x().whileTrue(drivetrain.runFrontLeft());
driver.y().whileTrue(drivetrain.runFrontRight());
driver.a().whileTrue(drivetrain.runRearLeft());
driver.b().whileTrue(drivetrain.runRearRight());
driver.start().and(driver.x()).whileTrue(drivetrain.runFrontLeft(1, 0));
driver.start().and(driver.y()).whileTrue(drivetrain.runFrontRight(1, 0));
driver.start().and(driver.a()).whileTrue(drivetrain.runRearLeft(1, 0));
driver.start().and(driver.b()).whileTrue(drivetrain.runRearRight(1, 0));
driver.start().negate().and(driver.x()).whileTrue(drivetrain.runFrontLeft(0, 45));
driver.start().negate().and(driver.y()).whileTrue(drivetrain.runFrontRight(0, 45));
driver.start().negate().and(driver.a()).whileTrue(drivetrain.runRearLeft(0, 45));
driver.start().negate().and(driver.b()).whileTrue(drivetrain.runRearRight(0, 45));
driver.rightBumper().whileTrue(drivetrain.setX());
//drivetrain.setDefaultCommand(drivetrain.disableOutputs());

View File

@@ -90,7 +90,8 @@ public class ModuleConstants {
turningConfig
.idleMode(kTurnIdleMode)
.smartCurrentLimit(kTurnMotorCurrentLimit);
.smartCurrentLimit(kTurnMotorCurrentLimit)
.inverted(true);
turningConfig.encoder
//.inverted(true)
.positionConversionFactor(kTurningFactor)
@@ -101,5 +102,6 @@ public class ModuleConstants {
.outputRange(-1, 1)
.positionWrappingEnabled(true)
.positionWrappingInputRange(0, 2 * Math.PI);
}
}

View File

@@ -134,32 +134,32 @@ public class Drivetrain extends SubsystemBase {
Logger.recordOutput("Drivetrain/Heading", getHeading());
}
public Command runFrontLeft() {
public Command runFrontLeft(double staticSpeed, double staticAngleDegrees) {
return run(() -> {
frontLeft.setDesiredState(new SwerveModuleState(
1,
new Rotation2d()));
staticSpeed,
Rotation2d.fromDegrees(staticAngleDegrees)));
});
}
public Command runFrontRight() {
public Command runFrontRight(double staticSpeed, double staticAngleDegrees) {
return run(() -> {
frontRight.setDesiredState(new SwerveModuleState(
1,
new Rotation2d()));
staticSpeed,
Rotation2d.fromDegrees(staticAngleDegrees)));
});
}
public Command runRearLeft() {
public Command runRearLeft(double staticSpeed, double staticAngleDegrees) {
return run(() -> {
rearLeft.setDesiredState(new SwerveModuleState(
1,
new Rotation2d()));
staticSpeed,
Rotation2d.fromDegrees(staticAngleDegrees)));
});
}
public Command runRearRight() {
public Command runRearRight(double staticSpeed, double staticAngleDegrees) {
return run(() -> {
rearRight.setDesiredState(new SwerveModuleState(
1,
new Rotation2d()));
staticSpeed,
Rotation2d.fromDegrees(staticAngleDegrees)));
});
}