4
4
import com .technototes .library .control .CommandAxis ;
5
5
import com .technototes .library .control .CommandButton ;
6
6
import com .technototes .library .control .CommandGamepad ;
7
+ import com .technototes .library .control .CommandInput ;
7
8
import com .technototes .library .control .Stick ;
8
- import com .technototes .library .util .Alliance ;
9
9
10
+ import org .firstinspires .ftc .teamcode .commands .arm .ArmCommand ;
11
+ import org .firstinspires .ftc .teamcode .commands .arm .ArmRaiseInCommand ;
12
+ import org .firstinspires .ftc .teamcode .commands .arm .ArmSharedCommand ;
10
13
import org .firstinspires .ftc .teamcode .commands .cap .CapDownCommand ;
11
14
import org .firstinspires .ftc .teamcode .commands .carousel .CarouselLeftCommand ;
12
15
import org .firstinspires .ftc .teamcode .commands .carousel .CarouselRightCommand ;
13
16
import org .firstinspires .ftc .teamcode .commands .arm .ArmInCommand ;
14
- import org .firstinspires .ftc .teamcode .commands .arm .ArmOutCommand ;
15
- import org .firstinspires .ftc .teamcode .commands .arm .ArmRaiseCommand ;
17
+ import org .firstinspires .ftc .teamcode .commands .arm .ArmAllianceCommand ;
16
18
import org .firstinspires .ftc .teamcode .commands .arm .BucketDumpVariableCommand ;
17
19
import org .firstinspires .ftc .teamcode .commands .drivebase .DriveCommand ;
18
20
import org .firstinspires .ftc .teamcode .commands .drivebase .DriveResetCommand ;
19
21
import org .firstinspires .ftc .teamcode .commands .drivebase .DriveSpeedCommand ;
20
22
import org .firstinspires .ftc .teamcode .commands .extension .ExtensionCollectCommand ;
23
+ import org .firstinspires .ftc .teamcode .commands .extension .ExtensionCommand ;
21
24
import org .firstinspires .ftc .teamcode .commands .extension .ExtensionLeftSideCommand ;
22
25
import org .firstinspires .ftc .teamcode .commands .extension .ExtensionOutCommand ;
23
26
import org .firstinspires .ftc .teamcode .commands .extension .ExtensionRightSideCommand ;
24
27
import org .firstinspires .ftc .teamcode .commands .extension .TurretTranslateCommand ;
25
28
import org .firstinspires .ftc .teamcode .commands .intake .IntakeInCommand ;
26
29
import org .firstinspires .ftc .teamcode .commands .intake .IntakeOutCommand ;
27
30
import org .firstinspires .ftc .teamcode .commands .lift .LiftCollectCommand ;
31
+ import org .firstinspires .ftc .teamcode .commands .lift .LiftCommand ;
28
32
import org .firstinspires .ftc .teamcode .commands .lift .LiftLevel1Command ;
29
33
import org .firstinspires .ftc .teamcode .commands .lift .LiftLevel3Command ;
30
- import org .firstinspires .ftc .teamcode .commands .lift .LiftNeutralCommand ;
34
+ import org .firstinspires .ftc .teamcode .commands .lift .LiftSharedCommand ;
31
35
import org .firstinspires .ftc .teamcode .commands .lift .LiftTranslateCommand ;
32
36
33
37
import static org .firstinspires .ftc .teamcode .Robot .SubsystemConstants .CAP_CONNECTED ;
38
42
import static org .firstinspires .ftc .teamcode .Robot .SubsystemConstants .INTAKE_CONNECTED ;
39
43
import static org .firstinspires .ftc .teamcode .Robot .SubsystemConstants .LIFT_CONNECTED ;
40
44
41
- public class SingleDriverControls {
45
+ public class BaseControls {
42
46
43
- public CommandGamepad driverGamepad ;
47
+ public CommandGamepad driverGamepad , codriverGamepad ;
44
48
45
49
public Robot robot ;
46
50
47
- public CommandAxis dumpAxis , toIntakeButton ;
51
+ public CommandAxis dumpAxis ;
52
+ public CommandInput <?> toIntakeButton ;
48
53
public CommandButton sharedHubButton , allianceHubButton ;
49
54
50
- public CommandButton liftAdjustUpButton , liftAdjustDownButton , slideAdjustInButton , slideAdjustOutButton ;
55
+ public CommandButton liftAdjustUpButton , liftAdjustDownButton , turretAdjustRightButton , turretAdjustLeftButton ;
51
56
52
57
public CommandButton intakeInButton , intakeOutButton ;
53
58
@@ -58,9 +63,13 @@ public class SingleDriverControls {
58
63
public Stick driveLeftStick , driveRightStick ;
59
64
public CommandButton resetGyroButton , snailSpeedButton ;
60
65
66
+ public BaseControls (Robot r , CommandGamepad driver , CommandGamepad codriver ) {
67
+ this (r , driver , codriver , true );
68
+ }
61
69
62
- public SingleDriverControls (Robot r , CommandGamepad driver , CommandGamepad codriver ) {
70
+ public BaseControls (Robot r , CommandGamepad driver , CommandGamepad codriver , boolean bind ) {
63
71
driverGamepad = driver ;
72
+ codriverGamepad = codriver ;
64
73
robot = r ;
65
74
66
75
dumpAxis = driverGamepad .leftTrigger .setTriggerThreshold (0.2 );
@@ -70,8 +79,8 @@ public SingleDriverControls(Robot r, CommandGamepad driver, CommandGamepad codri
70
79
71
80
liftAdjustUpButton = driverGamepad .dpadUp ;
72
81
liftAdjustDownButton = driverGamepad .dpadDown ;
73
- slideAdjustInButton = driverGamepad .dpadRight ;
74
- slideAdjustOutButton = driverGamepad .dpadLeft ;
82
+ turretAdjustRightButton = driverGamepad .dpadRight ;
83
+ turretAdjustLeftButton = driverGamepad .dpadLeft ;
75
84
76
85
intakeInButton = driverGamepad .cross ;
77
86
intakeOutButton = driverGamepad .circle ;
@@ -88,27 +97,35 @@ public SingleDriverControls(Robot r, CommandGamepad driver, CommandGamepad codri
88
97
capUpButton = driverGamepad .start ;
89
98
capDownButton = driverGamepad .back ;
90
99
100
+ armCommand = new ArmAllianceCommand (robot .armSubsystem );
101
+ extensionCommand = new ExtensionOutCommand (robot .extensionSubsystem );
102
+ liftCommand = new LiftLevel3Command (robot .liftSubsystem );
103
+ if (bind ) bindControls ();
104
+
105
+
106
+ }
107
+
108
+ public void bindControls (){
91
109
if (LIFT_CONNECTED ) bindLiftControls ();
92
- if (DEPOSIT_CONNECTED ) bindDepositControls ();
110
+ if (DEPOSIT_CONNECTED ) bindArmControls ();
93
111
if (DRIVE_CONNECTED ) bindDriveControls ();
94
112
if (INTAKE_CONNECTED ) bindIntakeControls ();
95
113
if (CAROUSEL_CONNECTED ) bindCarouselControls ();
96
114
if (CAP_CONNECTED ) bindCapControls ();
97
115
if (EXTENSION_CONNECTED ) bindExtensionControls ();
98
116
}
99
117
100
-
101
- public void bindDepositControls () {
102
- dumpAxis .whilePressedOnce (new BucketDumpVariableCommand (robot .depositSubsystem , dumpAxis ).asConditional (EXTENSION_CONNECTED ? robot .extensionSubsystem ::isSlideOut : ()->true ));
103
- toIntakeButton .whenPressed (new ArmRaiseCommand (robot .depositSubsystem ).sleep (0.3 ).andThen (new ArmInCommand (robot .depositSubsystem )));
104
- allianceHubButton .whenPressed (new ArmOutCommand (robot .depositSubsystem ));
105
- sharedHubButton .whenPressed (new ArmOutCommand (robot .depositSubsystem ));
118
+ public void bindArmControls () {
119
+ dumpAxis .whilePressedOnce (new BucketDumpVariableCommand (robot .armSubsystem , dumpAxis ).asConditional (EXTENSION_CONNECTED ? robot .extensionSubsystem ::isSlideOut : ()->true ));
120
+ toIntakeButton .whenPressed (new ArmRaiseInCommand (robot .armSubsystem ).andThen (new ArmInCommand (robot .armSubsystem )));
121
+ allianceHubButton .whenPressed (armCommand );
122
+ sharedHubButton .whenPressed (new ArmSharedCommand (robot .armSubsystem ));
106
123
107
124
}
108
125
109
126
public void bindLiftControls () {
110
- sharedHubButton .whenPressed (new WaitCommand (0.3 ).andThen (new LiftNeutralCommand (robot .liftSubsystem ).withTimeout (1 .5 )));
111
- allianceHubButton .whenPressed (new WaitCommand (0.3 ).andThen (new LiftLevel3Command ( robot . liftSubsystem ). withTimeout (1.5 )));
127
+ sharedHubButton .whenPressed (new WaitCommand (0.3 ).andThen (new LiftSharedCommand (robot .liftSubsystem ).withTimeout (0 .5 )));
128
+ allianceHubButton .whenPressed (new WaitCommand (0.3 ).andThen (liftCommand . withTimeout (1 )));
112
129
toIntakeButton .whenPressed (new WaitCommand (0.8 ).deadline (new LiftLevel1Command (robot .liftSubsystem )).andThen (new LiftCollectCommand (robot .liftSubsystem ).withTimeout (1.5 )));
113
130
liftAdjustUpButton .whilePressed (new LiftTranslateCommand (robot .liftSubsystem , 50 ));
114
131
liftAdjustDownButton .whilePressed (new LiftTranslateCommand (robot .liftSubsystem , -50 ));
@@ -131,10 +148,10 @@ public void bindIntakeControls() {
131
148
}
132
149
133
150
public void bindCarouselControls () {
134
- carouselButton .whilePressedOnce (Alliance . Selector . selectOf ( RobotConstants .getAlliance (),
151
+ carouselButton .whilePressedOnce (RobotConstants .getAlliance (). selectOf (
135
152
new CarouselLeftCommand (robot .carouselSubsystem ),
136
153
new CarouselRightCommand (robot .carouselSubsystem )));
137
- carouselBackButton .whilePressedOnce (Alliance . Selector . selectOf ( RobotConstants .getAlliance (),
154
+ carouselBackButton .whilePressedOnce (RobotConstants .getAlliance (). selectOf (
138
155
new CarouselRightCommand (robot .carouselSubsystem ),
139
156
new CarouselLeftCommand (robot .carouselSubsystem )));
140
157
}
@@ -144,14 +161,16 @@ public void bindCapControls() {
144
161
}
145
162
146
163
public void bindExtensionControls () {
147
- allianceHubButton .whenPressed (new ExtensionOutCommand ( robot . extensionSubsystem ) );
148
- sharedHubButton .whenPressed (Alliance . Selector . selectOf ( RobotConstants .getAlliance (),
164
+ allianceHubButton .whenPressed (extensionCommand );
165
+ sharedHubButton .whenPressed (RobotConstants .getAlliance (). selectOf (
149
166
new ExtensionRightSideCommand (robot .extensionSubsystem ),
150
167
new ExtensionLeftSideCommand (robot .extensionSubsystem )));
151
168
toIntakeButton .whenPressed (new ExtensionCollectCommand (robot .extensionSubsystem ));
152
- slideAdjustOutButton .whilePressed (new TurretTranslateCommand (robot .extensionSubsystem , -0.03 ));
153
- slideAdjustInButton .whilePressed (new TurretTranslateCommand (robot .extensionSubsystem , 0.03 ));
169
+ turretAdjustLeftButton .whilePressed (new TurretTranslateCommand (robot .extensionSubsystem , -0.05 ));
170
+ turretAdjustRightButton .whilePressed (new TurretTranslateCommand (robot .extensionSubsystem , 0.05 ));
154
171
}
155
-
172
+ protected LiftCommand liftCommand ;
173
+ protected ArmCommand armCommand ;
174
+ protected ExtensionCommand extensionCommand ;
156
175
157
176
}
0 commit comments