forked from FIRST-Tech-Challenge/FtcRobotController
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAutoWarehouseBlue.java
More file actions
123 lines (94 loc) · 4.02 KB
/
AutoWarehouseBlue.java
File metadata and controls
123 lines (94 loc) · 4.02 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
package org.firstinspires.ftc.teamcode;
import org.firstinspires.ftc.robotcore.external.navigation.AngleUnit;
import org.firstinspires.ftc.robotcore.external.navigation.AxesOrder;
import org.firstinspires.ftc.robotcore.external.navigation.AxesReference;
import org.firstinspires.ftc.robotcore.external.navigation.Orientation;
import org.firstinspires.ftc.teamcode.assemblies.Robot;
import org.firstinspires.ftc.teamcode.libs.teamUtil;
import com.qualcomm.hardware.bosch.BNO055IMU;
import com.qualcomm.robotcore.eventloop.opmode.Disabled;
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
import com.qualcomm.robotcore.util.RobotLog;
import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
@Disabled
@Autonomous(name="Autonomous Warehouse Blue")
public class AutoWarehouseBlue extends LinearOpMode {
public static void log(String logString) {
RobotLog.d("19743LOG:" + Thread.currentThread().getStackTrace()[3].getMethodName() + ": " + logString);
}
Robot robot;
@Override
public void runOpMode() {
teamUtil.init(this);
teamUtil.alliance = teamUtil.Alliance.BLUE;
teamUtil.telemetry.addLine("Initializing Op Mode...please wait");
teamUtil.telemetry.update();
robot = new Robot();
robot.armsCalibrated =false;
//TSE Detector and all assemblies are intialized
robot.init(true);
robot.detector.initialize();
robot.detector.activate();
int lastDetection = 0;
int newDetection;
while (!opModeIsActive()) {
teamUtil.pause(250);
newDetection = robot.detector.warehouseDetect();
if (newDetection > 0) {
lastDetection = newDetection;
}
telemetry.addData("Detection Value: ", lastDetection);
telemetry.update();
}
waitForStart();
//takes a starting IMU reading and a starting SystemTime reading
double startingIMU = robot.drive.getIMUHeading();
long startingTime = System.currentTimeMillis();
if (lastDetection == 1) {
robot.outakeArm.runToFirstLevelAuto();
}
else if (lastDetection == 2) {
robot.outakeArm.runToSecondLevelAuto();
}
else if (lastDetection == 3) {
robot.outakeArm.runToThirdLevelAuto();
}
robot.drive.moveInches(.35,3.5);
robot.drive.spinRightWithIMUV2(35,.4);
robot.drive.moveInches(.3,25);
robot.outakeArm.spinnerOutput();
teamUtil.pause(1000);
robot.outakeArm.spinnerStop();
robot.drive.moveBackInches(.25,9);
robot.drive.spinLeftWithIMUV2(115,.3);
robot.outakeArm.runToSharedHub();
robot.drive.moveInches(.45,40);
//FROM HERE BELOW IS EXPERIMENTAL; PICKING UP FREIGHT CODE
//uses starting IMU value to figure out where to turn (so that it is oriented towards warehouse)
double degreesNeeded = startingIMU-45;
double degreesNeededInverted = degreesNeeded*-1;
robot.outakeArm.runToGround();
robot.drive.spinLeftWithIMUV2(degreesNeededInverted, .25);
robot.outakeArm.spinnerIntake();
robot.drive.moveInches(.25,15);
robot.outakeArm.spinnerStop();
robot.outakeArm.runToThirdLevel();
robot.drive.moveBackInches(.25,15);
robot.drive.spinLeftWithIMUV2(135,.25);
robot.drive.moveInches(.45,44);
robot.drive.spinLeftWithIMUV2(65,.25);
robot.drive.moveInches(.4,7);
robot.outakeArm.spinnerOutput();
teamUtil.pause(1000);
robot.outakeArm.spinnerStop();
robot.drive.moveBackInches(.4,6);
robot.drive.spinLeftWithIMUV2(110,.45);
robot.outakeArm.runToSharedHub();
robot.drive.moveInches(.75,52);
//uses system time to identify whether or not crash is likely
long timeLeft = 30000-(System.currentTimeMillis()-startingTime);
robot.outakeArm.runToGround();
teamUtil.pause(timeLeft-1250);
}
}