forked from Yeetasoras/Decode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDriveOpMode.java
More file actions
138 lines (108 loc) · 5.46 KB
/
DriveOpMode.java
File metadata and controls
138 lines (108 loc) · 5.46 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
package org.firstinspires.ftc.teamcode;
import com.bylazar.telemetry.PanelsTelemetry;
import com.bylazar.telemetry.TelemetryManager;
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
import org.firstinspires.ftc.teamcode.subsystems.Loader;
import org.firstinspires.ftc.teamcode.subsystems.Intake;
import org.firstinspires.ftc.teamcode.subsystems.Shooter;
import dev.nextftc.core.commands.Command;
import dev.nextftc.core.commands.utility.InstantCommand;
import dev.nextftc.core.components.BindingsComponent;
import dev.nextftc.core.components.SubsystemComponent;
import dev.nextftc.ftc.Gamepads;
import dev.nextftc.ftc.NextFTCOpMode;
import dev.nextftc.ftc.components.BulkReadComponent;
import dev.nextftc.hardware.driving.FieldCentric;
import dev.nextftc.hardware.driving.MecanumDriverControlled;
import dev.nextftc.hardware.impl.Direction;
import dev.nextftc.hardware.impl.IMUEx;
import dev.nextftc.hardware.impl.MotorEx;
@TeleOp(name = "Drive")
public class DriveOpMode extends NextFTCOpMode {
private double xyScale = 0.75;
private double turnScale = 0.75;
private TelemetryManager panelsTelemetry;
public DriveOpMode() {
addComponents(
new SubsystemComponent(Shooter.INSTANCE, Loader.INSTANCE, Intake.INSTANCE),
BulkReadComponent.INSTANCE,
BindingsComponent.INSTANCE
);
}
// change the names and directions to suit your robot
private final MotorEx frontLeftMotor = new MotorEx("frontleft").brakeMode();
private final MotorEx backLeftMotor = new MotorEx("backleft").brakeMode();
private final MotorEx frontRightMotor = new MotorEx("frontright").reversed().brakeMode();
private final MotorEx backRightMotor = new MotorEx("backright").reversed().brakeMode();
private IMUEx imu = new IMUEx("imu", Direction.DOWN, Direction.LEFT).zeroed();
@Override
public void onInit() {
panelsTelemetry = PanelsTelemetry.INSTANCE.getTelemetry();
gamepad1.setLedColor(0, 255, 0, 120000);
telemetry.addLine("Ready");
telemetry.update();
}
@Override
public void onStartButtonPressed() {
Command driverControlled = new MecanumDriverControlled(
frontLeftMotor,
frontRightMotor,
backLeftMotor,
backRightMotor,
Gamepads.gamepad1().leftStickY().negate().mapToRange(doubleValue -> doubleValue * xyScale),
Gamepads.gamepad1().leftStickX().mapToRange(doubleValue -> doubleValue * xyScale),
Gamepads.gamepad1().rightStickX().mapToRange(doubleValue -> doubleValue * turnScale)
//, new FieldCentric(imu)
);
driverControlled.schedule();
Shooter.INSTANCE.spinUpMid.schedule();
//Drive scales
// Gamepads.gamepad1().rightBumper()
// .whenBecomesTrue(new InstantCommand(() -> xyScale = 0.25))
// .whenBecomesTrue(new InstantCommand(() -> turnScale = 0.25))
// .whenBecomesTrue(new InstantCommand(() -> Gamepads.gamepad1().getGamepad().invoke().setLedColor(255, 0, 0, 120000)));
//
// Gamepads.gamepad1().leftBumper()
// .whenBecomesTrue(new InstantCommand(() -> xyScale = 1))
// .whenBecomesTrue(new InstantCommand(() -> turnScale = 1))
// .whenBecomesTrue(new InstantCommand(() -> Gamepads.gamepad1().getGamepad().invoke().setLedColor(0, 0, 255, 120000)));
Gamepads.gamepad1().leftBumper()
.or(Gamepads.gamepad1().rightBumper())
.whenFalse(new InstantCommand(() -> xyScale = 0.75))
.whenFalse(new InstantCommand(() -> xyScale = 0.75))
.whenBecomesFalse(new InstantCommand(() -> Gamepads.gamepad1().getGamepad().invoke().setLedColor(0, 255, 0, 120000)));
Gamepads.gamepad1().rightBumper()
.or(Gamepads.gamepad1().rightBumper())
.whenFalse(new InstantCommand(() -> xyScale = 1))
.whenFalse(new InstantCommand(() -> xyScale = 1))
.whenBecomesFalse(new InstantCommand(() -> Gamepads.gamepad1().getGamepad().invoke().setLedColor(0, 255, 0, 120000)));
Gamepads.gamepad1().share()
.whenBecomesTrue(new InstantCommand(() -> imu.zeroed()))
.whenBecomesTrue(new InstantCommand(() -> Gamepads.gamepad1().getGamepad().invoke().rumble(250)));
//INTAKE COMMANDS
Gamepads.gamepad2().dpadUp()
.whenBecomesTrue(Shooter.INSTANCE.spinUpHigh);
Gamepads.gamepad2().dpadRight()
.whenBecomesTrue(Shooter.INSTANCE.spinUpMid);
Gamepads.gamepad2().dpadDown()
.whenBecomesTrue(Shooter.INSTANCE.spinUpLow);
Gamepads.gamepad2().dpadLeft()
.whenBecomesTrue(Shooter.INSTANCE.cutPower);
Gamepads.gamepad2().rightBumper()
.whenTrue(Intake.INSTANCE.spinUp)
.whenBecomesFalse(Intake.INSTANCE.cutPower);
Gamepads.gamepad2().square()
.whenTrue(Loader.INSTANCE.spinUp)
.whenBecomesFalse(Loader.INSTANCE.cutPower);
Gamepads.gamepad2().triangle()
.whenBecomesTrue(Loader.INSTANCE.feedOut)
.whenBecomesTrue(Intake.INSTANCE.pushOut)
.whenBecomesFalse(Loader.INSTANCE.cutPower)
.whenBecomesFalse(Intake.INSTANCE.cutPower);
}
@Override
public void onUpdate() {
panelsTelemetry.update(telemetry);
telemetry.update();
}
}