erreurs corrigées
This commit is contained in:
parent
0cbc68e0e9
commit
b770f1a271
1 changed files with 23 additions and 22 deletions
|
@ -16,15 +16,15 @@ import com.qualcomm.robotcore.hardware.Servo;
|
||||||
public class Werobot_FTC2024_carlike extends LinearOpMode {
|
public class Werobot_FTC2024_carlike extends LinearOpMode {
|
||||||
private DcMotor rm;
|
private DcMotor rm;
|
||||||
private DcMotor lm;
|
private DcMotor lm;
|
||||||
private double helloexp(double t){
|
private double helloexp(double t){
|
||||||
return (Math.exp(5*t)-1)/(Math.exp(5)-1);
|
return (Math.exp(5*t)-1)/(Math.exp(5)-1);
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void runOpMode() throws InterruptedException {
|
public void runOpMode() throws InterruptedException {
|
||||||
float x;
|
float x;
|
||||||
double y;
|
double y;
|
||||||
double t;
|
double t;
|
||||||
double t2;
|
double t2;
|
||||||
double t3;
|
double t3;
|
||||||
String mode = "normal";
|
String mode = "normal";
|
||||||
boolean already_a = false;
|
boolean already_a = false;
|
||||||
|
@ -32,7 +32,7 @@ public class Werobot_FTC2024_carlike extends LinearOpMode {
|
||||||
telemetry.update();
|
telemetry.update();
|
||||||
lm = hardwareMap.get(DcMotor.class, "blm");
|
lm = hardwareMap.get(DcMotor.class, "blm");
|
||||||
rm = hardwareMap.get(DcMotor.class, "brm");
|
rm = hardwareMap.get(DcMotor.class, "brm");
|
||||||
rm.setDirection(DcMotorSimple.Direction.REVERSE);
|
rm.setDirection(DcMotorSimple.Direction.REVERSE);
|
||||||
waitForStart();
|
waitForStart();
|
||||||
|
|
||||||
|
|
||||||
|
@ -40,17 +40,17 @@ public class Werobot_FTC2024_carlike extends LinearOpMode {
|
||||||
x = gamepad1.left_stick_x;
|
x = gamepad1.left_stick_x;
|
||||||
y = gamepad1.left_stick_y;
|
y = gamepad1.left_stick_y;
|
||||||
t= gamepad1.right_trigger;
|
t= gamepad1.right_trigger;
|
||||||
t2 = helloexp(t);
|
t2 = helloexp(t);
|
||||||
t3 = helloexp(Math.sqrt(x^2+y^2))
|
t3 = helloexp(Math.sqrt(Math.pow(x,2)+Math.pow(y,2)));
|
||||||
telemetry.addData("Status", "Running");
|
telemetry.addData("Status", "Running");
|
||||||
if(gamepad1.a && !already_a){
|
if(gamepad1.a && !already_a){
|
||||||
if(mode=="normal"){
|
if(mode=="normal"){
|
||||||
mode="tank";
|
mode="tank";
|
||||||
}else if(mode=="tank"){
|
}else if(mode=="tank"){
|
||||||
mode = "essaifranck";
|
mode = "essaifranck";
|
||||||
}else if (mode == "essaifranck"){
|
}else if (mode == "essaifranck"){
|
||||||
mode = "elina";
|
mode = "elina";
|
||||||
}else{
|
}else{
|
||||||
mode="normal";
|
mode="normal";
|
||||||
}
|
}
|
||||||
already_a = true;
|
already_a = true;
|
||||||
|
@ -70,34 +70,35 @@ public class Werobot_FTC2024_carlike extends LinearOpMode {
|
||||||
lpower = -y;
|
lpower = -y;
|
||||||
rpower = gamepad1.right_stick_y;
|
rpower = gamepad1.right_stick_y;
|
||||||
}
|
}
|
||||||
else if (mode=="essaifranck"){
|
else if (mode=="essaifranck"){
|
||||||
double a = (-y+x)/Math.pow(2,1/2);
|
double a = (-y+x)/Math.pow(2,1/2);
|
||||||
double b = (-y-x)/Math.pow(2,1/2);
|
double b = (-y-x)/Math.pow(2,1/2);
|
||||||
double vmean = (Math.abs(a)+Math.abs(b))/2;
|
double vmean = (Math.abs(a)+Math.abs(b))/2;
|
||||||
lpower = (a/vmean)*t2;
|
lpower = (a/vmean)*t2;
|
||||||
rpower = (b/vmean)*t2;
|
rpower = (b/vmean)*t2;
|
||||||
}
|
}
|
||||||
else if (mode=="elina"){
|
else if (mode=="elina"){
|
||||||
double a = (-y+x)/Math.pow(2,1/2);
|
double a = (-y+x)/Math.pow(2,1/2);
|
||||||
double b = (-y-x)/Math.pow(2,1/2);
|
double b = (-y-x)/Math.pow(2,1/2);
|
||||||
double vmean = (Math.abs(a)+Math.abs(b))/2;
|
double vmean = (Math.abs(a)+Math.abs(b))/2;
|
||||||
lpower = (a/vmean)*t3
|
lpower = (a/vmean)*t3;
|
||||||
rpower = (b/vmean)*t3
|
rpower = (b/vmean)*t3;
|
||||||
|
}
|
||||||
if(!(gamepad1.left_bumper)){
|
if(!(gamepad1.left_bumper)){
|
||||||
lpower/=3;
|
lpower/=3;
|
||||||
rpower/=3;
|
rpower/=3;
|
||||||
}
|
}
|
||||||
lm.setPower(lpower);
|
lm.setPower(lpower);
|
||||||
rm.setPower(rpower);
|
rm.setPower(rpower);
|
||||||
|
|
||||||
telemetry.addData("x",x);
|
telemetry.addData("x",x);
|
||||||
telemetry.addData("y",y);
|
telemetry.addData("y",y);
|
||||||
telemetry.addData("lpow",lpower);
|
telemetry.addData("lpow",lpower);
|
||||||
telemetry.addData("rpow",rpower);
|
telemetry.addData("rpow",rpower);
|
||||||
telemetry.addData("ltrigg",t);
|
telemetry.addData("ltrigg",t);
|
||||||
telemetry.addData("t2",t2);
|
telemetry.addData("t2",t2);
|
||||||
telemetry.addData("mode",mode);
|
telemetry.addData("mode",mode);
|
||||||
telemetry.update();
|
telemetry.update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue