Skip to content
This repository was archived by the owner on Sep 12, 2023. It is now read-only.

Commit 60e1391

Browse files
committed
cursed controls
1 parent 59e683d commit 60e1391

File tree

64 files changed

+739
-234
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+739
-234
lines changed

MeepMeep/build.gradle

+9-4
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,18 @@ java{
44
sourceCompatibility JavaVersion.VERSION_1_8
55
targetCompatibility JavaVersion.VERSION_1_8
66
}
7-
repositories {
8-
maven { url 'https://jitpack.io' }
9-
}
107

118
dependencies {
129
implementation 'org.apache.commons:commons-math3:3.6.1'
1310

14-
implementation 'com.github.NoahBres:MeepMeep:2.0.0'
11+
implementation 'com.github.noahbres:meepmeep:2.0.0'
12+
}
13+
repositories {
14+
mavenCentral()
15+
google() // Needed for androidx
16+
maven { url 'https://jitpack.io' }
17+
flatDir {
18+
dirs rootProject.file('libs')
19+
}
1520
}
1621

OspreyCode/src/main/java/org/firstinspires/ftc/teamcode/SingleDriverControls.java OspreyCode/src/main/java/org/firstinspires/ftc/teamcode/BaseControls.java

+46-27
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,34 @@
44
import com.technototes.library.control.CommandAxis;
55
import com.technototes.library.control.CommandButton;
66
import com.technototes.library.control.CommandGamepad;
7+
import com.technototes.library.control.CommandInput;
78
import com.technototes.library.control.Stick;
8-
import com.technototes.library.util.Alliance;
99

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;
1013
import org.firstinspires.ftc.teamcode.commands.cap.CapDownCommand;
1114
import org.firstinspires.ftc.teamcode.commands.carousel.CarouselLeftCommand;
1215
import org.firstinspires.ftc.teamcode.commands.carousel.CarouselRightCommand;
1316
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;
1618
import org.firstinspires.ftc.teamcode.commands.arm.BucketDumpVariableCommand;
1719
import org.firstinspires.ftc.teamcode.commands.drivebase.DriveCommand;
1820
import org.firstinspires.ftc.teamcode.commands.drivebase.DriveResetCommand;
1921
import org.firstinspires.ftc.teamcode.commands.drivebase.DriveSpeedCommand;
2022
import org.firstinspires.ftc.teamcode.commands.extension.ExtensionCollectCommand;
23+
import org.firstinspires.ftc.teamcode.commands.extension.ExtensionCommand;
2124
import org.firstinspires.ftc.teamcode.commands.extension.ExtensionLeftSideCommand;
2225
import org.firstinspires.ftc.teamcode.commands.extension.ExtensionOutCommand;
2326
import org.firstinspires.ftc.teamcode.commands.extension.ExtensionRightSideCommand;
2427
import org.firstinspires.ftc.teamcode.commands.extension.TurretTranslateCommand;
2528
import org.firstinspires.ftc.teamcode.commands.intake.IntakeInCommand;
2629
import org.firstinspires.ftc.teamcode.commands.intake.IntakeOutCommand;
2730
import org.firstinspires.ftc.teamcode.commands.lift.LiftCollectCommand;
31+
import org.firstinspires.ftc.teamcode.commands.lift.LiftCommand;
2832
import org.firstinspires.ftc.teamcode.commands.lift.LiftLevel1Command;
2933
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;
3135
import org.firstinspires.ftc.teamcode.commands.lift.LiftTranslateCommand;
3236

3337
import static org.firstinspires.ftc.teamcode.Robot.SubsystemConstants.CAP_CONNECTED;
@@ -38,16 +42,17 @@
3842
import static org.firstinspires.ftc.teamcode.Robot.SubsystemConstants.INTAKE_CONNECTED;
3943
import static org.firstinspires.ftc.teamcode.Robot.SubsystemConstants.LIFT_CONNECTED;
4044

