-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAutonomous.java
More file actions
62 lines (53 loc) · 1.75 KB
/
Autonomous.java
File metadata and controls
62 lines (53 loc) · 1.75 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
package org.firstinspires.ftc.teamcode;
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
import com.qualcomm.robotcore.hardware.DcMotor;
import com.qualcomm.robotcore.hardware.DcMotorSimple;
@TeleOp(name = "Autonomous (Blocks to Java)")
public class Autonomous extends LinearOpMode {
private DcMotor Motor2AsDcMotor;
private DcMotor Motor1AsDcMotor;
/**
* This function is executed when this Op Mode is selected from the Driver Station.
*/
@Override
public void runOpMode() {
Motor2AsDcMotor = hardwareMap.get(DcMotor.class, "Motor2AsDcMotor");
Motor1AsDcMotor = hardwareMap.get(DcMotor.class, "Motor1AsDcMotor");
// Put initialization blocks here.
waitForStart();
if (opModeIsActive()) {
// Put run blocks here.
turnLeft();
}
}
/**
* Describe this function...
*/
private void forward() {
// this thing needs time :)
Motor2AsDcMotor.setDirection(DcMotorSimple.Direction.FORWARD);
Motor1AsDcMotor.setDirection(DcMotorSimple.Direction.FORWARD);
}
/**
* Describe this function...
*/
private void backwards() {
Motor2AsDcMotor.setDirection(DcMotorSimple.Direction.REVERSE);
Motor1AsDcMotor.setDirection(DcMotorSimple.Direction.REVERSE);
}
/**
* Describe this function...
*/
private void turnLeft() {
Motor2AsDcMotor.setDirection(DcMotorSimple.Direction.FORWARD);
Motor1AsDcMotor.setDirection(DcMotorSimple.Direction.REVERSE);
}
/**
* Describe this function...
*/
private void turnRight() {
Motor2AsDcMotor.setDirection(DcMotorSimple.Direction.REVERSE);
Motor1AsDcMotor.setDirection(DcMotorSimple.Direction.FORWARD);
}
}