-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBasicTeleOp.java
More file actions
52 lines (41 loc) · 2.01 KB
/
Copy pathBasicTeleOp.java
File metadata and controls
52 lines (41 loc) · 2.01 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
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="Griffin Basic TeleOp", group="Linear Opmode")
public class BasicTeleOp extends LinearOpMode {
// Declare OpMode members.
private DcMotor leftDrive = null;
private DcMotor rightDrive = null;
@Override
public void runOpMode() {
telemetry.addData("Status", "Initialized");
telemetry.update();
// Initialize the hardware variables. Note that the strings used here as parameters
// to 'get' must correspond to the names assigned during robot configuration.
leftDrive = hardwareMap.get(DcMotor.class, "left_drive");
rightDrive = hardwareMap.get(DcMotor.class, "right_drive");
// Most robots need the motors to be reversed or set to FORWARD.
// You will need to determine which direction is "forward" for your robot.
leftDrive.setDirection(DcMotor.Direction.FORWARD);
rightDrive.setDirection(DcMotor.Direction.REVERSE); // Reverse one motor for tank drive
// Wait for the game to start (driver presses PLAY)
waitForStart();
telemetry.addData("Status", "Running");
telemetry.update();
// Run until the end of the match (driver presses STOP)
while (opModeIsActive()) {
// Get joystick values from gamepad1
double leftPower = -gamepad1.left_stick_y; // Negative because Y-axis is inverted on gamepads
double rightPower = -gamepad1.right_stick_y;
// Set motor power
leftDrive.setPower(leftPower);
rightDrive.setPower(rightPower);
// Display current motor power on Driver Station
telemetry.addData("Left Motor Power", leftPower);
telemetry.addData("Right Motor Power", rightPower);
telemetry.update();
}
}
}