Update autonome_api.java

This commit is contained in:
GZod01 2024-03-07 16:28:23 +01:00 committed by GitHub
parent ce1f5a5741
commit e5d1c81fbc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -23,10 +23,10 @@ public class ftc2024_autonome_api extends LinearOpMode {
private DcMotor rm;
private DcMotor lm;
private IMU imu;
private static double wheel_width = 9.0e-2; // metres
private static double wheel_perimeter = Math.PI * wheel_width;
private static double tour_par_minutes = 300.0;
private static double ground_tiles_width = 61.0e-2; // metres
private final double wheel_width = 9.0e-2; // metres
private final double wheel_perimeter = Math.PI * wheel_width;
private final double tour_par_minutes = 300.0;
private final double ground_tiles_width = 61.0e-2; // metres
/*
* return a metre/sec speed
* @param motor_speed = double between 0 and 1
@ -41,7 +41,7 @@ public class ftc2024_autonome_api extends LinearOpMode {
return (dist/speed);
}
public void forward(double n_tiles, double motor_speed = 1.0){
double total_time = time_for_dist(n_tiles, motor_speed);
double total_time = time_for_dist(n_tiles*ground_tiles_width, motor_speed);
double start_time = runtime.seconds();
while( opModeIsActive() && ((runtime.seconds()-start_time)<total_time)){
lm.setPower(motor_speed);
@ -92,42 +92,9 @@ public class ftc2024_autonome_api extends LinearOpMode {
waitForStart();
while (opModeIsActive()){
double [] lm_p = {0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1};
double [] rm_p = {-0.1,-0.2,-0.3,-0.4,-0.5,-0.6,-0.7,-0.8,-0.9,-1};
double [] x = new double[lm_p.length];
for(int i = 0; i< 9; i++){
while (opModeIsActive() && Yaw < 90){
lm.setPower(lm_p[i]);
rm.setPower(rm_p[i]);
robotOrientation = imu.getRobotYawPitchRollAngles();
Yaw = robotOrientation.getYaw(AngleUnit.DEGREES);
telemetry.addData("Yaw ", Yaw);
telemetry.update();
yaw_sortie = Yaw;
}
telemetry.addData("Yaw sortie", yaw_sortie);
telemetry.update();
Yaw = robotOrientation.getYaw(AngleUnit.DEGREES);
x [i]= Yaw - yaw_sortie;
imu.resetYaw();
Yaw = robotOrientation.getYaw(AngleUnit.DEGREES);
telemetry.addData("Yaw", Yaw);
telemetry.update();
}
while (opModeIsActive()){
telemetry.addData("0.1", x[0]);
telemetry.addData("0.2", x[1]);
telemetry.addData("0.3", x[2]);
telemetry.addData("0.4", x[3]);
telemetry.addData("0.5", x[4]);
telemetry.addData("0.6", x[5]);
telemetry.addData("0.7", x[6]);
telemetry.addData("0.8", x[7]);
telemetry.addData("0.9", x[8]);
telemetry.addData("1", x[9]);
}
}
if(opModeIsRunning()){
forward(2);
rotate(90);
forward(2);
}
}