-
Notifications
You must be signed in to change notification settings - Fork 0
/
DriveArcade.java
53 lines (40 loc) · 1.65 KB
/
DriveArcade.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
// simple teleop program that drives bot using controller joysticks in arcade 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 Arcade", group="Exercises")
//@Disabled
public class DriveArcade extends LinearOpMode
{
DcMotor leftMotor, rightMotor;
float leftPower, rightPower, xValue, yValue;
// 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())
{
yValue = gamepad1.right_stick_y * -1;
xValue = gamepad1.right_stick_x * -1;
leftPower = yValue - xValue;
rightPower = yValue + xValue;
leftMotor.setPower(Range.clip(leftPower, -1.0, 1.0));
rightMotor.setPower(Range.clip(rightPower, -1.0, 1.0));
telemetry.addData("Mode", "running");
telemetry.addData("stick", " y=" + yValue + " x=" + xValue);
telemetry.addData("power", " left=" + leftPower + " right=" + rightPower);
telemetry.update();
idle();
}
}
}