-
Notifications
You must be signed in to change notification settings - Fork 78
/
CommandOpMode.java
67 lines (53 loc) · 1.58 KB
/
CommandOpMode.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package com.arcrobotics.ftclib.command;
import com.arcrobotics.ftclib.gamepad.GamepadEx;
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
/**
* As opposed to the general WPILib-style Robot paradigm, FTCLib also offers a command opmode
* for individual opmodes.
*
* @author Jackson
*/
public abstract class CommandOpMode extends LinearOpMode {
protected GamepadEx driverOp = new GamepadEx(gamepad1);
protected GamepadEx toolOp = new GamepadEx(gamepad2);
/**
* Cancels all previous commands
*/
public void reset() {
CommandScheduler.getInstance().reset();
}
/**
* Runs the {@link CommandScheduler} instance
*/
public void run() {
CommandScheduler.getInstance().run();
}
/**
* Schedules {@link com.arcrobotics.ftclib.command.Command} objects to the scheduler
*/
public void schedule(Command... commands) {
CommandScheduler.getInstance().schedule(commands);
}
/**
* Registers {@link com.arcrobotics.ftclib.command.Subsystem} objects to the scheduler
*/
public void register(Subsystem... subsystems) {
CommandScheduler.getInstance().registerSubsystem(subsystems);
}
@Override
public void runOpMode() throws InterruptedException {
initialize();
// run the scheduler
while (!isStopRequested() && opModeIsActive()) {
run();
}
reset();
}
public abstract void initialize();
public static void disable() {
Robot.disable();
}
public static void enable() {
Robot.enable();
}
}