-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAngularTesting.java
91 lines (61 loc) · 2.14 KB
/
AngularTesting.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
/*
* Author: Benton Li '19
* Version: 1.0
*
* */
package org.firstinspires.ftc.teamcode;
import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
import com.qualcomm.robotcore.hardware.DcMotor;
import com.qualcomm.robotcore.hardware.Servo;
import com.qualcomm.robotcore.util.ElapsedTime;
@Autonomous(name = "Angular Testing")
public class AngularTesting extends LinearOpMode {
//preparation for these cool vuforia stuffs
//configure motors
private DcMotor left = null;
private DcMotor right = null;
private DcMotor lift = null;
private Servo launch = null;
ElapsedTime runTime = new ElapsedTime();
double checkpoint1 = 10;
private void configureMotors() {
left = hardwareMap.get(DcMotor.class, "mot0");
right = hardwareMap.get(DcMotor.class, "mot1");
lift = hardwareMap.get(DcMotor.class,"mot2");
launch = hardwareMap.get(Servo.class,"ser");
//set rotational direction
left.setDirection(DcMotor.Direction.REVERSE);
right.setDirection(DcMotor.Direction.FORWARD);
lift.setDirection(DcMotor.Direction.FORWARD);
waitForStart();
}
public void linearForward(double dX){//dx means displacement
runTime.reset();
left.setPower(.5);//power depends on the the robot and case studies are needed
right.setPower(.5);
while (runTime.seconds()<dX){
telemetry.addData("time",runTime.seconds());
telemetry.update();
}
left.setPower(0);
right.setPower(0);
}
public void angularClockwise(double dA){//dA means change in angular degree
runTime.reset();;
left.setPower(.5);
right.setPower(-.5);//power depends on the the robot and case studies are needed
while (runTime.seconds()<dA){
telemetry.addData("time",runTime.seconds());
telemetry.update();
}
left.setPower(0);
right.setPower(0);
}
@Override
public void runOpMode() {
configureMotors();
angularClockwise(2);
stop();
}
}