Repository navigation
Expand file tree
/
Copy pathAutomode6RedClose.java
More file actions
129 lines (101 loc) · 3.04 KB
/
Copy pathAutomode6RedClose.java
File metadata and controls
129 lines (101 loc) · 3.04 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
124
125
126
127
128
129
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 = "Automode6RedClose")
public class Automode6RedClose 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);
//wait for motors to start.
waitForStart();
//turn the motors on.
rightLED.setPosition(0);
leftLED.setPosition(0);
startThrower();
sleep(7300);
fire();
sleep(2500);
fire();
sleep(2500);
fire();
sleep(2500);
fire();
fire();
sleep(2500);
backMotors();
sleep(950);
backMotorRight();
sleep(350);
backMotors();
sleep(1300);
startMotors();
sleep(350);
stopMotors();
}
private void startMotors() {
leftFrontDrive.setPower(-0.5);
rightFrontDrive.setPower(0.5);
return;
}
private void stopMotors() {
leftFrontDrive.setPower(0.0);
rightFrontDrive.setPower(0.0);
return;
}
private void turnMotorsRight() {
leftFrontDrive.setPower(-0.8);
rightFrontDrive.setPower(0.0);
return;
}
private void turnMotorsLeft() {
leftFrontDrive.setPower(0.0);
rightFrontDrive.setPower(0.8);
return;
}
private void startThrower() {
thrower.setVelocity(1150);
return;
}
private void backMotorLeft() {
leftFrontDrive.setPower(0.0);
rightFrontDrive.setPower(-0.8);
return;
}
private void backMotorRight() {
leftFrontDrive.setPower(0.8);
rightFrontDrive.setPower(0.0);
return;
}
private void backMotors() {
leftFrontDrive.setPower(0.5);
rightFrontDrive.setPower(-0.5);
return;
}
public void fire() {
rightStopper.setPower(-1);
leftStopper.setPower(1);
sleep(Constants.TeleOpConstants.STOPPER_DELAY);
rightStopper.setPower(0);
leftStopper.setPower(0);
}
}