Skip to content

Commit f5639f0

Browse files
committed
demo changes
1 parent 734b91a commit f5639f0

File tree

5 files changed

+24
-6
lines changed

5 files changed

+24
-6
lines changed

src/main/java/frc/robot/Constants.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ public static class SwerveConstants { // all swerve on CAN ID range 1-9
4747
public static final double kTurnAbsPositionConversionFactor = Units.rotationsToRadians(1);
4848

4949
public static final double kMaxWheelSpeed = 8; // m/s
50-
public static final double kMagVelLimit = 6; // m/s
50+
public static final double kMagVelLimit = 2; // m/s
5151
public static final double kDirVelLimit = 10; // rad/s
52-
public static final double kRotVelLimit = 6; // rad/s
52+
public static final double kRotVelLimit = 4; // rad/s
5353
public static final double kMagAccelLimit = 48; // m/s^2
54-
public static final double kRotAccelLimit = 30; // rad/s^2
54+
public static final double kRotAccelLimit = 60; // rad/s^2
5555

5656
public static final double kDefaultTestTurn = 0;
5757
public static final double kDefaultTestDrive = 0;

src/main/java/frc/robot/RobotContainer.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@ private void configureBindings() {
142142
// altController.rightBumper().onFalse(intake.runRoller(0));
143143
// altController.rightTrigger().onTrue(intake.runRoller(16));
144144
// altController.rightTrigger().onFalse(intake.runRoller(0));
145+
146+
altController.rightBumper().onTrue(swerveDrive.toggleEnabled());
145147
}
146148

147149
public Command getAutonomousCommand() {

src/main/java/frc/robot/subsystems/shooter/Shooter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ public void periodic() {
277277
indexSpeedFactor = 0.3;
278278
break;
279279
case SPEAKER:
280-
speedFactor = -1;
280+
speedFactor = -0.35;
281281
indexSpeedFactor = speedFactor;
282282
break;
283283
case AMP:

src/main/java/frc/robot/subsystems/swerve/SDSSwerveModule.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ public void setDesiredSwerveState(SwerveModuleState state, boolean optimize) {
128128
turnAbsEncoder.getPosition()
129129
)
130130
);
131+
// correctedState.speedMetersPerSecond *= correctedState.angle.minus(new Rotation2d(turnAbsEncoder.getPosition())).minus(chassisAngularOffset).getCos();
131132
} else {
132133
correctedState = SwerveModuleState.optimize(
133134
correctedState,

src/main/java/frc/robot/subsystems/swerve/SwerveDrive.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,10 @@ public class SwerveDrive extends SubsystemBase {
9292
private Field2d field;
9393
private Field2d limelightField;
9494

95+
private boolean enabled;
96+
9597
public SwerveDrive() {
98+
enabled = true;
9699
initComponents();
97100
initMathModels();
98101
initSimulations();
@@ -263,10 +266,21 @@ public Command runUpdateConstants() {
263266
});
264267
}
265268

269+
public Command toggleEnabled() {
270+
return runOnce(() -> {
271+
System.out.println(enabled);
272+
enabled = !enabled;
273+
});
274+
}
275+
266276
public Command runDriveInputs(
267277
DoubleSupplier rawXSpeed, DoubleSupplier rawYSpeed, DoubleSupplier rawRotSpeed,
268278
BooleanSupplier robotCentric, BooleanSupplier noOptimize, boolean rateLimited) {
269279
return run(() -> {
280+
if(!enabled) {
281+
adjustedDriveInputs(0, 0, 0, robotCentric.getAsBoolean(), noOptimize.getAsBoolean(), rateLimited);
282+
return;
283+
}
270284
double adjXSpeed = MathUtil.applyDeadband(rawXSpeed.getAsDouble(), 0.2);
271285
double adjYSpeed = MathUtil.applyDeadband(-rawYSpeed.getAsDouble(), 0.2);
272286

@@ -393,9 +407,10 @@ private void addPresetPositionDriveInputs(double xSpeed, double ySpeed, double r
393407

394408
public void rawDriveInputs(double rawXSpeed, double rawYSpeed, double rawRotSpeed, boolean noOptimize, boolean robotCentric) {
395409
SwerveModuleState[] states = SwerveConstants.kSwerveKinematics.toSwerveModuleStates(!robotCentric ?
396-
ChassisSpeeds.fromFieldRelativeSpeeds(rawXSpeed, rawYSpeed, rawRotSpeed, getRotation2d()) : // see if gyro is done correctly
397-
new ChassisSpeeds(rawXSpeed, rawYSpeed, rawRotSpeed)
410+
ChassisSpeeds.fromFieldRelativeSpeeds(rawXSpeed, rawYSpeed, rawRotSpeed, getRotation2d()) : // see if gyro is done correctly
411+
new ChassisSpeeds(rawXSpeed, rawYSpeed, rawRotSpeed)
398412
);
413+
// System.out.println(states[0].angle.getDegrees() + " " + rawXSpeed);
399414
// System.out.println(rawXSpeed + " " + rawYSpeed + " " + rawRotSpeed);
400415
rawModuleInputs(states, noOptimize);
401416
}

0 commit comments

Comments
 (0)