Repository navigation
Expand file tree
/
Copy pathAutomode5BlueClose.java
More file actions
118 lines (91 loc) · 2.85 KB
/
Copy pathAutomode5BlueClose.java
File metadata and controls
118 lines (91 loc) · 2.85 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
package org.firstinspires.ftc.teamcode;
import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
import com.qualcomm.robotcore.hardware.CRServo;
import com.qualcomm.robotcore.hardware.DcMotor;
import com.qualcomm.robotcore.hardware.DcMotorEx;
import com.qualcomm.robotcore.hardware.Servo;
import com.qualcomm.robotcore.util.ElapsedTime;
@Autonomous(name = "Automode5BlueClose")
public class Automode5BlueClose extends LinearOpMode {
private final ElapsedTime runtime = new ElapsedTime();
private DcMotor leftFrontDrive;
private DcMotor rightFrontDrive;
private DcMotorEx thrower;
CRServo rightStopper;
CRServo leftStopper;
Servo rightLED;
Servo leftLED;
@Override
public void runOpMode() {
leftFrontDrive = hardwareMap.get(DcMotor.class, "FL");
rightFrontDrive = hardwareMap.get(DcMotor.class, "FR");
thrower = hardwareMap.get(DcMotorEx.class, "T");
rightStopper = hardwareMap.get(CRServo.class, "RS");
leftStopper = hardwareMap.get(CRServo.class, "LS");
rightLED = hardwareMap.get(Servo.class,"RLED");
leftLED = hardwareMap.get(Servo.class,"LLED");
thrower.setMode(DcMotor.RunMode.RUN_USING_ENCODER);
waitForStart();
//turn the motors on.
rightLED.setPosition(0);
leftLED.setPosition(0);
startThrower();
sleep(7300);
fire();
sleep(3600);
fire();
sleep(2500);
fire();
sleep(2500);
fire();
sleep(2500);
backMotors();
sleep(950);
backMotorLeft();
sleep(450);
backMotors();
sleep(1000);
stopMotors();
}
private void startMotors() {
leftFrontDrive.setPower(-0.5);
rightFrontDrive.setPower(0.5);
return;
}
private void stopMotors() {
leftFrontDrive.setPower(0.0);
rightFrontDrive.setPower(0.0);
}
private void turnMotorsRight() {
leftFrontDrive.setPower(-0.8);
rightFrontDrive.setPower(0.0);
}
private void turnMotorsLeft() {
leftFrontDrive.setPower(0.0);
rightFrontDrive.setPower(0.8);
}
private void startThrower() {
thrower.setVelocity(1150);
return;
}
private void backMotorLeft() {
leftFrontDrive.setPower(0.0);
rightFrontDrive.setPower(-0.8);
}
private void backMotorRight() {
leftFrontDrive.setPower(0.8);
rightFrontDrive.setPower(0.0);
}
private void backMotors() {
leftFrontDrive.setPower(0.5);
rightFrontDrive.setPower(-0.5);
}
public void fire() {
rightStopper.setPower(-1);
leftStopper.setPower(1);
sleep(Constants.TeleOpConstants.STOPPER_DELAY);
rightStopper.setPower(0);
leftStopper.setPower(0);
}
}