forked from InspirationRobotics/FTC-2023-2024
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TimedMecanumDrive.java
87 lines (81 loc) · 2.91 KB
/
TimedMecanumDrive.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
87
package org.firstinspires.ftc.teamcode;
public abstract class TimedMecanumDrive extends HardwareMap_Inspire {
public void MoveForward(long milliseconds, double speed) throws InterruptedException{
leftFront.setPower(speed);
leftBack.setPower(speed);
rightBack.setPower(speed);
rightFront.setPower(speed);
Thread.sleep(milliseconds);
leftFront.setPower(0);
leftBack.setPower(0);
rightBack.setPower(0);
rightFront.setPower(0);
}
public void MoveBackward(long milliseconds, double speed) throws InterruptedException{
leftFront.setPower(-speed);
leftBack.setPower(-speed);
rightBack.setPower(-speed);
rightFront.setPower(-speed);
Thread.sleep(milliseconds);
leftFront.setPower(0);
leftBack.setPower(0);
rightBack.setPower(0);
rightFront.setPower(0);
}
public void TurnRight(long milliseconds, double speed) throws InterruptedException{
leftFront.setPower(speed);
leftBack.setPower(speed);
rightBack.setPower(-speed);
rightFront.setPower(-speed);
Thread.sleep(milliseconds);
leftFront.setPower(0);
leftBack.setPower(0);
rightBack.setPower(0);
rightFront.setPower(0);
}
public void TurnLeft(long milliseconds, double speed) throws InterruptedException{
leftFront.setPower(-speed);
leftBack.setPower(-speed);
rightBack.setPower(speed);
rightFront.setPower(speed);
Thread.sleep(milliseconds);
leftFront.setPower(0);
leftBack.setPower(0);
rightBack.setPower(0);
rightFront.setPower(0);
}
public void StrafeLeft(long milliseconds, double speed) throws InterruptedException{
leftFront.setPower(-speed);
leftBack.setPower(speed);
rightBack.setPower(-speed);
rightFront.setPower(speed);
Thread.sleep(milliseconds);
leftFront.setPower(0);
leftBack.setPower(0);
rightBack.setPower(0);
rightFront.setPower(0);
}
public void StrafeRight(long milliseconds, double speed) throws InterruptedException{
leftFront.setPower(speed);
leftBack.setPower(-speed);
rightBack.setPower(speed);
rightFront.setPower(-speed);
Thread.sleep(milliseconds);
leftFront.setPower(0);
leftBack.setPower(0);
rightBack.setPower(0);
rightFront.setPower(0);
}
public void spinIntake(long milliseconds, double speed) throws InterruptedException{
intake.setPower(speed);
Thread.sleep(milliseconds);
intake.setPower(0);
}
public void extend(long milliseconds, double speed) throws InterruptedException{
extension.setPower(speed);
Thread.sleep(milliseconds);
extension.setPower(0);
}
public abstract void start();
public abstract void loop() throws InterruptedException;
}