-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDhsTeleopDirectionTest.java
More file actions
77 lines (64 loc) · 2.37 KB
/
Copy pathDhsTeleopDirectionTest.java
File metadata and controls
77 lines (64 loc) · 2.37 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
package org.firstinspires.ftc.teamcode;
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
import com.qualcomm.robotcore.hardware.DcMotorSimple;
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
import com.qualcomm.robotcore.hardware.Blinker;
import com.qualcomm.robotcore.hardware.Gyroscope;
import com.qualcomm.robotcore.hardware.DcMotor;
@TeleOp
public class DhsTeleopDirectionTest extends LinearOpMode {
private Blinker expansion_Hub_1;
private Gyroscope imu;
private DcMotor m0;
private DcMotor m1;
private DcMotor m2;
private DcMotor m3;
// todo: write your code here
public void runOpMode() {
m0 = hardwareMap.dcMotor.get("m0");
m1 = hardwareMap.dcMotor.get("m1");
m1.setDirection(DcMotorSimple.Direction.REVERSE);
m2 = hardwareMap.dcMotor.get("m2");
m2.setDirection(DcMotorSimple.Direction.REVERSE);
m3 = hardwareMap.dcMotor.get("m3");
m0.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
m1.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
m2.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
m3.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
while (!isStarted()) {
}
while (!isStopRequested()) {
float power = gamepad1.left_trigger;
if (gamepad1.dpad_up) {
m0.setPower(-power);
m1.setPower(-power);
m2.setPower(power);
m3.setPower(power);
}
else if (gamepad1.dpad_down) {
m0.setPower(power);
m1.setPower(power);
m2.setPower(-power);
m3.setPower(-power);
}
else if (gamepad1.dpad_left) {
m0.setPower(-power);
m1.setPower(power);
m2.setPower(-power);
m3.setPower(power);
}
else if (gamepad1.dpad_right) {
m0.setPower(power);
m1.setPower(-power);
m2.setPower(power);
m3.setPower(-power);
}
else {
m0.setPower(0);
m1.setPower(0);
m2.setPower(0);
m3.setPower(0);
}
}
}
}