22
33import  java .util .function .BooleanSupplier ;
44import  java .util .function .DoubleSupplier ;
5+ import  java .util .function .Supplier ;
56
67import  edu .wpi .first .math .filter .SlewRateLimiter ;
78import  edu .wpi .first .math .geometry .Translation2d ;
89import  edu .wpi .first .math .kinematics .ChassisSpeeds ;
910import  edu .wpi .first .wpilibj .smartdashboard .SmartDashboard ;
1011import  edu .wpi .first .wpilibj2 .command .CommandBase ;
12+ import  team1403 .lib .core .CougarRobot ;
1113import  team1403 .robot .chargedup .AutoManager ;
1214import  team1403 .robot .chargedup .RobotConfig ;
1315import  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