Skip to content

Commit ede598a

Browse files
TechnototesLaptopkevinfrei
authored andcommitted
hoops controls for diff controllers
1 parent a894ffa commit ede598a

File tree

3 files changed

+132
-2
lines changed

3 files changed

+132
-2
lines changed
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
package org.firstinspires.ftc.hoops.controllers;
2+
3+
import com.technototes.library.command.CommandScheduler;
4+
import com.technototes.library.control.CommandAxis;
5+
import com.technototes.library.control.CommandButton;
6+
import com.technototes.library.control.CommandGamepad;
7+
import com.technototes.library.control.Stick;
8+
import org.firstinspires.ftc.hoops.Robot;
9+
import org.firstinspires.ftc.hoops.Setup;
10+
import org.firstinspires.ftc.hoops.commands.EZCmd;
11+
import org.firstinspires.ftc.hoops.commands.IntakeAndLaunchCommand;
12+
import org.firstinspires.ftc.hoops.commands.IntakeCommands;
13+
import org.firstinspires.ftc.hoops.commands.JoystickDriveCommand;
14+
import org.firstinspires.ftc.hoops.commands.LaunchCommands;
15+
16+
public class AllinOneController {
17+
18+
public Robot robot;
19+
public CommandGamepad gamepad;
20+
21+
public Stick driveLeftStick, driveRightStick;
22+
public CommandButton resetGyroButton, turboButton, snailButton;
23+
public CommandButton override;
24+
public CommandAxis driveStraighten;
25+
public CommandButton launch;
26+
public CommandButton intake;
27+
public CommandButton intakeandlaunch;
28+
29+
public AllinOneController(CommandGamepad g, Robot r) {
30+
this.robot = r;
31+
gamepad = g;
32+
33+
AssignNamedControllerButton();
34+
if (Setup.Connected.DRIVEBASE) {
35+
bindDriveControls();
36+
}
37+
if (Setup.Connected.LAUNCHER) {
38+
bindLaunchControls();
39+
}
40+
if (Setup.Connected.INTAKE) {
41+
bindIntakeControls();
42+
}
43+
}
44+
45+
private void AssignNamedControllerButton() {
46+
resetGyroButton = gamepad.ps_options;
47+
driveLeftStick = gamepad.leftStick;
48+
driveRightStick = gamepad.rightStick;
49+
driveStraighten = gamepad.rightTrigger;
50+
turboButton = gamepad.leftBumper;
51+
snailButton = gamepad.rightBumper;
52+
launch = gamepad.ps_square;
53+
intake = gamepad.ps_circle;
54+
intakeandlaunch = gamepad.ps_triangle;
55+
}
56+
57+
public void bindDriveControls() {
58+
CommandScheduler.scheduleJoystick(
59+
new JoystickDriveCommand(
60+
robot.drivebaseSubsystem,
61+
driveLeftStick,
62+
driveRightStick,
63+
driveStraighten
64+
)
65+
);
66+
turboButton.whenPressed(EZCmd.Drive.TurboMode(robot.drivebaseSubsystem));
67+
turboButton.whenReleased(EZCmd.Drive.NormalMode(robot.drivebaseSubsystem));
68+
snailButton.whenPressed(EZCmd.Drive.SnailMode(robot.drivebaseSubsystem));
69+
snailButton.whenReleased(EZCmd.Drive.NormalMode(robot.drivebaseSubsystem));
70+
71+
resetGyroButton.whenPressed(EZCmd.Drive.ResetGyro(robot.drivebaseSubsystem));
72+
}
73+
74+
public void bindLaunchControls() {
75+
launch.whenPressed(LaunchCommands.launchCommand(robot));
76+
launch.whenReleased(LaunchCommands.stopLaunchCommand(robot));
77+
intakeandlaunch.whenPressed(IntakeAndLaunchCommand.IntakeAndLaunch(robot));
78+
intakeandlaunch.whenReleased(IntakeAndLaunchCommand.IntakeAndLaunchStop(robot));
79+
}
80+
81+
public void bindIntakeControls() {
82+
intake.whenPressed(IntakeCommands.intakeCommand(robot));
83+
intake.whenReleased(IntakeCommands.stopIntakeCommand(robot));
84+
}
85+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package org.firstinspires.ftc.hoops.controllers;
2+
3+
import com.acmerobotics.dashboard.FtcDashboard;
4+
import com.acmerobotics.dashboard.telemetry.MultipleTelemetry;
5+
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
6+
import com.technototes.library.command.CommandScheduler;
7+
import com.technototes.library.structure.CommandOpMode;
8+
import com.technototes.library.util.Alliance;
9+
import org.firstinspires.ftc.hoops.Hardware;
10+
import org.firstinspires.ftc.hoops.Robot;
11+
import org.firstinspires.ftc.hoops.Setup;
12+
import org.firstinspires.ftc.hoops.commands.EZCmd;
13+
14+
@TeleOp(name = "Driving w/Turbo!")
15+
@SuppressWarnings("unused")
16+
public class TwoControllers extends CommandOpMode {
17+
18+
public Robot robot;
19+
public org.firstinspires.ftc.hoops.controllers.DriverController controlsDriver;
20+
public org.firstinspires.ftc.hoops.controllers.OperatorController controlsOperator;
21+
public Hardware hardware;
22+
23+
@Override
24+
public void uponInit() {
25+
telemetry = new MultipleTelemetry(telemetry, FtcDashboard.getInstance().getTelemetry());
26+
hardware = new Hardware(hardwareMap);
27+
robot = new Robot(hardware);
28+
controlsOperator = new org.firstinspires.ftc.hoops.controllers.OperatorController(
29+
codriverGamepad,
30+
robot
31+
);
32+
if (Setup.Connected.DRIVEBASE) {
33+
controlsDriver = new org.firstinspires.ftc.hoops.controllers.DriverController(
34+
driverGamepad,
35+
robot
36+
);
37+
38+
CommandScheduler.scheduleForState(
39+
EZCmd.Drive.ResetGyro(robot.drivebaseSubsystem),
40+
OpModeState.INIT
41+
);
42+
}
43+
}
44+
}

Hoops/src/main/java/org/firstinspires/ftc/hoops/opmodes/tele/LaunchTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import com.technototes.library.structure.CommandOpMode;
88
import org.firstinspires.ftc.hoops.Hardware;
99
import org.firstinspires.ftc.hoops.Robot;
10+
import org.firstinspires.ftc.hoops.controllers.AllinOneController;
1011
import org.firstinspires.ftc.hoops.controllers.DriverController;
1112
import org.firstinspires.ftc.hoops.controllers.OperatorController;
1213

@@ -17,13 +18,13 @@ public class LaunchTest extends CommandOpMode implements Loggable {
1718
public Hardware hardware;
1819
public Robot robot;
1920

20-
public OperatorController operator;
21+
public AllinOneController operator;
2122

2223
@Override
2324
public void uponInit() {
2425
telemetry = new MultipleTelemetry(telemetry, FtcDashboard.getInstance().getTelemetry());
2526
hardware = new Hardware(hardwareMap);
2627
robot = new Robot(hardware);
27-
operator = new OperatorController(driverGamepad, robot);
28+
operator = new AllinOneController(driverGamepad, robot);
2829
}
2930
}

0 commit comments

Comments
 (0)