-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRedDepotDecember_Copy.java
More file actions
95 lines (77 loc) · 3.62 KB
/
Copy pathRedDepotDecember_Copy.java
File metadata and controls
95 lines (77 loc) · 3.62 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
package org.firstinspires.ftc.teamcode;
import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
import com.qualcomm.robotcore.util.ElapsedTime;
import org.firstinspires.ftc.robotcore.external.navigation.DistanceUnit;
import com.qualcomm.hardware.rev.RevBlinkinLedDriver;
import com.qualcomm.robotcore.hardware.DcMotor;
import org.firstinspires.ftc.robotcore.external.navigation.Position;
import org.firstinspires.ftc.robotcore.external.navigation.Velocity;
/**
* Created by Drew from 11874 on 10/20/2018.
*/
@Autonomous(name = "Dapet 2019")
public class RedDepotDecember_Copy extends theColt {
ElapsedTime gametime = new ElapsedTime();
@Override
public void runOpMode() {
telemetry.addData("You broke it Harrison","");
telemetry.update();
INIT(hardwareMap);
lights.setPattern(RevBlinkinLedDriver.BlinkinPattern.STROBE_RED);
initIMU();
initTfod();
zeroEncoders();
angleZzeroValue=45;
tfod.activate();
lights.setPattern(RevBlinkinLedDriver.BlinkinPattern.HEARTBEAT_RED);
while (!isStarted()) //scan until the program starts
{
scanMinerals();
}
gametime.reset();
//if the program was started and the gold mineral wasn't detected, default to the GOLD_MINERAL_LEFT position
if (goldMineralLocation==GOLD_MINERAL_UNKNOWN)
{
goldMineralLocation=GOLD_MINERAL_LEFT;
telemetry.log().add("gold mineral UNKNOWN, defaulting to LEFT");
}
else telemetry.log().add("gold Mineral location "+ goldMineralLocation);
lights.setPattern(RevBlinkinLedDriver.BlinkinPattern.SKY_BLUE);
imu.startAccelerationIntegration(new Position(), new Velocity(), 1000); //Start IMU
outputTelemetry();
lowerRobot();
lights.setPattern(RevBlinkinLedDriver.BlinkinPattern.CP1_HEARTBEAT_FAST);
sleep(.5);
DriveforLength(1.23, -.2); //drive forward out of the lander
sleep(.5);
driveIntoMineral(-45, goldMineralLocation); //this method knocks over the gold mineral and goes to depot
TurnPID(0,2); //make sure the robot is facing straight towards the depot for deploying the team marker
if (goldMineralLocation==GOLD_MINERAL_LEFT && getRobotPositionX()>24) do
{
setEquation(new double[] {3});
driveOverLine(.5, 24, 72, true);
TurnPID(0,2);
} while (getRobotPositionX()>24);
if (goldMineralLocation==GOLD_MINERAL_RIGHT) DriveforLength(.8, -.5);
deployTeamMarker();
setEquation(new double[] {3});
do {
driveOverLinePID(38, 5, 3); //to halfway creater
TurnPID(0, 2);
} while (getRobotPositionX()<40 && (distanceSensorX.getDistance(DistanceUnit.INCH))!=0 && (distanceSensorY.getDistance(DistanceUnit.INCH))!=0 && gametime.seconds()<24);
DriveFieldRealtiveDistance(.5, 90, 3.5);
TurnPID(0,1);
DriveFieldRealtiveDistance(.14, 90,.1);
stopRobot(); //at long distances, distance sensors are unreliable.
writeFile(GYRO_ANGLE_FILE_NAME, getIMUAngle()); //save the current gyro angle for later use in the field realtive teleop
teamMarker.setPosition(1);
lights.setPattern(RevBlinkinLedDriver.BlinkinPattern.CP1_BREATH_SLOW);
raiseRobot();
telemetry.log().add("Autonomous is done, if might have failed but hopefully it didn't");
while (opModeIsActive()) //after program is done
{
telemetry.addData("current angle", getIMUAngle());
telemetry.update();
}
}
}