Skip to content

Commit 1aba4d0

Browse files
fix auto speed limiter a different way
1 parent 80561ad commit 1aba4d0

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

src/main/java/team1403/robot/chargedup/AutoManager.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ public void init(SwerveSubsystem swerve, ArmSubsystem arm) {
7676
pathplannerAuto = autoBuilder.fullAuto(pathGroup).andThen(() -> swerve.stop(), swerve);
7777
twoPieceAuto = autoBuilder.fullAuto(twoPiece).andThen(() -> swerve.stop(), swerve);
7878
threePieceAuto = autoBuilder.fullAuto(threePiece).andThen(() -> swerve.stop(), swerve);
79-
}
79+
}
80+
8081
public CommandBase getThreePieceAuto(SwerveSubsystem swerve)
8182
{
8283
swerve.setSpeedLimiter(1.0);

src/main/java/team1403/robot/chargedup/CougarRobotImpl.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public Command getAutonomousCommand() {
9494
CommandScheduler.getInstance().removeDefaultCommand(m_swerveSubsystem);
9595
CommandScheduler.getInstance().removeDefaultCommand(m_arm);
9696
//force the swerve subsystem to stop running the default command, setting the speed limiter should now work
97-
new InstantCommand(() -> m_swerveSubsystem.stop(), m_swerveSubsystem);
97+
//new InstantCommand(() -> m_swerveSubsystem.stop(), m_swerveSubsystem);
9898
return m_autonChooser.getSelected();
9999

100100
// return
@@ -129,7 +129,8 @@ public void configureDriverInterface() {
129129
() -> -deadband(driveController.getLeftY(), 0),
130130
() -> -deadband(driveController.getRightX(), 0),
131131
() -> driveController.getYButton(),
132-
() -> driveController.getRightTriggerAxis()
132+
() -> driveController.getRightTriggerAxis(),
133+
() -> getMode()
133134
));
134135

135136
new Trigger(() -> driveController.getBButton()).onFalse(
@@ -143,10 +144,6 @@ public void configureDriverInterface() {
143144
.onFalse(new InstantCommand(() -> m_swerveSubsystem.setXModeEnabled(false)));
144145
new Trigger(() -> driveController.getPOV() == 180)
145146
.toggleOnTrue(new InstantCommand(() -> m_swerveSubsystem.resetOdometry()));
146-
new Trigger(() -> driveController.getRightBumperPressed())
147-
.toggleOnTrue(new InstantCommand(() -> m_swerveSubsystem.increaseSpeed(0.2)));
148-
new Trigger(() -> driveController.getLeftBumperPressed())
149-
.toggleOnTrue(new InstantCommand(() -> m_swerveSubsystem.decreaseSpeed(0.2)));
150147
}
151148

152149
/**

src/main/java/team1403/robot/chargedup/swerve/SwerveCommand.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22

33
import java.util.function.BooleanSupplier;
44
import java.util.function.DoubleSupplier;
5+
import java.util.function.Supplier;
56

67
import edu.wpi.first.math.filter.SlewRateLimiter;
78
import edu.wpi.first.math.geometry.Translation2d;
89
import edu.wpi.first.math.kinematics.ChassisSpeeds;
910
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
1011
import edu.wpi.first.wpilibj2.command.CommandBase;
12+
import team1403.lib.core.CougarRobot;
1113
import team1403.robot.chargedup.AutoManager;
1214
import team1403.robot.chargedup.RobotConfig;
1315
import team1403.robot.chargedup.RobotConfig.Swerve;
@@ -23,6 +25,7 @@ public class SwerveCommand extends CommandBase {
2325
private final DoubleSupplier m_rotationSupplier;
2426
private final BooleanSupplier m_fieldRelativeSupplier;
2527
private final DoubleSupplier m_speedDoubleSupplier;
28+
private final Supplier<CougarRobot.Mode> m_modeSupplier;
2629
private boolean m_isFieldRelative;
2730

2831
private Translation2d frontRight;
@@ -56,13 +59,15 @@ public SwerveCommand(SwerveSubsystem drivetrain,
5659
DoubleSupplier verticalTranslationSupplier,
5760
DoubleSupplier rotationSupplier,
5861
BooleanSupplier fieldRelativeSupplier,
59-
DoubleSupplier speedDoubleSupplier) {
62+
DoubleSupplier speedDoubleSupplier,
63+
Supplier<CougarRobot.Mode> modeSupplier) {
6064
this.m_drivetrainSubsystem = drivetrain;
6165
this.m_verticalTranslationSupplier = verticalTranslationSupplier;
6266
this.m_horizontalTranslationSupplier = horizontalTranslationSupplier;
6367
this.m_rotationSupplier = rotationSupplier;
6468
this.m_fieldRelativeSupplier = fieldRelativeSupplier;
6569
this.m_speedDoubleSupplier = speedDoubleSupplier;
70+
this.m_modeSupplier = modeSupplier;
6671
m_isFieldRelative = true;
6772

6873
frontRight = new Translation2d(
@@ -89,7 +94,14 @@ public SwerveCommand(SwerveSubsystem drivetrain,
8994

9095
@Override
9196
public void execute() {
92-
m_drivetrainSubsystem.setSpeedLimiter(0.2 + (m_speedDoubleSupplier.getAsDouble() * 0.8));
97+
if(m_modeSupplier.get() == CougarRobot.Mode.TELEOP)
98+
{
99+
m_drivetrainSubsystem.setSpeedLimiter(0.2 + (m_speedDoubleSupplier.getAsDouble() * 0.8));
100+
}
101+
else if(m_modeSupplier.get() == CougarRobot.Mode.AUTONOMOUS)
102+
{
103+
m_drivetrainSubsystem.setSpeedLimiter(1.0);
104+
}
93105
if (m_fieldRelativeSupplier.getAsBoolean()) {
94106
m_isFieldRelative = !m_isFieldRelative;
95107
}

0 commit comments

Comments
 (0)