This repository has been archived by the owner on Jun 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DriveBlue.java
169 lines (133 loc) · 6.72 KB
/
DriveBlue.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
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;
import org.firstinspires.ftc.teamcode.libs.*;
import com.qualcomm.robotcore.robot.Robot;
import com.qualcomm.hardware.rev.RevBlinkinLedDriver;
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
import com.qualcomm.robotcore.hardware.HardwareMap;
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
import org.firstinspires.ftc.robotcore.external.navigation.VuforiaLocalizer;
import org.firstinspires.ftc.robotcore.external.tfod.TFObjectDetector;
import com.qualcomm.robotcore.hardware.Gyroscope;
import com.qualcomm.robotcore.hardware.DcMotor;
import com.qualcomm.robotcore.hardware.Servo;
import org.firstinspires.ftc.robotcore.external.hardware.camera.WebcamName;
import org.firstinspires.ftc.robotcore.external.ClassFactory;
import java.util.concurrent.Callable;
@TeleOp
public class DriveBlue extends Drive {
@Override
public void runPowerShots(){
// start shooter
(new TimedAutoTask(new Runnable() { public void run() {
//hardwareInterface.setShooterRPM(RobotConfig.RPMInts[1]);
hardwareInterface.runShooter(1);
}}, opModeActiveCallable, "Shoot", telemetry, 1400)).run();
// drive diagonally to shooting spot
if (runningPowerShots) autoNav.goForTime(750, 0, -1, 0, 0.5f);
// open the shooter gate
(new TimedAutoTask(new Runnable() { public void run() {
hardwareInterface.setPusherPosition(0.2f);
}}, opModeActiveCallable, "Gate down", telemetry, 250)).run();
// push rings into the shooter -- shoot!
(new TimedAutoTask(new Runnable() { public void run() {
hardwareInterface.fullIntake();
}}, opModeActiveCallable, "Shoot", telemetry, 100)).run();
(new TimedAutoTask(new Runnable() { public void run() {
hardwareInterface.setPusherPosition(-1);
}}, opModeActiveCallable, "Wait", telemetry, 600)).run();
// stop shooting
hardwareInterface.stopIntake();
// bump up shooter power
hardwareInterface.runShooter(2);
// drive diagonally to shooting spot
if (runningPowerShots) autoNav.goForTime(750, 0, -1, 0, 0.5f);
// open the shooter gate
(new TimedAutoTask(new Runnable() { public void run() {
hardwareInterface.setPusherPosition(0.2f);
}}, opModeActiveCallable, "Gate down", telemetry, 250)).run();
// push rings into the shooter -- shoot!
(new TimedAutoTask(new Runnable() { public void run() {
hardwareInterface.fullIntake();
}}, opModeActiveCallable, "Shoot", telemetry, 100)).run();
(new TimedAutoTask(new Runnable() { public void run() {
hardwareInterface.setPusherPosition(-1);
}}, opModeActiveCallable, "Wait", telemetry, 600)).run();
// stop shooting
hardwareInterface.stopIntake();
// drive diagonally to shooting spot
if (runningPowerShots) autoNav.goForTime(700, 0, -1, 0, 0.5f);
// open the shooter gate
(new TimedAutoTask(new Runnable() { public void run() {
hardwareInterface.setPusherPosition(0.2f);
}}, opModeActiveCallable, "Gate down", telemetry, 250)).run();
// push rings into the shooter -- shoot!
(new TimedAutoTask(new Runnable() { public void run() {
hardwareInterface.fullIntake();
}}, opModeActiveCallable, "Shoot", telemetry, 1000)).run();
// stop shooting
hardwareInterface.setPusherPosition(-1);
hardwareInterface.stopIntake();
hardwareInterface.stopShooter();
runningPowerShots = false;
}
@Override
public void runPowerShotsInPlace(){
hardwareInterface.runShooter(1);
//// Back up a few inches.
////autoNav.goForTime(500, -1, 0, 0, 0.4f);
// Go diagonally backward and to the right from the wall to our shooting spot.
autoNav.goForTime(1500, -0.1f, -1, 0.03f, 0.6f);
// Rotate clockwise to line up the first shot.
autoNav.goForTime(500, 0, 0, 1, 0.14f);
// Wait for the shooter to get up to speed
while(!hardwareInterface.shooterReady()){
try{java.lang.Thread.sleep(1);}
catch (Exception e){}
}
// open the shooter gate
(new TimedAutoTask(new Runnable() { public void run() {
hardwareInterface.setPusherPosition(0.2f);
}}, opModeActiveCallable, "Gate down", telemetry, 250)).run();
// push rings into the shooter -- shoot!
(new TimedAutoTask(new Runnable() { public void run() {
hardwareInterface.fullIntake();
}}, opModeActiveCallable, "Shoot", telemetry, 100)).run();
// Now that the first ring has been shot, slow the shooter down for the next 2 shots.
hardwareInterface.runShooter(2);
// Close the gate.
(new TimedAutoTask(new Runnable() { public void run() {
hardwareInterface.setPusherPosition(-1);
}}, opModeActiveCallable, "Wait", telemetry, 600)).run();
// Rotate clockwise to line up the second shot.
autoNav.goForTime(500, 0, 0, 1, 0.14f);
// open the shooter gate
(new TimedAutoTask(new Runnable() { public void run() {
hardwareInterface.setPusherPosition(0.2f);
}}, opModeActiveCallable, "Gate down", telemetry, 250)).run();
// push rings into the shooter -- shoot!
(new TimedAutoTask(new Runnable() { public void run() {
hardwareInterface.fullIntake();
}}, opModeActiveCallable, "Shoot", telemetry, 100)).run();
// Close the gate.
(new TimedAutoTask(new Runnable() { public void run() {
hardwareInterface.setPusherPosition(-1);
}}, opModeActiveCallable, "Wait", telemetry, 600)).run();
// Rotate clockwise to line up the third shot.
autoNav.goForTime(500, 0, 0, 1, 0.12f);
// open the shooter gate
(new TimedAutoTask(new Runnable() { public void run() {
hardwareInterface.setPusherPosition(0.2f);
}}, opModeActiveCallable, "Gate down", telemetry, 250)).run();
// push rings into the shooter -- shoot!
(new TimedAutoTask(new Runnable() { public void run() {
hardwareInterface.fullIntake();
}}, opModeActiveCallable, "Shoot", telemetry, 100)).run();
// Stop shooting.
hardwareInterface.setPusherPosition(-1);
hardwareInterface.stopIntake();
hardwareInterface.stopShooter();
// We are done running the Power Shots, don't do it again!
runningPowerShots = false;
}
}