33import com .qualcomm .robotcore .eventloop .opmode .LinearOpMode ;
44import com .qualcomm .robotcore .eventloop .opmode .TeleOp ;
55import com .qualcomm .robotcore .hardware .DcMotor ;
6+ import com .qualcomm .robotcore .hardware .DcMotorSimple ;
7+
8+ import org .firstinspires .ftc .teamcode .config .utils .ButtonToggle ;
69
710@ TeleOp
811public class DemoTeleOp extends LinearOpMode {
@@ -19,20 +22,36 @@ public void runOpMode() throws InterruptedException {
1922 // If your robot moves backwards when commanded to go forwards,
2023 // reverse the left side instead.
2124 // See the note about this earlier on this page.
22- //frontRightMotor .setDirection(DcMotorSimple.Direction.REVERSE);
23- //backRightMotor .setDirection(DcMotorSimple.Direction.REVERSE);
24-
25+ frontLeftMotor .setDirection (DcMotorSimple .Direction .REVERSE );
26+ backLeftMotor .setDirection (DcMotorSimple .Direction .REVERSE );
27+ backRightMotor . setDirection ( DcMotorSimple . Direction . REVERSE );
2528 waitForStart ();
26-
29+ ButtonToggle a = new ButtonToggle ();
30+ ButtonToggle b = new ButtonToggle ();
2731 if (isStopRequested ()) return ;
2832
2933 while (opModeIsActive ()) {
30- double y = Math .pow (-gamepad1 .left_stick_y ,3 ); // Remember, Y stick value is reversed
31- double x = Math .pow (gamepad1 .left_stick_x * 1.1 ,3 ); // Counteract imperfect strafing
32- double rx = Math .pow (gamepad1 .right_stick_x ,3 );
34+
35+ if (a .isClicked (gamepad1 .a )) {
36+ frontRightMotor .setDirection (DcMotorSimple .Direction .FORWARD );
37+ backRightMotor .setDirection (DcMotorSimple .Direction .FORWARD );
38+ frontLeftMotor .setDirection (DcMotorSimple .Direction .REVERSE );
39+ backLeftMotor .setDirection (DcMotorSimple .Direction .REVERSE );
40+ telemetry .addData ("left reverse" , 1 );
41+ }
42+ if (b .isClicked (gamepad1 .b )){
43+ frontRightMotor .setDirection (DcMotorSimple .Direction .REVERSE );
44+ backRightMotor .setDirection (DcMotorSimple .Direction .REVERSE );
45+ frontLeftMotor .setDirection (DcMotorSimple .Direction .FORWARD );
46+ backLeftMotor .setDirection (DcMotorSimple .Direction .FORWARD );
47+ telemetry .addData ("right reverse" , 2 );
48+ }
49+ double y = -gamepad1 .left_stick_y ; // Remember, Y stick value is reversed
50+ double x = gamepad1 .left_stick_x * 1.1 ; // Counteract imperfect strafing
51+ double rx = gamepad1 .right_stick_x ;
3352
3453 // Denominator is the largest motor power (absolute value) or 1
35- // This ensures all the powers maintain the same ratio,x
54+ // This ensures all the powers maintain the same ratio,
3655 // but only if at least one is out of the range [-1, 1]
3756 double denominator = Math .max (Math .abs (y ) + Math .abs (x ) + Math .abs (rx ), 1 );
3857 double frontLeftPower = (y + x + rx ) / denominator ;
@@ -44,6 +63,8 @@ public void runOpMode() throws InterruptedException {
4463 backLeftMotor .setPower (backLeftPower );
4564 frontRightMotor .setPower (frontRightPower );
4665 backRightMotor .setPower (backRightPower );
66+
67+ telemetry .update ();
4768 }
4869 }
4970}
0 commit comments