-
Notifications
You must be signed in to change notification settings - Fork 0
/
Teleop
169 lines (150 loc) · 4.61 KB
/
Teleop
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
package org.firstinspires.ftc.teamcode.TeleOp;
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
import com.qualcomm.robotcore.hardware.CRServo;
import com.qualcomm.robotcore.hardware.DcMotor;
import com.qualcomm.robotcore.hardware.Gamepad;
import com.qualcomm.robotcore.hardware.Servo;
@TeleOp(name = "Teleop")
public class Teleop extends OpMode {
DcMotor fL;
DcMotor bL;
DcMotor fR;
DcMotor bR;
DcMotor Arm;
DcMotor Lift;
DcMotor Wrist;
Servo LeftServo;
Servo RightServo;
Servo DroneServo;
CRServo DroneLift;
@Override
public void init() {
fL = hardwareMap.dcMotor.get("fL");
bL = hardwareMap.dcMotor.get("bL");
fR = hardwareMap.dcMotor.get("fR");
bR = hardwareMap.dcMotor.get("bR");
Arm = hardwareMap.dcMotor.get("Arm");
LeftServo = hardwareMap.servo.get("LS");
RightServo = hardwareMap.servo.get("RS");
Lift = hardwareMap.dcMotor.get("Lift");
Wrist = hardwareMap.dcMotor.get("Wrist");
DroneLift = hardwareMap.crservo.get("droneLift");
DroneServo = hardwareMap.servo.get("Drone");
fL.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.FLOAT);
fR.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.FLOAT);
bL.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.FLOAT);
bR.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.FLOAT);
Arm.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
Lift.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
Wrist.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
}
@Override
public void loop() {
//Front back Left
if (Math.abs(-gamepad1.left_stick_y) > .2) {
fL.setPower(gamepad1.left_stick_y * 1);
bL.setPower(gamepad1.left_stick_y * 1);
} else {
fL.setPower(0);
bL.setPower(0);
}
//Front back Right
if (Math.abs(gamepad1.right_stick_y) > .2) {
fR.setPower(-gamepad1.right_stick_y * 1);
bR.setPower(-gamepad1.right_stick_y * 1);
} else {
fR.setPower(0);
bR.setPower(0);
}
//Side speed Right
if (gamepad1.right_bumper) {
fL.setPower(-.9);
bL.setPower(.9);
fR.setPower(-.9);
bR.setPower(.9);
}
else {
fL.setPower(0);
bL.setPower(0);
fR.setPower(0);
bR.setPower(0);
}
//Side speed Left
if (gamepad1.left_bumper) {
fL.setPower(.9);
bL.setPower(-.9);
fR.setPower(.9);
bR.setPower(-.9);
}
else {
fL.setPower(0);
bL.setPower(0);
fR.setPower(0);
bR.setPower(0);
}
//funny arm :P
if (Math.abs(-gamepad2.left_stick_y) > .1) {
Arm.setPower(gamepad2.left_stick_y * .5);
}
else {
Arm.setPower(0);
}
// Intake out
if (gamepad2.dpad_left) {
LeftServo.setPosition(0); //Neutral = 0
RightServo.setPosition(1); //Neutral = 1
}
else if (gamepad2.b){ //close all
LeftServo.setPosition(.1);
RightServo.setPosition(.92);
}
else if (gamepad2.a){ //open all
LeftServo.setPosition(.2);
RightServo.setPosition(.8);
}
// Intake in
else if (gamepad2.x) {
LeftServo.setPosition(.2);
} else if (gamepad2.y) {
RightServo.setPosition(.8);
}
//Wrist
if (Math.abs(-gamepad2.right_stick_y) > .1) {
Wrist.setPower(-gamepad2.right_stick_y * .9);
}
else {
Wrist.setPower(0);
}
//Lift
if (gamepad2.left_bumper) {
Lift.setPower(-.9);
}
else if (gamepad2.right_bumper) {
Lift.setPower(.9);
}
else {
Lift.setPower(0);
}
//Lift up
if (Math.abs(gamepad1.left_trigger) > .2) {
DroneLift.setPower(gamepad1.left_trigger * 0.8);
} else {
DroneLift.setPower(0);
}
//Lift Down
if (Math.abs(gamepad1.right_trigger) > .2) {
DroneLift.setPower(gamepad1.right_trigger * -0.8);
} else {
DroneLift.setPower(0);
}
//DoneLaunch
if (gamepad1.a) {
DroneServo.setPosition(0.3);
}
//Drone dock
if (gamepad1.b) {
DroneServo.setPosition(1);
}
}
}