Untitled
unknown
java
2 years ago
1.7 kB
8
Indexable
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 public class DualDrive extends LinearOpMode { // Register motors private DcMotor rightmotor; private DcMotor leftmotor; // Register joy stick variables double leftJoyStickX = gamepad1.left_stick_x; double leftJoyStickY = -gamepad1.left_stick_y; @Override public void runOpMode() { // Connect motors to the robot rightmotor = hardwareMap.get(DcMotor.class, "rightmotor"); leftmotor = hardwareMap.get(DcMotor.class, "leftmotor"); // Fixing right motor two share same direction as the left one rightmotor.setDirection(DcMotorSimple.Direction.REVERSE); // IDK what this is, prob just an init stage, I will just leave it tbh waitForStart(); // Loop when the program is ON while (opModeIsActive()) { /* Set motors according to the joysticks. This method could be unconsistent (a millimeter differnece of the joystick will influence the speed of the robot), but we can't do anything about it. I don't want to waste time hard-coding parameters in (just like I did for the past hour) Anyways, STICK WITH IT. */ leftmotor.setPower(leftJoyStickY + leftJoyStickX); rightmotor.setPower(leftJoyStickY - leftJoyStickX); } } }
Editor is loading...