41-
public class SingleDriverControls {
45+
public class BaseControls {
4246

43-
public CommandGamepad driverGamepad;
47+
public CommandGamepad driverGamepad, codriverGamepad;
4448

4549
public Robot robot;
4650

47-
public CommandAxis dumpAxis, toIntakeButton;
51+
public CommandAxis dumpAxis;
52+
public CommandInput<?> toIntakeButton;
4853
public CommandButton sharedHubButton, allianceHubButton;
4954

50-
public CommandButton liftAdjustUpButton, liftAdjustDownButton, slideAdjustInButton, slideAdjustOutButton;
55+
public CommandButton liftAdjustUpButton, liftAdjustDownButton, turretAdjustRightButton, turretAdjustLeftButton;
5156

5257
public CommandButton intakeInButton, intakeOutButton;
5358

@@ -58,9 +63,13 @@ public class SingleDriverControls {
5863
public Stick driveLeftStick, driveRightStick;
5964
public CommandButton resetGyroButton, snailSpeedButton;
6065

66+
public BaseControls(Robot r, CommandGamepad driver, CommandGamepad codriver) {
67+
this(r, driver, codriver, true);
68+
}
6169

62-
public SingleDriverControls(Robot r, CommandGamepad driver, CommandGamepad codriver) {
70+
public BaseControls(Robot r, CommandGamepad driver, CommandGamepad codriver, boolean bind) {
6371
driverGamepad = driver;
72+
codriverGamepad = codriver;
6473
robot = r;
6574

6675
dumpAxis = driverGamepad.leftTrigger.setTriggerThreshold(0.2);
@@ -70,8 +79,8 @@ public SingleDriverControls(Robot r, CommandGamepad driver, CommandGamepad codri
7079

7180
liftAdjustUpButton = driverGamepad.dpadUp;
7281
liftAdjustDownButton = driverGamepad.dpadDown;
73-
slideAdjustInButton = driverGamepad.dpadRight;
74-
slideAdjustOutButton = driverGamepad.dpadLeft;
82+
turretAdjustRightButton = driverGamepad.dpadRight;
83+
turretAdjustLeftButton = driverGamepad.dpadLeft;
7584

7685
intakeInButton = driverGamepad.cross;
7786
intakeOutButton = driverGamepad.circle;
@@ -88,27 +97,35 @@ public SingleDriverControls(Robot r, CommandGamepad driver, CommandGamepad codri
8897
capUpButton = driverGamepad.start;
8998
capDownButton = driverGamepad.back;
9099

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(){
91109
if (LIFT_CONNECTED) bindLiftControls();
92-
if (DEPOSIT_CONNECTED) bindDepositControls();
110+
if (DEPOSIT_CONNECTED) bindArmControls();
93111
if (DRIVE_CONNECTED) bindDriveControls();
94112
if (INTAKE_CONNECTED) bindIntakeControls();
95113
if (CAROUSEL_CONNECTED) bindCarouselControls();
96114
if (CAP_CONNECTED) bindCapControls();
97115
if (EXTENSION_CONNECTED) bindExtensionControls();
98116
}
99117

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));
106123

107124
}
108125

109126
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)));
112129
toIntakeButton.whenPressed(new WaitCommand(0.8).deadline(new LiftLevel1Command(robot.liftSubsystem)).andThen(new LiftCollectCommand(robot.liftSubsystem).withTimeout(1.5)));
113130
liftAdjustUpButton.whilePressed(new LiftTranslateCommand(robot.liftSubsystem, 50));
114131
liftAdjustDownButton.whilePressed(new LiftTranslateCommand(robot.liftSubsystem, -50));
@@ -131,10 +148,10 @@ public void bindIntakeControls() {
131148
}
132149

133150
public void bindCarouselControls() {
134-
carouselButton.whilePressedOnce(Alliance.Selector.selectOf(RobotConstants.getAlliance(),
151+
carouselButton.whilePressedOnce(RobotConstants.getAlliance().selectOf(
135152
new CarouselLeftCommand(robot.carouselSubsystem),
136153
new CarouselRightCommand(robot.carouselSubsystem)));
137-
carouselBackButton.whilePressedOnce(Alliance.Selector.selectOf(RobotConstants.getAlliance(),
154+
carouselBackButton.whilePressedOnce(RobotConstants.getAlliance().selectOf(
138155
new CarouselRightCommand(robot.carouselSubsystem),
139156
new CarouselLeftCommand(robot.carouselSubsystem)));
140157
}
@@ -144,14 +161,16 @@ public void bindCapControls() {
144161
}
145162

146163
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(
149166
new ExtensionRightSideCommand(robot.extensionSubsystem),
150167
new ExtensionLeftSideCommand(robot.extensionSubsystem)));
151168
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));
154171
}
155-
172+
protected LiftCommand liftCommand;
173+
protected ArmCommand armCommand;
174+
protected ExtensionCommand extensionCommand;
156175

157176
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
package org.firstinspires.ftc.teamcode;
2+
3+
import com.technototes.library.control.Binding;
4+
import com.technototes.library.control.CommandAxis;
5+
import com.technototes.library.control.CommandBinding;
6+
import com.technototes.library.control.CommandButton;
7+
import com.technototes.library.control.CommandGamepad;
8+
import com.technototes.library.control.CommandInput;
9+
import com.technototes.library.util.Enablable;
10+
11+
import org.firstinspires.ftc.teamcode.commands.arm.ArmAllianceCommand;
12+
import org.firstinspires.ftc.teamcode.commands.arm.ArmCommand;
13+
import org.firstinspires.ftc.teamcode.commands.arm.ArmInCommand;
14+
import org.firstinspires.ftc.teamcode.commands.arm.ArmSharedCommand;
15+
import org.firstinspires.ftc.teamcode.commands.arm.BucketDumpVariableCommand;
16+
import org.firstinspires.ftc.teamcode.commands.extension.ExtensionCollectCommand;
17+
import org.firstinspires.ftc.teamcode.commands.extension.ExtensionCommand;
18+
import org.firstinspires.ftc.teamcode.commands.extension.ExtensionLeftOutCommand;
19+
import org.firstinspires.ftc.teamcode.commands.extension.ExtensionLeftSideCommand;
20+
import org.firstinspires.ftc.teamcode.commands.extension.ExtensionOutCommand;
21+
import org.firstinspires.ftc.teamcode.commands.extension.ExtensionRightOutCommand;
22+
import org.firstinspires.ftc.teamcode.commands.extension.ExtensionRightSideCommand;
23+
import org.firstinspires.ftc.teamcode.commands.extension.ExtensionTranslateCommand;
24+
import org.firstinspires.ftc.teamcode.commands.lift.LiftCollectCommand;
25+
import org.firstinspires.ftc.teamcode.commands.lift.LiftCommand;
26+
import org.firstinspires.ftc.teamcode.commands.lift.LiftLevel2Command;
27+
import org.firstinspires.ftc.teamcode.commands.lift.LiftLevel3Command;
28+
import org.firstinspires.ftc.teamcode.commands.lift.LiftSharedCommand;
29+
import org.firstinspires.ftc.teamcode.subsystems.ArmSubsystem;
30+
import org.firstinspires.ftc.teamcode.subsystems.ExtensionSubsystem;
31+
import org.firstinspires.ftc.teamcode.subsystems.LiftSubsystem;
32+
33+
import java.util.function.Function;
34+
35+
public class ExpandedControls extends BaseControls implements Enablable<ExpandedControls> {
36+
37+
//more adj buttons
38+
public CommandButton slideTranslateOutButton, slideTranslateInButton;
39+
40+
public CommandAxis secondDumpAxis, secondIntakeButton;
41+
//strategy buttons
42+
public CommandInput sharedButton, stealButton, highButton, midButton, defenseButton;
43+
44+
public ExpandedControls(Robot r, CommandGamepad driver, CommandGamepad codriver) {
45+
super(r, driver, codriver, false);
46+
47+
liftAdjustUpButton = codriverGamepad.dpadUp;
48+
liftAdjustDownButton = codriverGamepad.dpadDown;
49+
slideTranslateInButton = codriverGamepad.dpadLeft;
50+
slideTranslateOutButton = codriverGamepad.dpadRight;
51+
turretAdjustLeftButton = codriverGamepad.leftBumper;
52+
turretAdjustRightButton = codriverGamepad.rightBumper;
53+
54+
secondDumpAxis = codriverGamepad.leftTrigger;
55+
secondIntakeButton = codriverGamepad.rightTrigger;
56+
57+
sharedButton = codriverGamepad.square;
58+
stealButton = codriverGamepad.cross;
59+
highButton = codriverGamepad.triangle;
60+
midButton = codriverGamepad.circle;
61+
defenseButton = codriver.start;
62+
63+
sharedHubButton.disable();
64+
65+
toIntakeButton = new CommandBinding(Binding.Type.SOME_ACTIVE, toIntakeButton, secondIntakeButton);
66+
67+
68+
bindControls();
69+
bindStrategyControls();
70+
}
71+
72+
@Override
73+
public void bindExtensionControls() {
74+
super.bindExtensionControls();
75+
slideTranslateInButton.whilePressed(new ExtensionTranslateCommand(robot.extensionSubsystem, 0.05));
76+
slideTranslateOutButton.whilePressed(new ExtensionTranslateCommand(robot.extensionSubsystem, -0.05));
77+
}
78+
79+
@Override
80+
public void bindArmControls() {
81+
super.bindArmControls();
82+
secondDumpAxis.whilePressedOnce(new BucketDumpVariableCommand(robot.armSubsystem, secondDumpAxis));
83+
}
84+
85+
public void bindStrategyControls() {
86+
allianceHubButton.whenPressed(this::enable);
87+
toIntakeButton.whenPressed(this::disable);
88+
sharedButton.whenPressed(() -> setStrategy(Strategy.SHARED));
89+
stealButton.whenPressed(() -> setStrategy(Strategy.STEAL_SHARED));
90+
highButton.whenPressed(() -> setStrategy(Strategy.HIGH_ALLIANCE));
91+
midButton.whenPressed(() -> setStrategy(Strategy.MID_ALLIANCE));
92+
defenseButton.whenPressed(() -> setStrategy(Strategy.DEFENDING));
93+
}
94+
95+
public void setStrategy(Strategy s) {
96+
liftCommand = s.getLiftCommand(robot);
97+
armCommand = s.getArmCommand(robot);
98+
extensionCommand = s.getExtensionCommand(robot);
99+
}
100+
101+
//enabling stuff so vvv cool
102+
public boolean enabled = false;
103+
104+
@Override
105+
public ExpandedControls enable() {
106+
codriverGamepad.rumbleBlips(2);
107+
driverGamepad.rumble(0.5);
108+
return Enablable.super.enable();
109+
110+
}
111+
112+
public ExpandedControls disable() {
113+
codriverGamepad.rumble(0.5);
114+
driverGamepad.rumbleBlips(2);
115+
return Enablable.super.disable();
116+
}
117+
118+
@Override
119+
public ExpandedControls setEnabled(boolean enable) {
120+
liftAdjustUpButton.setEnabled(enable);
121+
liftAdjustDownButton.setEnabled(enable);
122+
slideTranslateOutButton.setEnabled(enable);
123+
slideTranslateInButton.setEnabled(enable);
124+
turretAdjustLeftButton.setEnabled(enable);
125+
turretAdjustRightButton.setEnabled(enable);
126+
secondDumpAxis.setEnabled(enable);
127+
secondIntakeButton.setEnabled(enable);
128+
enabled = enable;
129+
return this;
130+
}
131+
132+
@Override
133+
public boolean isEnabled() {
134+
return enabled;
135+
}
136+
137+
public enum Strategy {
138+
SHARED(ArmSharedCommand::new, ExtensionRightSideCommand::new, ExtensionLeftSideCommand::new, LiftSharedCommand::new),
139+
STEAL_SHARED(ArmSharedCommand::new, ExtensionLeftOutCommand::new, ExtensionRightOutCommand::new, LiftSharedCommand::new),
140+
HIGH_ALLIANCE(ArmAllianceCommand::new, ExtensionOutCommand::new, LiftLevel3Command::new),
141+
MID_ALLIANCE(ArmAllianceCommand::new, ExtensionOutCommand::new, LiftLevel2Command::new),
142+
DEFENDING(ArmInCommand::new, ExtensionCollectCommand::new, LiftCollectCommand::new);
143+
Function<ArmSubsystem, ArmCommand> armCommand;
144+
Function<ExtensionSubsystem, ExtensionCommand> redExtensionCommand, blueExtensionCommand;
145+
Function<LiftSubsystem, LiftCommand> liftCommand;
146+
147+
Strategy(Function<ArmSubsystem, ArmCommand> arm, Function<ExtensionSubsystem, ExtensionCommand> red, Function<ExtensionSubsystem, ExtensionCommand> blue, Function<LiftSubsystem, LiftCommand> lift) {
148+
armCommand = arm;
149+
redExtensionCommand = red;
150+
blueExtensionCommand = blue;
151+
liftCommand = lift;
152+
}
153+
154+
Strategy(Function<ArmSubsystem, ArmCommand> arm, Function<ExtensionSubsystem, ExtensionCommand> extension, Function<LiftSubsystem, LiftCommand> lift) {
155+
armCommand = arm;
156+
redExtensionCommand = extension;
157+
blueExtensionCommand = extension;
158+
liftCommand = lift;
159+
}
160+
161+
public ArmCommand getArmCommand(Robot r) {
162+
return armCommand.apply(r.armSubsystem);
163+
}
164+
165+
public ExtensionCommand getExtensionCommand(Robot r) {
166+
return RobotConstants.getAlliance().selectOf(redExtensionCommand, blueExtensionCommand).apply(r.extensionSubsystem);
167+
}
168+
169+
public LiftCommand getLiftCommand(Robot r) {
170+
return liftCommand.apply(r.liftSubsystem);
171+
}
172+
}
173+
}

OspreyCode/src/main/java/org/firstinspires/ftc/teamcode/Hardware.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public Hardware() {
8181
liftMotor = new EncodedMotor<>(LIFT);
8282
}
8383
if(DEPOSIT_CONNECTED) {
84-
dumpServo = new Servo(DUMP).invert();
84+
dumpServo = new Servo(DUMP).invert().setStartingPosition(ArmSubsystem.ArmConstants.CARRY);
8585
armServo = new Servo(ARM).setStartingPosition(ArmSubsystem.ArmConstants.UP);
8686
}
8787
if(EXTENSION_CONNECTED){

0 commit comments

Comments
 (0)