repl.it
@JoshuaS3/

Java testing

Java

No description

fork
loading
Files
  • Main.java
  • jdt.ls-java-project
Main.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import android.hardware.Sensor;
import android.hardware.camera2.params.MeteringRectangle;
import android.text.method.Touch;
import com.qualcomm.hardware.motors.RevRobotics40HdHexMotor;
import com.qualcomm.hardware.motors.RevRoboticsCoreHexMotor;
import com.qualcomm.hardware.rev.Rev2mDistanceSensor;
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
import com.qualcomm.hardware.rev.RevTouchSensor;
import com.qualcomm.robotcore.hardware.DigitalChannel;
import com.qualcomm.robotcore.hardware.DistanceSensor;
import com.qualcomm.robotcore.hardware.Servo;
import com.qualcomm.robotcore.hardware.TouchSensor;
import com.qualcomm.robotcore.util.ElapsedTime;
import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
import com.qualcomm.robotcore.hardware.DcMotor;
import com.qualcomm.robotcore.hardware.DigitalChannel;
import org.firstinspires.ftc.robotcore.external.Telemetry;
import org.firstinspires.ftc.robotcore.external.navigation.DistanceUnit;
import static org.firstinspires.ftc.robotcore.external.navigation.DistanceUnit.CM;
import static org.firstinspires.ftc.robotcore.external.navigation.DistanceUnit.INCH;
import static org.firstinspires.ftc.robotcore.external.navigation.DistanceUnit.METER;
import static org.firstinspires.ftc.robotcore.external.navigation.DistanceUnit.MM;
import static org.firstinspires.ftc.robotcore.external.navigation.DistanceUnit.mPerInch;
import com.qualcomm.robotcore.hardware.CRServo;

@TeleOp(name="team_gear", group="Linear Opmode")  // @Autonomous(...) is the other common choice

public class team_gear extends LinearOpMode {

	/* Declare OpMode members. */
	private ElapsedTime runtime = new ElapsedTime();

	//declare servo variables
	Servo servo_left = null;
	Servo servo_right = null;


	@Override
	public void runOpMode() throws InterruptedException {
		telemetry.addData("Status", "Initialized");
		telemetry.update();

		//connect variables to servos
		servo_left = hardwareMap.servo.get("left");
		servo_right = hardwareMap.servo.get("right");
		
		//give default pos to servos
		servo_left.setPosition(0.0);
		servo_right.setPosition(0.0);


		waitForStart();
		runtime.reset();

		// run until the end of the match (driver presses STOP)

		/*
		//stuff for turning
		float stick_y = 0;
		float stick_x = 0;
		float leftv = 0;
		float rightv = 0;
		*/

		while (opModeIsActive()) {
			telemetry.addData("Status", "Run Time: " + runtime.toString());
			telemetry.update();
      
			if (gamepad1.x):
				servo_left.setPosition(1.0);
				servo_right.setPosition(1.0);
			else:
				servo_left.setPosition(0.0);
				servo_right.setPosition(0.0);

			/*
			//getting stick pressure
			stick_y = gamepad1.left_stick_y;
			stick_x = gamepad1.left_stick_x;

			//setting un-biased velocity
			leftv = stick_y;
			rightv = stick_y;

			//adding turn bias
			if (stick_x < -0.1)
				leftv += -stick_x;

			if (stick_x > 0.1)
				rightv += -stick_x;

			//setting velocities
			one.setPower(-leftv);
			two.setPower(rightv);
      */

			idle(); // Always call idle() at the bottom of your while(opModeIsActive()) loop
		}
	}
}
Fetching token
?