5
5
import edu .wpi .first .math .util .Units ;
6
6
import edu .wpi .first .networktables .*;
7
7
import edu .wpi .first .wpilibj .DigitalInput ;
8
+ import edu .wpi .first .wpilibj .GenericHID ;
8
9
import edu .wpi .first .wpilibj .Timer ;
9
10
import edu .wpi .first .wpilibj .smartdashboard .SmartDashboard ;
10
11
import edu .wpi .first .wpilibj2 .command .InstantCommand ;
11
12
import edu .wpi .first .wpilibj2 .command .SubsystemBase ;
13
+ import edu .wpi .first .wpilibj2 .command .button .CommandXboxController ;
12
14
import frc .robot .commands .drive .Alignments ;
13
15
import frc .robot .util .AllianceFlipUtil ;
14
16
import frc .robot .util .MBUtils ;
@@ -197,7 +199,9 @@ public void setClimbState(ClimbState climbState){
197
199
DigitalInput beamBreak1 = new DigitalInput (4 );
198
200
199
201
200
- public StateControllerSub (){
202
+ CommandXboxController driver ;
203
+ CommandXboxController operator ;
204
+ public StateControllerSub (CommandXboxController driver , CommandXboxController operator ){
201
205
NamedCommands .registerCommand ("intakeMode" ,new InstantCommand (this ::intakePressed ));
202
206
NamedCommands .registerCommand ("holdMode" ,new InstantCommand (this ::holdPressed ));
203
207
NamedCommands .registerCommand ("setObjectiveSpeaker" ,new InstantCommand (this ::speakerPressed ));
@@ -215,6 +219,8 @@ public StateControllerSub(){
215
219
SmartDashboard .putBoolean ("alignWhenClose" ,alignWhenCloseEnabled );
216
220
217
221
222
+ this .driver = driver ;
223
+ this .operator = operator ;
218
224
219
225
}
220
226
@@ -230,6 +236,8 @@ public void periodic(){
230
236
231
237
publishTableEntries ();
232
238
239
+ updateRumbles ();
240
+
233
241
//get an x y and z from smartDashboard
234
242
235
243
@@ -288,6 +296,28 @@ public void periodic(){
288
296
289
297
}
290
298
299
+ public void updateRumbles (){
300
+ double bothRumbleVal = 0 ;
301
+
302
+ if (Timer .getFPGATimestamp () - lastBrakeEngagementTimestamp <0.2 && armState == ArmState .SPEAKER )
303
+ bothRumbleVal = 1 ;
304
+
305
+ driver .getHID ().setRumble (GenericHID .RumbleType .kBothRumble ,bothRumbleVal );
306
+ operator .getHID ().setRumble (GenericHID .RumbleType .kBothRumble ,bothRumbleVal );
307
+
308
+ }
309
+ boolean brakeEngaged = false ;
310
+ double lastBrakeEngagementTimestamp = 0 ;
311
+ public void feedBrakeEngaged (boolean brakeEngaged ){
312
+ if (brakeEngaged == true && this .brakeEngaged == false )
313
+ onBrakeEngaged ();
314
+ this .brakeEngaged = brakeEngaged ;
315
+ }
316
+
317
+ void onBrakeEngaged (){
318
+ lastBrakeEngagementTimestamp = Timer .getFPGATimestamp ();
319
+ }
320
+
291
321
292
322
public void setDuckMode (boolean down ){
293
323
if (down ) duckMode = DuckMode .DOWN ;
0 commit comments