ftc2024-robotcode/ftc2024-autonome.java

65 lines
2.1 KiB
Java
Raw Normal View History

2024-01-28 16:37:13 +01:00
package org.firstinspires.ftc.teamcode;
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
import com.qualcomm.robotcore.hardware.AnalogInput;
import com.qualcomm.robotcore.hardware.Gyroscope;
import com.qualcomm.robotcore.hardware.ColorSensor;
import com.qualcomm.robotcore.hardware.Servo;
import com.qualcomm.robotcore.hardware.DigitalChannel;
import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
import com.qualcomm.robotcore.eventloop.opmode.Disabled;
import com.qualcomm.robotcore.hardware.DcMotor;
import com.qualcomm.robotcore.hardware.DcMotorSimple;
import com.qualcomm.robotcore.util.ElapsedTime;
@Autonomous
2024-01-28 16:47:11 +01:00
public class ftc2024_autonome extends LinearOpMode {
private DcMotor rm;
private DcMotor lm;
2024-01-28 16:37:13 +01:00
private ElapsedTime runtime = new ElapsedTime();
@Override
public void runOpMode() {
2024-01-28 16:47:11 +01:00
lm = hardwareMap.get(DcMotor.class, "blm");
rm = hardwareMap.get(DcMotor.class, "brm");
2024-01-28 16:37:13 +01:00
telemetry.addData("Status", "Initialized");
telemetry.update();
2024-01-28 16:47:11 +01:00
boolean mode = true;
2024-01-28 16:37:13 +01:00
// Wait for the game to start (driver presses PLAY)
waitForStart();
2024-01-28 16:47:11 +01:00
runtime.reset();
if (mode){
//mode Elina
while (opModeIsActive() && (runtime.seconds() <= 3.0)) {
leftMotor.setPower(1);
2024-01-28 16:55:48 +01:00
rightMotor.setPower(-1);
2024-01-28 16:47:11 +01:00
telemetry.addData("Leg 1", runtime.seconds());
telemetry.update();
}
2024-01-28 16:55:48 +01:00
while (opModeIsActive() && (runtime.seconds() <= 10.0)) {
leftMotor.setPower(1);
rightMotor.setPower(1);
telemetry.addData("Leg 2", runtime.seconds());
telemetry.update();
}
2024-01-28 16:47:11 +01:00
}
else {
//mode Aurelien
while (opModeIsActive() && (runtime.seconds() <= 3.0)) {
leftMotor.setPower(-1);
rightMotor.setPower(-1);
telemetry.addData("Leg 2", runtime.seconds());
telemetry.update();
}
}
2024-01-28 16:55:48 +01:00
// run until the end of the match (driver presses STOP
2024-01-28 16:37:13 +01:00
}
}
2024-01-28 16:55:48 +01:00