helloworld
This commit is contained in:
parent
4c6981b598
commit
60d01e81f5
1 changed files with 43 additions and 21 deletions
64
ftc_new.java
64
ftc_new.java
|
@ -25,6 +25,9 @@ import org.firstinspires.ftc.robotcore.external.navigation.Velocity;
|
||||||
|
|
||||||
@TeleOp(name = "WeRobot: FTC2024 NEW!!! Carlike", group = "WeRobot")
|
@TeleOp(name = "WeRobot: FTC2024 NEW!!! Carlike", group = "WeRobot")
|
||||||
public class WEROBOT_FTC2024_New_carlike extends LinearOpMode {
|
public class WEROBOT_FTC2024_New_carlike extends LinearOpMode {
|
||||||
|
public enum RobotMode{
|
||||||
|
ESSAIFRANCK, ELINA, NORMAL, TANCK;
|
||||||
|
}
|
||||||
|
|
||||||
private DcMotor rm;
|
private DcMotor rm;
|
||||||
private DcMotor lm;
|
private DcMotor lm;
|
||||||
|
@ -134,18 +137,18 @@ public class WEROBOT_FTC2024_New_carlike extends LinearOpMode {
|
||||||
|
|
||||||
telemetry.addData("Status", "Running");
|
telemetry.addData("Status", "Running");
|
||||||
// si le bouton a du gamepad 1 est appuyé et {already_a} est faux
|
// si le bouton a du gamepad 1 est appuyé et {already_a} est faux
|
||||||
/*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 = "essai franck";
|
||||||
} else if (mode == "essaifranck") {
|
} else if (mode == "essai franck") {
|
||||||
mode = "elina";
|
mode = "elina";
|
||||||
} else {
|
} else {
|
||||||
mode = "elina";
|
mode = "elina";
|
||||||
}
|
}
|
||||||
already_a = true;
|
already_a = true;
|
||||||
}*/
|
}
|
||||||
|
|
||||||
boxRot = gamepad1.right_stick_x;
|
boxRot = gamepad1.right_stick_x;
|
||||||
// if (boxRot <= 0){
|
// if (boxRot <= 0){
|
||||||
|
@ -175,14 +178,15 @@ public class WEROBOT_FTC2024_New_carlike extends LinearOpMode {
|
||||||
}
|
}
|
||||||
double lpower = 0.0;
|
double lpower = 0.0;
|
||||||
double rpower = 0.0;
|
double rpower = 0.0;
|
||||||
/*if (mode == "normal") {
|
if (mode == "normal") {
|
||||||
double ysign = y > 0 ? 1.0 : (y < 0 ? -1.0 : 0.0);
|
double ysign = Double.signum(y);
|
||||||
double xsign = x > 0 ? 1.0 : (x < 0 ? -1.0 : 0.0);
|
double xsign = Double.signum(x);
|
||||||
lpower = -ysign * t + (xsign - 2 * x) * t;
|
lpower = -ysign * t + (xsign - 2 * x) * t;
|
||||||
rpower = ysign * t + (xsign - 2 * x) * t;
|
rpower = ysign * t + (xsign - 2 * x) * t;
|
||||||
} else if (mode == "tank") {
|
} else if (mode == "tank") {
|
||||||
lpower = -y;
|
lpower = -y;
|
||||||
rpower = gamepad1.right_stick_y;*/
|
rpower = gamepad1.right_stick_y;
|
||||||
|
}
|
||||||
if (mode == "essaifranck") {
|
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);
|
||||||
|
@ -384,6 +388,24 @@ public class WEROBOT_FTC2024_New_carlike extends LinearOpMode {
|
||||||
telemetry.addData("Position box",box.getCurrentPosition());
|
telemetry.addData("Position box",box.getCurrentPosition());
|
||||||
telemetry.addData("box velocity",rotation.getVelocity());
|
telemetry.addData("box velocity",rotation.getVelocity());
|
||||||
telemetry.update();
|
telemetry.update();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public void nextMode(){
|
||||||
|
this.RobotMode toNextMode;
|
||||||
|
switch(this.mode){
|
||||||
|
case (this.RobotMode.ESSAIFRANCK):
|
||||||
|
toNextMode = this.RobotMode.ELINA;
|
||||||
|
break;
|
||||||
|
case (this.RobotMode.ELINA):
|
||||||
|
toNextMode = this.RobotMode.NORMAL;
|
||||||
|
break;
|
||||||
|
case (this.RobotMode.NORMAL):
|
||||||
|
toNextMode = this.RobotMode.TANK;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
toNextMode = this.RobotMode.ESSAIFRANCK;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
this.mode = toNextMode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue