@@ -11,12 +11,8 @@ CreeperClimb* Robot::m_CreeperClimb;
11
11
HatchMechanism* Robot::m_HatchMechanism;
12
12
13
13
// Initialize Commands - Intake
14
- GrabHatchFromDispenser* Robot::m_GrabHatchFromDispenser;
15
- ReleaseHatch* Robot::m_ReleaseHatch;
16
14
RotateCargoForCargoShip* Robot::m_RotateCargoForCargoShip;
17
15
RotateCargoForLevelOneRocket* Robot::m_RotateCargoForLevelOneRocket;
18
- RotateHatchForFloor* Robot::m_RotateHatchForFloor;
19
- RotateHatchForDispenser* Robot::m_RotateHatchForDispenser;
20
16
21
17
ShootCargoForCargoShip* Robot::m_ShootCargoForCargoShip;
22
18
ShootCargoForLevelOneRocket* Robot::m_ShootCargoForLevelOneRocket;
@@ -35,6 +31,13 @@ ClimbStep* Robot::m_ClimbStep;
35
31
DriveSandstormStepWithCargo* Robot::m_DriveSandstormStepWithCargo;
36
32
DriveSandstormStepWithHatch* Robot::m_DriveSandstormStepWithHatch;
37
33
34
+ // Initialize Commands - Hatch
35
+ LowerHatch* Robot::m_LowerHatch;
36
+ RaiseHatch* Robot::m_RaiseHatch;
37
+
38
+ GrabHatchFromLoadingStation* Robot::m_GrabHatchFromLoadingStation;
39
+ ReadyHatch* Robot::m_ReadyHatch;
40
+
38
41
// Initialize JSON reader
39
42
wpi::json Robot::m_JsonConfig;
40
43
@@ -65,12 +68,8 @@ Robot::Robot() {
65
68
m_DriveSandstormStepWithHatch = new DriveSandstormStepWithHatch ();
66
69
67
70
// Allocate and initialize commands - Intake
68
- m_GrabHatchFromDispenser = new GrabHatchFromDispenser ();
69
- m_ReleaseHatch = new ReleaseHatch ();
70
71
m_RotateCargoForCargoShip = new RotateCargoForCargoShip ();
71
72
m_RotateCargoForLevelOneRocket = new RotateCargoForLevelOneRocket ();
72
- m_RotateHatchForFloor = new RotateHatchForFloor ();
73
- m_RotateHatchForDispenser = new RotateHatchForDispenser ();
74
73
75
74
m_ShootCargoForCargoShip = new ShootCargoForCargoShip ();
76
75
m_ShootCargoForLevelOneRocket = new ShootCargoForLevelOneRocket ();
@@ -84,6 +83,10 @@ Robot::Robot() {
84
83
// Allocate and initialize commands -
85
84
m_ReadyCreeperArm = new ReadyCreeperArm ();
86
85
m_ClimbStep = new ClimbStep ();
86
+
87
+ // Allocate and initialize commands - Hatch
88
+ m_GrabHatchFromLoadingStation = new GrabHatchFromLoadingStation ();
89
+ m_ReadyHatch = new ReadyHatch ();
87
90
}
88
91
89
92
void Robot::RobotInit () {
@@ -150,6 +153,7 @@ void Robot::DisabledInit() {
150
153
151
154
GetCreeperClimb ().Disable ();
152
155
GetCargoIntake ().Disable ();
156
+ GetHatchMechanism ().Disable ();
153
157
154
158
// Clear pending commands out of scheduler.
155
159
// frc::Scheduler::GetInstance()->ResetAll();
@@ -165,6 +169,11 @@ void Robot::AutonomousInit() {
165
169
GetDriveTrain ().RunReset ();
166
170
GetCreeperClimb ().RunReset ();
167
171
GetCargoIntake ().RunReset ();
172
+
173
+ // Some positions of hatch mechanism are compliant, so disable
174
+ // PID/rotation instead of RunReset.
175
+ GetHatchMechanism ().StopRotation ();
176
+
168
177
m_CanSandstormStepDrive = true ;
169
178
170
179
m_OI.ClearButtonBuffer ();
@@ -242,16 +251,33 @@ void Robot::CompetitionJoystickInput() {
242
251
m_Bling.SetBling (m_Bling.CargoIntakePattern );
243
252
}
244
253
245
- if (console.GetHatchGrabReleased () || console.GetHatchReleaseReleased ()) {
246
- std::cout << " Comp Joy Input: Stop Hatch Rotate" << std::endl;
247
- GetHatchMechanism ().StopRotation ();
248
- } else if (console.GetHatchGrabPressed ()) {
254
+ if (console.GetHatchGrabPressed ()) {
249
255
std::cout << " Comp Joy Input: Console: Hatch Grab Pressed" << std::endl;
250
- GetHatchMechanism ().RaiseHatch ();
256
+ m_RaiseHatch
257
+ ->Until ([]() { return Robot::m_OI.GetOperatorConsole ().GetHatchGrabReleased (); })
258
+ ->Start ();
251
259
m_Bling.SetBling (m_Bling.HatchPattern );
252
260
} else if (console.GetHatchReleasePressed ()) {
253
261
std::cout << " Comp Joy Input: Console: Hatch Release Pressed" << std::endl;
254
- GetHatchMechanism ().LowerHatch ();
262
+ m_LowerHatch
263
+ ->Until ([]() { return Robot::m_OI.GetOperatorConsole ().GetHatchReleaseReleased (); })
264
+ ->Start ();
265
+ m_Bling.SetBling (m_Bling.HatchPattern );
266
+ }
267
+
268
+ if (console.GetHatchTopPositionPressed ()) {
269
+ std::cout << " Comp Joy Input: Console: Hatch Top Position Pressed" << std::endl;
270
+ m_GrabHatchFromLoadingStation->Start ();
271
+ m_Bling.SetBling (m_Bling.HatchPattern );
272
+ } else if (console.GetHatchMidPositionPressed ()) {
273
+ std::cout << " Comp Joy Input: Console: Hatch Mid Position Pressed" << std::endl;
274
+ m_ReadyHatch->Start ();
275
+ m_Bling.SetBling (m_Bling.HatchPattern );
276
+ } else if (console.GetHatchLowerPressed ()) {
277
+ std::cout << " Comp Joy Input: Console: Hatch Lower Pressed" << std::endl;
278
+ m_LowerHatch
279
+ ->Until ([]() { return Robot::m_OI.GetOperatorConsole ().GetHatchLowerReleased (); })
280
+ ->Start ();
255
281
m_Bling.SetBling (m_Bling.HatchPattern );
256
282
}
257
283
0 commit comments