3030import frc .robot .commands .intake .RunIntake ;
3131import frc .robot .commands .shooter .Shoot ;
3232import frc .robot .commands .shooter .ShootManualFlywheel ;
33+ import frc .robot .constants .FIELD ;
3334import frc .robot .generated .WoodBotConstants ;
3435import frc .robot .simulation .Robot2d ;
3536import frc .robot .subsystems .*;
3637import frc .robot .subsystems .Climber ;
38+ import frc .robot .subsystems .CommandSwerveDrivetrain ;
39+ import frc .robot .subsystems .Indexer ;
40+ import frc .robot .subsystems .Intake ;
41+ import frc .robot .subsystems .Uptake ;
3742import frc .team4201 .lib .simulation .FieldSim ;
3843import frc .team4201 .lib .utils .HubTracker ;
3944import frc .team4201 .lib .utils .Telemetry ;
@@ -88,13 +93,13 @@ public boolean isHubActive() {
8893 }
8994
9095 @ NotLogged
91- private double MaxSpeed =
92- WoodBotConstants .kSpeedAt12Volts .in (MetersPerSecond ); // Kspeed at 12 volts desired top speed
96+ private final double MaxSpeed =
97+ WoodBotConstants .kSpeedAt12Volts .in (MetersPerSecond ); // kSpeed at 12 volts desired top speed
9398
9499 private Boolean m_flipToRight = false ;
95100
96101 @ NotLogged
97- private double MaxAngularRate =
102+ private final double MaxAngularRate =
98103 RotationsPerSecond .of (SWERVE .kMaxRotationRadiansPerSecond )
99104 .in (RadiansPerSecond ); // 3/4 of a rotation per second max angular velocity
100105
@@ -106,7 +111,7 @@ public boolean isHubActive() {
106111
107112 private Robot2d m_robotSim ;
108113 private final Telemetry m_telemetry = new Telemetry (MaxSpeed , SWERVE .kModuleTranslations );
109- private final FieldSim m_fieldSim = new FieldSim ();
114+ private FieldSim m_fieldSim = new FieldSim ();
110115
111116 @ Logged (name = "AutoChooser" )
112117 private final SendableChooser <Command > m_autoChooser = new SendableChooser <>();
@@ -116,6 +121,8 @@ public boolean isHubActive() {
116121 /** The container for the robot. Contains subsystems, OI devices, and commands. */
117122 public RobotContainer () {
118123 // Configure the trigger bindings
124+ FIELD .initializeConstants ();
125+ FIELD .updateConstants ();
119126 initializeSubSystems ();
120127 configureBindings ();
121128 initSmartDashboard ();
@@ -145,6 +152,7 @@ private void initializeSubSystems() {
145152 rotationRate ); // Drive counterclockwise with negative X (left)
146153 return drive ;
147154 }));
155+ m_fieldSim = new FieldSim ();
148156 m_flywheel = new Flywheel ();
149157 m_controls = new Controls ();
150158 m_vision = new Vision (m_controls );
@@ -162,6 +170,8 @@ private void initializeSubSystems() {
162170 m_led .setDefaultCommand (new UpdateLEDs (m_led , m_swerveDrive , m_intake , m_climber , m_uptake ));
163171
164172 if (Robot .isSimulation ()) {
173+ FIELD .plotAllPositions (m_fieldSim );
174+
165175 m_robotSim = new Robot2d ();
166176 m_robotSim .registerSubsystems (m_flywheel , m_hood , m_indexer , m_intake , m_uptake );
167177 }
@@ -177,8 +187,8 @@ private void configureBindings() {
177187 new AutoAlignDrive (
178188 m_swerveDrive ,
179189 m_vision ,
180- () -> m_driverController . getLeftY () ,
181- () -> m_driverController . getLeftX () ),
190+ m_driverController :: getLeftY ,
191+ m_driverController :: getLeftX ),
182192 new Shoot (m_flywheel , m_vision )));
183193 }
184194
@@ -189,8 +199,8 @@ private void configureBindings() {
189199 new AutoAlignDrive (
190200 m_swerveDrive ,
191201 m_vision ,
192- () -> m_driverController . getLeftY () ,
193- () -> m_driverController . getLeftX () ));
202+ m_driverController :: getLeftY ,
203+ m_driverController :: getLeftX ));
194204 }
195205
196206 if (m_swerveDrive != null && m_flywheel != null && m_vision != null ) {
@@ -201,7 +211,7 @@ private void configureBindings() {
201211 m_driverController .y ().whileTrue (new ShootManualFlywheel (m_flywheel ));
202212 }
203213
204- // I forsee a state machine in the future...
214+ // I foresee a state machine in the future...
205215 if (m_uptake != null && m_indexer != null && m_intake != null ) {
206216 m_driverController
207217 .a ()
@@ -244,10 +254,7 @@ private void initSideChooser() {
244254
245255 m_autoSide .addOption ("Depot" , false );
246256 m_autoSide .addOption ("Outpost" , true );
247- m_autoSide .onChange (
248- (Boolean selected ) -> {
249- m_flipToRight = selected ;
250- });
257+ m_autoSide .onChange ((Boolean selected ) -> m_flipToRight = selected );
251258 }
252259
253260 private void initSmartDashboard () {
@@ -278,4 +285,8 @@ public Command getAutonomousCommand() {
278285 // An example command will be run in autonomous
279286 return m_autoChooser .getSelected ();
280287 }
288+
289+ public void robotPeriodic () {
290+ FIELD .updateCurrentSector (m_swerveDrive .getState ().Pose );
291+ }
281292}
0 commit comments