-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDriveTank.java
More file actions
49 lines (37 loc) · 1.45 KB
/
Copy pathDriveTank.java
File metadata and controls
49 lines (37 loc) · 1.45 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
// simple teleop program that drives bot using controller joysticks in tank mode.
// this code monitors the period and stops when the period is ended.
package org.firstinspires.ftc.teamcode;
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
import com.qualcomm.robotcore.hardware.DcMotor;
import com.qualcomm.robotcore.util.Range;
@TeleOp(name="Drive Tank", group="Exercises")
//@Disabled
public class DriveTank extends LinearOpMode
{
DcMotor leftMotor, rightMotor;
float leftY, rightY;
// called when init button is pressed.
@Override
public void runOpMode() throws InterruptedException
{
leftMotor = hardwareMap.dcMotor.get("left_motor");
rightMotor = hardwareMap.dcMotor.get("right_motor");
leftMotor.setDirection(DcMotor.Direction.REVERSE);
telemetry.addData("Mode", "waiting");
telemetry.update();
// wait for start button.
waitForStart();
while (opModeIsActive())
{
leftY = gamepad1.left_stick_y * -1;
rightY = gamepad1.right_stick_y * -1;
leftMotor.setPower(Range.clip(leftY, -1.0, 1.0));
rightMotor.setPower(Range.clip(rightY, -1.0, 1.0));
telemetry.addData("Mode", "running");
telemetry.addData("sticks", " left=" + leftY + " right=" + rightY);
telemetry.update();
idle();
}
}
}