2
2
3
3
#include " util/util.h"
4
4
5
+ // Select hatch/piston controls
6
+ //
7
+ // 0 = Tippecanoe controls. No PID hatch arm. 2 hatch buttons.
8
+ // 1 = Kokomo controls. PID hatch arm. 3 hatch buttons.
9
+ #define HATCH_CONTROL_TYPE 1
10
+
5
11
// Initialize Operator Interface
6
12
OI Robot::m_OI;
7
13
// Initialize Subsystems
@@ -108,17 +114,23 @@ void Robot::RobotInit() {
108
114
}
109
115
110
116
void Robot::RobotPeriodic () {
111
- frc::SmartDashboard::PutNumber (" flight throttle" ,
112
- m_OI.GetOperatorConsole ().GetThrottle ());
113
- frc::SmartDashboard::PutNumber (" intake rotation" ,
114
- GetCargoIntake ().GetIntakeRotation ());
115
- frc::SmartDashboard::PutNumber (" climb arm rotation" ,
116
- GetCreeperClimb ().GetCurrentArmPosition ());
117
+ frc::SmartDashboard::PutNumber (" flight throttle" , m_OI.GetOperatorConsole ().GetThrottle ());
118
+ frc::SmartDashboard::PutNumber (" intake rotation" , GetCargoIntake ().GetIntakeRotation ());
119
+ frc::SmartDashboard::PutNumber (" climb arm rotation" , GetCreeperClimb ().GetCurrentArmPosition ());
117
120
frc::SmartDashboard::PutNumber (" climb stage" , m_ClimbStep->GetSegment ());
118
- const double psiPerVolt = 150.0 / 1.1 ;
119
- frc::SmartDashboard::PutNumber (" air pressure" , (m_AirPressureMeter.GetVoltage () - 0.3 ) * psiPerVolt);
120
121
frc::SmartDashboard::PutBoolean (" climb ready" , GetCreeperClimb ().IsArmAtPosition (" arm-ready" ));
121
122
frc::SmartDashboard::PutBoolean (" climb done" , GetCreeperClimb ().IsArmAtPosition (" arm-climb" ));
123
+ frc::SmartDashboard::PutNumber (" hatch anlge" , GetHatchMechanism ().GetArmPosition ());
124
+
125
+ bool manualControl = abs (m_OI.GetOperatorConsole ().GetThrottle ()) >= 0.75 ;
126
+ bool cargoControl = m_OI.GetOperatorConsole ().GetThrottle () >= 0.75 ;
127
+ frc::SmartDashboard::PutBoolean (" manual control" , manualControl);
128
+ frc::SmartDashboard::PutString (" manual mode" , manualControl ? (cargoControl ? " Cargo" : " Creeper" ) : " None" );
129
+
130
+ // 3.36 = 110
131
+ const double psiPerVolt = 1.0 / 1.0 ;
132
+ const double psiOffset = 0.0 ;
133
+ frc::SmartDashboard::PutNumber (" air pressure" , (m_AirPressureMeter.GetVoltage () * psiPerVolt) + psiOffset);
122
134
123
135
{
124
136
static bool lastCargoState = false ;
@@ -175,6 +187,7 @@ void Robot::AutonomousInit() {
175
187
// Some positions of hatch mechanism are compliant, so disable
176
188
// PID/rotation instead of RunReset.
177
189
GetHatchMechanism ().StopRotation ();
190
+ GetHatchMechanism ().HoldPID ();
178
191
179
192
m_CanSandstormStepDrive = true ;
180
193
@@ -253,6 +266,13 @@ void Robot::CompetitionJoystickInput() {
253
266
m_Bling.SetBling (m_Bling.CargoIntakePattern );
254
267
}
255
268
269
+ #if HATCH_CONTROL_TYPE==0
270
+ // Hatch controls for Compeition 2 Tippecanoe.
271
+ // 2 vertical black buttons.
272
+ //
273
+ // Top button - RAISE + GRAB hatch.
274
+ // Bottom button - LOWER + RELEASE hatch.
275
+
256
276
if (console.GetHatchGrabPressed ()) {
257
277
std::cout << " Comp Joy Input: Console: Hatch Grab Pressed" << std::endl;
258
278
m_RaiseHatch
@@ -267,6 +287,35 @@ void Robot::CompetitionJoystickInput() {
267
287
m_Bling.SetBling (m_Bling.HatchPattern );
268
288
}
269
289
290
+ // Piston controls for Competition 2 Tippecanoe.
291
+ // Top 2 of 3 vertical buttons along right edge of console.
292
+ //
293
+ // Top button - RETRACT piston.
294
+ // Middle button - EXTEND piston.
295
+
296
+ if (console.GetHatchTopPositionPressed ()) {
297
+ std::cout << " Comp Joy Input: Console: Piston Extend Pressed" << std::endl;
298
+ GetCreeperClimb ().PistonExtend ();
299
+ } else if (console.GetHatchTopPositionReleased ()) {
300
+ std::cout << " Comp Joy Input: Console: Piston Extend Released" << std::endl;
301
+ GetCreeperClimb ().PistonHold ();
302
+ } else if (console.GetHatchMidPositionPressed ()) {
303
+ std::cout << " Comp Joy Input: Console: Piston Retract Pressed" << std::endl;
304
+ GetCreeperClimb ().PistonRetract ();
305
+ } else if (console.GetHatchMidPositionReleased ()) {
306
+ std::cout << " Comp Joy Input: Console: Piston Retract Released" << std::endl;
307
+ GetCreeperClimb ().PistonHold ();
308
+ }
309
+
310
+ #elif HATCH_CONTROL_TYPE==1
311
+
312
+ // Hatch controls for Competition 3 Kokomo.
313
+ // 3 buttons on right edge of console.
314
+ //
315
+ // Top button - GRAB hatch + TOP position + HOLD pid.
316
+ // Middle button - GRAB hatch + MID position + HOLD pid.
317
+ // Lower button - RELEASE hatch + rotate DOWN + no pid.
318
+
270
319
if (console.GetHatchTopPositionPressed ()) {
271
320
std::cout << " Comp Joy Input: Console: Hatch Top Position Pressed" << std::endl;
272
321
m_GrabHatchFromLoadingStation->Start ();
@@ -283,6 +332,53 @@ void Robot::CompetitionJoystickInput() {
283
332
m_Bling.SetBling (m_Bling.HatchPattern );
284
333
}
285
334
335
+ // Hatch controls for Compeition 2 Tippecanoe.
336
+ // 2 vertical black buttons.
337
+ //
338
+ // Top button - RAISE + GRAB hatch.
339
+ // Bottom button - LOWER + RELEASE hatch.
340
+
341
+ if (console.GetHatchGrabPressed ()) {
342
+ std::cout << " Comp Joy Input: Console: Hatch Grab Pressed" << std::endl;
343
+ m_RaiseHatch
344
+ ->Until ([]() { return Robot::m_OI.GetOperatorConsole ().GetHatchGrabReleased (); })
345
+ ->Start ();
346
+ m_Bling.SetBling (m_Bling.HatchPattern );
347
+ } else if (console.GetHatchReleasePressed ()) {
348
+ std::cout << " Comp Joy Input: Console: Hatch Release Pressed" << std::endl;
349
+ m_LowerHatch
350
+ ->Until ([]() { return Robot::m_OI.GetOperatorConsole ().GetHatchReleaseReleased (); })
351
+ ->Start ();
352
+ m_Bling.SetBling (m_Bling.HatchPattern );
353
+ }
354
+
355
+ if (console.GetOpenHatchGripperPressed ()) {
356
+ GetHatchMechanism ().ReleaseHatch ();
357
+ } else if (console.GetOpenHatchGripperReleased ()) {
358
+ GetHatchMechanism ().GrabHatch ();
359
+ }
360
+
361
+ // Piston controls for Competition 3 Kokomo.
362
+ // 2 vertical black buttons (originally for hatch)
363
+ // Top button - RETRACT piston.
364
+ // Bottom button - EXTEND piston.
365
+
366
+ if (console.GetCreeperExtendPistonPressed ()) {
367
+ std::cout << " Comp Joy Input: Console: Piston Extend Pressed" << std::endl;
368
+ GetCreeperClimb ().PistonExtend ();
369
+ } else if (console.GetCreeperExtendPistonReleased ()) {
370
+ std::cout << " Comp Joy Input: Console: Piston Extend Released" << std::endl;
371
+ GetCreeperClimb ().PistonHold ();
372
+ } else if (console.GetCreeperRetractPistonPressed ()) {
373
+ std::cout << " Comp Joy Input: Console: Piston Retract Pressed" << std::endl;
374
+ GetCreeperClimb ().PistonRetract ();
375
+ } else if (console.GetCreeperRetractPistonReleased ()) {
376
+ std::cout << " Comp Joy Input: Console: Piston Retract Released" << std::endl;
377
+ GetCreeperClimb ().PistonHold ();
378
+ }
379
+
380
+ #endif
381
+
286
382
if (console.GetCargoShootRocketTwoPressed ()) {
287
383
std::cout << " Comp Joy Input: Console: Rocket Shot (Level 2)" << std::endl;
288
384
m_ShootCargoForLevelTwoRocket->Start ();
@@ -292,7 +388,7 @@ void Robot::CompetitionJoystickInput() {
292
388
if (console.GetCreeperReadyArmPressed ()) {
293
389
std::cout << " Comp Joy Input: Console: Creeper Ready Arm Pressed" << std::endl;
294
390
m_ReadyCreeperArm->Start ();
295
- m_Bling.SetBling (m_Bling.Climb );
391
+ m_Bling.SetBling (m_Bling.ClimbReady );
296
392
} else if (console.GetCreeperClimbEnabled ()) {
297
393
std::cout << " Comp Joy Input: Console: Climb Sequence Pressed" << std::endl;
298
394
m_ClimbStep->Start ();
0 commit comments