This repository was archived by the owner on Jul 19, 2025. It is now read-only.
forked from FIRST-Tech-Challenge/FtcRobotController
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAuto.java
More file actions
68 lines (56 loc) · 2.67 KB
/
Copy pathAuto.java
File metadata and controls
68 lines (56 loc) · 2.67 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package org.firstinspires.ftc.teamcode;
import android.icu.util.Output;
import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
import com.qualcomm.robotcore.hardware.CRServo;
import com.qualcomm.robotcore.hardware.DcMotor;
import com.qualcomm.robotcore.hardware.DcMotorSimple;
import com.qualcomm.robotcore.hardware.Servo;
@Autonomous
public class Auto extends LinearOpMode {
@Override
public void runOpMode() throws InterruptedException {
// Declare our motors
// Make sure your ID's match your configuration
DcMotor frontLeftMotor = hardwareMap.dcMotor.get("frontleftmotor");
DcMotor backLeftMotor = hardwareMap.dcMotor.get("backleftmotor");
DcMotor frontRightMotor = hardwareMap.dcMotor.get("frontrightmotor");
DcMotor backRightMotor = hardwareMap.dcMotor.get("backrightmotor");
Servo IntakeLift = hardwareMap.servo.get("intakelift");
frontLeftMotor.setDirection(DcMotorSimple.Direction.REVERSE);
backLeftMotor.setDirection(DcMotorSimple.Direction.REVERSE);
waitForStart();
if (isStopRequested()) return;
while (opModeIsActive()) {
IntakeLift.setPosition(0.9);
double y = 0;
double x = 1.1;
double rx = 0;
//movement
//double y = -gamepad1.left_stick_y; // Remember, Y stick value is reversed
//double x = gamepad1.left_stick_x * 1.1; // Counteract imperfect strafing
//double rx = gamepad1.right_trigger - gamepad1.left_trigger;
// Denominator is the largest motor power (absolute value) or 1
// This ensures all the powers maintain the same ratio,
// but only if at least one is out of the range [-1, 1]
double denominator = Math.max(Math.abs(y) + Math.abs(x) + Math.abs(rx), 1);
double frontLeftPower = -(y + x + rx) / denominator;
double backLeftPower = -(y - x + rx) / denominator;
double frontRightPower = -(y - x - rx) / denominator;
double backRightPower = -(y + x - rx) / denominator;
frontLeftMotor.setPower(frontLeftPower);
backLeftMotor.setPower(backLeftPower);
frontRightMotor.setPower(frontRightPower);
backRightMotor.setPower(backRightPower);
sleep(3000);
telemetry.addData("here", 0);
telemetry.update();
frontLeftMotor.setPower(0);
backLeftMotor.setPower(0);
frontRightMotor.setPower(0);
backRightMotor.setPower(0);
break;
}
}
}