22
33import static frc .robot .GlobalConstants .Controllers .DRIVER_CONTROLLER ;
44import static frc .robot .Subsystems .Drive .DriveConstants .*;
5-
6- import com .pathplanner .lib .auto .AutoBuilder ;
7- import com .pathplanner .lib .controllers .PPHolonomicDriveController ;
8- import com .pathplanner .lib .pathfinding .Pathfinding ;
9- import com .pathplanner .lib .util .PathPlannerLogging ;
105import edu .wpi .first .math .Matrix ;
116import edu .wpi .first .math .geometry .Pose2d ;
127import edu .wpi .first .math .geometry .Rotation2d ;
138import edu .wpi .first .math .numbers .N1 ;
149import edu .wpi .first .math .numbers .N3 ;
15- import edu .wpi .first .wpilibj .DriverStation ;
1610import edu .wpi .first .wpilibj .Filesystem ;
17- import edu .wpi .first .wpilibj .smartdashboard .Field2d ;
1811import edu .wpi .first .wpilibj .smartdashboard .SmartDashboard ;
1912import frc .robot .GlobalConstants ;
2013import frc .robot .GlobalConstants .Controllers ;
2114import frc .robot .GlobalConstants .RobotMode ;
2215import java .io .File ;
23- import org .littletonrobotics .junction .Logger ;
2416import org .team7525 .subsystem .Subsystem ;
2517import swervelib .SwerveDrive ;
2618import swervelib .SwerveInputStream ;
@@ -34,9 +26,6 @@ public class Drive extends Subsystem<DriveStates> {
3426 private SwerveInputStream swerveInputs ;
3527 private SwerveDrive swerveDrive ;
3628 private boolean fieldRelative ;
37-
38- // Field/Auto Variables:
39- private Field2d field ;
4029 private boolean slow ;
4130 // INSTANCE:
4231 private static Drive instance ;
@@ -50,26 +39,8 @@ public static Drive getInstance() {
5039
5140 public Drive () {
5241 super ("Drive" , DriveStates .MANUAL );
53- // Create field:
54- field = new Field2d ();
55-
56- //Logging for pathplanner
57- PathPlannerLogging .setLogActivePathCallback (poses -> {
58- field .getObject ("PATH" ).setPoses (poses );
59- Logger .recordOutput ("Auto/poses" , poses .toArray (new Pose2d [poses .size ()]));
60- });
61- PathPlannerLogging .setLogActivePathCallback (activePath -> {
62- field .getObject ("TRAJECTORY" ).setPoses (activePath );
63- Logger .recordOutput (
64- "Auto/Trajectory" ,
65- activePath .toArray (new Pose2d [activePath .size ()])
66- );
67- });
68- Pathfinding .ensureInitialized ();
69-
7042 slow = false ;
7143 fieldRelative = true ;
72-
7344 // Setup SwerveDrive:
7445 SwerveDriveTelemetry .verbosity = TelemetryVerbosity .HIGH ;
7546 try {
@@ -90,30 +61,7 @@ public Drive() {
9061 () -> -1 * (Controllers .DRIVER_CONTROLLER .getLeftX ())
9162 )
9263 .withControllerRotationAxis (() -> -1 * Controllers .DRIVER_CONTROLLER .getRightX ())
93- .allianceRelativeControl (true )
94- .driveToPoseEnabled (false );
95-
96- AutoBuilder .configure (
97- swerveDrive ::getPose , // Robot pose supplier
98- swerveDrive ::resetOdometry , // Method to reset odometry (will be called if your auto has a starting pose)
99- swerveDrive ::getRobotVelocity , // ChassisSpeeds supplier. MUST BE ROBOT RELATIVE
100- swerveDrive ::setChassisSpeeds , // Method that will drive the robot given ROBOT RELATIVE ChassisSpeeds. Also optionally outputs individual module feedforwards
101- new PPHolonomicDriveController (
102- // PPHolonomicController is the built in path following controller for holonomic drive trains
103- PPH_TRANSLATION_PID , // Translation PID constants
104- PPH_ROTATION_PID // Rotation PID constants
105- ),
106- DriveConstants .getRobotConfig (), // The robot configuration
107- () -> {
108- var alliance = DriverStation .getAlliance ();
109- if (alliance .isPresent ()) {
110- return alliance .get () == DriverStation .Alliance .Red ;
111- }
112- return false ;
113- },
114- this // Reference to this subsystem to set requirements
115- );
116-
64+ .allianceRelativeControl (true );
11765 establishTriggers ();
11866 }
11967
@@ -140,14 +88,14 @@ public void runState() {
14088 if (Controllers .DRIVER_CONTROLLER .getLeftBumperButtonPressed ()) {
14189 slow = false ;
14290 }
143- swerveInputs .scaleTranslation (0.33 );
144- swerveInputs .scaleRotation (0.33 );
91+ swerveInputs .scaleTranslation (0.1 );
92+ swerveInputs .scaleRotation (0.1 );
14593 } else {
14694 if (Controllers .DRIVER_CONTROLLER .getLeftBumperButtonPressed ()) {
14795 slow = true ;
14896 }
149- swerveInputs .scaleTranslation (1 );
150- swerveInputs .scaleRotation (1 );
97+ swerveInputs .scaleTranslation (0.33 );
98+ swerveInputs .scaleRotation (0.33 );
15199 }
152100
153101 if (fieldRelative ) {
@@ -164,7 +112,6 @@ public void runState() {
164112
165113 SmartDashboard .putBoolean ("SLOW MODE" , slow );
166114 SmartDashboard .putBoolean ("FIELD RELATIVE" , fieldRelative );
167- SmartDashboard .putData (field );
168115 }
169116
170117 // Vision Code Getters:
@@ -194,12 +141,4 @@ public void addVisionMeasurement(
194141 }
195142 swerveDrive .updateOdometry ();
196143 }
197- // // Bum AUTO Stuff:
198- // public void driveForward() {
199- // swerveDrive.drive(DRIVE_FORWARD_CHASSIS_SPEED);
200- // }
201-
202- // public void sidewaysToRightFace() {
203- // swerveDrive.drive(SIDEWAYS_TO_RIGHT_CHASSIS_SPEED);
204- // }
205144}
0 commit comments