Update autonome_api.java
This commit is contained in:
parent
ce1f5a5741
commit
e5d1c81fbc
1 changed files with 9 additions and 42 deletions
|
@ -23,10 +23,10 @@ public class ftc2024_autonome_api extends LinearOpMode {
|
||||||
private DcMotor rm;
|
private DcMotor rm;
|
||||||
private DcMotor lm;
|
private DcMotor lm;
|
||||||
private IMU imu;
|
private IMU imu;
|
||||||
private static double wheel_width = 9.0e-2; // metres
|
private final double wheel_width = 9.0e-2; // metres
|
||||||
private static double wheel_perimeter = Math.PI * wheel_width;
|
private final double wheel_perimeter = Math.PI * wheel_width;
|
||||||
private static double tour_par_minutes = 300.0;
|
private final double tour_par_minutes = 300.0;
|
||||||
private static double ground_tiles_width = 61.0e-2; // metres
|
private final double ground_tiles_width = 61.0e-2; // metres
|
||||||
/*
|
/*
|
||||||
* return a metre/sec speed
|
* return a metre/sec speed
|
||||||
* @param motor_speed = double between 0 and 1
|
* @param motor_speed = double between 0 and 1
|
||||||
|
@ -41,7 +41,7 @@ public class ftc2024_autonome_api extends LinearOpMode {
|
||||||
return (dist/speed);
|
return (dist/speed);
|
||||||
}
|
}
|
||||||
public void forward(double n_tiles, double motor_speed = 1.0){
|
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();
|
double start_time = runtime.seconds();
|
||||||
while( opModeIsActive() && ((runtime.seconds()-start_time)<total_time)){
|
while( opModeIsActive() && ((runtime.seconds()-start_time)<total_time)){
|
||||||
lm.setPower(motor_speed);
|
lm.setPower(motor_speed);
|
||||||
|
@ -92,42 +92,9 @@ public class ftc2024_autonome_api extends LinearOpMode {
|
||||||
|
|
||||||
waitForStart();
|
waitForStart();
|
||||||
|
|
||||||
while (opModeIsActive()){
|
if(opModeIsRunning()){
|
||||||
double [] lm_p = {0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1};
|
forward(2);
|
||||||
double [] rm_p = {-0.1,-0.2,-0.3,-0.4,-0.5,-0.6,-0.7,-0.8,-0.9,-1};
|
rotate(90);
|
||||||
double [] x = new double[lm_p.length];
|
forward(2);
|
||||||
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]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue