-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFreightFrenzy.java
103 lines (90 loc) · 3.26 KB
/
FreightFrenzy.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
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
/*
Control Scheme:
Gamepad 1 - robot locomotion:
left stick - xy position of robot
right stick - rotation of robot
right bumper 1/2 speed slowmode
dpad - 1.0 power in any given direction
*/
package org.firstinspires.ftc.teamcode;
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
import com.qualcomm.robotcore.hardware.DcMotor;
@TeleOp
public class FreightFrenzy extends LinearOpMode {
private DcMotor frontLeft;
private DcMotor backLeft;
private DcMotor frontRight;
private DcMotor backRight;
private DcMotor CarouselSpinner;
@Override
public void runOpMode() {
float x;
float y;
float clockwise;
double fl;
double fr;
double bl;
double br;
frontLeft = hardwareMap.get(DcMotor.class,
"frontLeft");
backLeft = hardwareMap.get(DcMotor.class,
"backLeft");
frontRight = hardwareMap.get(DcMotor.class,
"frontRight");
backRight = hardwareMap.get(DcMotor.class,
"backRight");
CarouselSpinner = hardwareMap.get(DcMotor.class,
"CarouselSpinner");
frontRight.setDirection(DcMotor.Direction.REVERSE);
backRight.setDirection(DcMotor.Direction.REVERSE);
CarouselSpinner.setDirection(DcMotor.Direction.REVERSE);
waitForStart();
if (opModeIsActive()) {
frontLeft.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
backLeft.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
frontRight.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
backRight.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
CarouselSpinner.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
while (opModeIsActive()) {
x = gamepad1.left_stick_x;
y = gamepad1.left_stick_y;
clockwise = gamepad1.right_stick_x;
if (gamepad1.dpad_up) {
y = (float) - 1.0;
}
if (gamepad1.dpad_down) {
y = (float) 1.0;
}
if (gamepad1.dpad_right) {
x = (float) 1.0;
}
if (gamepad1.dpad_left) {
x = (float) - 1.0;
}
fl = y - x - clockwise;
fr = y + x + clockwise;
bl = y + x - clockwise;
br = y - x + clockwise;
if (gamepad1.right_bumper) {
fl /= 2;
fr /= 2;
bl /= 2;
br /= 2;
}
frontLeft.setPower(fl);
frontRight.setPower(fr);
backLeft.setPower(bl);
backRight.setPower(br);
if (gamepad1.a) {
CarouselSpinner.setPower((float)0.95);
} else if (gamepad1.b) {
CarouselSpinner.setPower((float)-0.95);
} else {
CarouselSpinner.setPower((float)0);
}
telemetry.update();
}
}
}
}