diff --git a/create_all_files.py b/create_all_files.py new file mode 100644 index 0000000..4a2e50e --- /dev/null +++ b/create_all_files.py @@ -0,0 +1,14 @@ +import os +file_exists = (lambda p: (os.path.isfile(p) and os.path.exists(p))) +modes_list_str="b4d.b2d.r2d.r4d.r2n.r4n.b4n.b2n" +modes_list = modes_list_str.split(".") +for m in modes_list: + if not file_exists("ftc2024_auto_"+m.lower()+".java"): + f= open("ftc2024_auto_"+m.lower()+".java","w") + f.write(""" + package org.firstinspires.ftc.teamcode; + import org.firstinspires.ftc.teamcode.Ftc2024_autonome_api; + public class ftc2024_auto_{0} extends Ftc2024_autonome_api{{ + public AutoMode autonomous_mode = AutoMode.{1}; + }} + """.format(m.lower(),m.upper())); \ No newline at end of file diff --git a/ftc2024_auto_b2d.java b/ftc2024_auto_b2d.java new file mode 100644 index 0000000..c1a2bbd --- /dev/null +++ b/ftc2024_auto_b2d.java @@ -0,0 +1,7 @@ + + package org.firstinspires.ftc.teamcode; + import org.firstinspires.ftc.teamcode.Ftc2024_autonome_api; + public class ftc2024_auto_b2d extends Ftc2024_autonome_api{ + public AutoMode autonomous_mode = AutoMode.B2D; + } + \ No newline at end of file diff --git a/ftc2024_auto_b2n.java b/ftc2024_auto_b2n.java new file mode 100644 index 0000000..7d6a487 --- /dev/null +++ b/ftc2024_auto_b2n.java @@ -0,0 +1,7 @@ + + package org.firstinspires.ftc.teamcode; + import org.firstinspires.ftc.teamcode.Ftc2024_autonome_api; + public class ftc2024_auto_b2n extends Ftc2024_autonome_api{ + public AutoMode autonomous_mode = AutoMode.B2N; + } + \ No newline at end of file diff --git a/ftc2024_auto_b4d.java b/ftc2024_auto_b4d.java index 17f818c..7191249 100644 --- a/ftc2024_auto_b4d.java +++ b/ftc2024_auto_b4d.java @@ -1,5 +1,7 @@ -package org.firstinspires.ftc.teamcode; -import org.firstinspires.ftc.teamcode.Ftc2024_autonome_api; -public class ftc2024_auto_b4d extends Ftc2024_autonome_api{ - public AutoMode autonomous_mode = AutoMode.B4D; -} \ No newline at end of file + + package org.firstinspires.ftc.teamcode; + import org.firstinspires.ftc.teamcode.Ftc2024_autonome_api; + public class ftc2024_auto_b4d extends Ftc2024_autonome_api{ + public AutoMode autonomous_mode = AutoMode.B4D; + } + \ No newline at end of file diff --git a/ftc2024_auto_b4n.java b/ftc2024_auto_b4n.java new file mode 100644 index 0000000..66b61f5 --- /dev/null +++ b/ftc2024_auto_b4n.java @@ -0,0 +1,7 @@ + + package org.firstinspires.ftc.teamcode; + import org.firstinspires.ftc.teamcode.Ftc2024_autonome_api; + public class ftc2024_auto_b4n extends Ftc2024_autonome_api{ + public AutoMode autonomous_mode = AutoMode.B4N; + } + \ No newline at end of file diff --git a/ftc2024_auto_r2d.java b/ftc2024_auto_r2d.java new file mode 100644 index 0000000..aa60134 --- /dev/null +++ b/ftc2024_auto_r2d.java @@ -0,0 +1,7 @@ + + package org.firstinspires.ftc.teamcode; + import org.firstinspires.ftc.teamcode.Ftc2024_autonome_api; + public class ftc2024_auto_r2d extends Ftc2024_autonome_api{ + public AutoMode autonomous_mode = AutoMode.R2D; + } + \ No newline at end of file diff --git a/ftc2024_auto_r2n.java b/ftc2024_auto_r2n.java new file mode 100644 index 0000000..3f64edf --- /dev/null +++ b/ftc2024_auto_r2n.java @@ -0,0 +1,7 @@ + + package org.firstinspires.ftc.teamcode; + import org.firstinspires.ftc.teamcode.Ftc2024_autonome_api; + public class ftc2024_auto_r2n extends Ftc2024_autonome_api{ + public AutoMode autonomous_mode = AutoMode.R2N; + } + \ No newline at end of file diff --git a/ftc2024_auto_r4d.java b/ftc2024_auto_r4d.java new file mode 100644 index 0000000..4ca8b64 --- /dev/null +++ b/ftc2024_auto_r4d.java @@ -0,0 +1,7 @@ + + package org.firstinspires.ftc.teamcode; + import org.firstinspires.ftc.teamcode.Ftc2024_autonome_api; + public class ftc2024_auto_r4d extends Ftc2024_autonome_api{ + public AutoMode autonomous_mode = AutoMode.R4D; + } + \ No newline at end of file diff --git a/ftc2024_auto_r4n.java b/ftc2024_auto_r4n.java new file mode 100644 index 0000000..d4449db --- /dev/null +++ b/ftc2024_auto_r4n.java @@ -0,0 +1,7 @@ + + package org.firstinspires.ftc.teamcode; + import org.firstinspires.ftc.teamcode.Ftc2024_autonome_api; + public class ftc2024_auto_r4n extends Ftc2024_autonome_api{ + public AutoMode autonomous_mode = AutoMode.R4N; + } + \ No newline at end of file diff --git a/ftc2024_autonome_api.java b/ftc2024_autonome_api.java deleted file mode 100644 index f23a138..0000000 --- a/ftc2024_autonome_api.java +++ /dev/null @@ -1,190 +0,0 @@ -package org.firstinspires.ftc.teamcode; - -//import FTC2024WeRobotControl; //a tester car pas sur que ça fonctionne - -import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode; -import com.qualcomm.robotcore.hardware.DcMotorEx; - -import com.qualcomm.robotcore.hardware.IMU; -import org.firstinspires.ftc.robotcore.external.navigation.YawPitchRollAngles; -import com.qualcomm.robotcore.hardware.ImuOrientationOnRobot; -import com.qualcomm.hardware.rev.RevHubOrientationOnRobot; - -import org.firstinspires.ftc.robotcore.external.navigation.Orientation; -import org.firstinspires.ftc.robotcore.external.navigation.AxesOrder; -import org.firstinspires.ftc.robotcore.external.navigation.AxesReference; -import org.firstinspires.ftc.robotcore.external.navigation.AngleUnit; - -import com.qualcomm.robotcore.eventloop.opmode.TeleOp; -import com.qualcomm.robotcore.eventloop.opmode.Autonomous; -import com.qualcomm.robotcore.hardware.DcMotor; -import com.qualcomm.robotcore.util.ElapsedTime; - -@Autonomous - -public class Ftc2024_autonome_api extends LinearOpMode { - public enum AutoMode{ - B2D,B4D,B2N,B4N,R2D,R4D,R2N,R4N - } - public AutoMode autonomous_mode; - public DcMotor lm; - public DcMotor rm; - public DcMotorEx lmelevator; - public DcMotorEx rmelevator; - public DcMotor harvestmotor; - public IMU imu; - public DcMotorEx rotation; - - @Override - public void runOpMode() { - lm = hardwareMap.get(DcMotor.class, "blm"); - rm = hardwareMap.get(DcMotor.class, "brm"); - harvestmotor = hardwareMap.get(DcMotor.class, "moissonneuse"); - rotation = hardwareMap.get(DcMotorEx.class, "elvRot"); - - rm.setDirection(DcMotor.Direction.REVERSE); - rotation.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE); - - imu = hardwareMap.get(IMU.class, "imu"); - imu.initialize( - new IMU.Parameters( - new RevHubOrientationOnRobot( - RevHubOrientationOnRobot.LogoFacingDirection.UP, - RevHubOrientationOnRobot.UsbFacingDirection.FORWARD))); - imu.resetYaw(); - YawPitchRollAngles robotOrientation; - FTC2024WeRobotControl robot = new FTC2024WeRobotControl(this); - autonomous_mode = "b4d"; - - telemetry.addData("wait for start", ""); - telemetry.update(); - - - - waitForStart(); - telemetry.addData("started", ""); - telemetry.update(); - robotOrientation = imu.getRobotYawPitchRollAngles(); - - if (opModeIsActive()) { - /* - * autonomous_mode differents possibles values respect the next scheme: - * team_color_shortcode + start_line_index + direct_or_no - * - * team_color_shortcode = "b" for blue & "r" for red - * start_line_index = 4 or 2 see competition manual appendix B Tile location - * plan - * direct_or_no = "d" to direct go to pixel deliver zone or "n" to harvest - * pixels before to go in deliver zone - * - * default is "b4d" - */ - switch (autonomous_mode) { - default: - robot.boxElv(); - robot.forward(0.5); - robot.rotate((-90)); - robot.forward(1.5); - robot.harvest(-1); - robot.backward(1); - robot.harvest(0); - break; - case ("b2d"): - robot.boxElv(); - robot.forward(0.5); - robot.rotate((-90)); - robot.forward(2.5); - robot.harvest(-1); - robot.backward(1); - robot.harvest(0); - break; - case ("r4d"): - robot.boxElv(); - robot.forward(0.5); - robot.rotate(90); - robot.forward(1.5); - robot.harvest(-1); - robot.backward(1); - robot.harvest(0); - break; - case ("r2d"): - robot.boxElv(); - robot.forward(0.5); - robot.rotate(90); - robot.forward(2.5); - robot.harvest(-1); - robot.backward(1); - robot.harvest(0); - break; - case ("b4n"): - robot.boxElv(); - robot.forward(1.5); - robot.rotate(90); - robot.harvest(); - robot.forward(3); - robot.harvest(0); - robot.rotate(180); - robot.forward(1); - robot.rotate(-90); - robot.forward(1); - robot.rotate(90); - robot.forward(2.5); - robot.harvest(-1); - robot.backward(1); - robot.harvest(0); - break; - case ("b2n"): - robot.boxElv(); - robot.forward(1.5); - robot.rotate(90); - robot.harvest(); - robot.forward(1); - robot.harvest(0); - robot.rotate(180); - robot.forward(1); - robot.rotate(-90); - robot.forward(1); - robot.rotate(90); - robot.forward(2.5); - robot.harvest(-1); - robot.backward(1); - robot.harvest(0); - break; - case ("r4n"): - robot.boxElv(); - robot.forward(1.5); - robot.rotate(-90); - robot.harvest(); - robot.forward(3); - robot.harvest(0); - robot.rotate(180); - robot.forward(1); - robot.rotate(90); - robot.forward(1); - robot.rotate(-90); - robot.forward(2.5); - robot.harvest(-1); - robot.backward(1); - robot.harvest(0); - break; - case ("r2n"): - robot.boxElv(); - robot.forward(1.5); - robot.rotate(-90); - robot.harvest(); - robot.forward(1); - robot.harvest(0); - robot.rotate(180); - robot.forward(1); - robot.rotate(90); - robot.forward(1); - robot.rotate(-90); - robot.forward(2.5); - robot.harvest(-1); - robot.backward(1); - robot.harvest(0); - break; - } - } - } -} \ No newline at end of file diff --git a/ftc_new.java b/ftc_new.java index f707c90..43edd75 100644 --- a/ftc_new.java +++ b/ftc_new.java @@ -174,7 +174,7 @@ public class WEROBOT_FTC2024_New_carlike extends LinearOpMode { /* * définition de {@link t3} par utilisation de la fonction {@link helloexp} sur * la norme du vecteur du joystick gauche du gamepad 1 (racine carrée de {@link - * x} au carré plus {@link y} au carré + * x} au carré plus {@link y} au carré) */ t3 = helloexp(Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2))); @@ -195,6 +195,7 @@ public class WEROBOT_FTC2024_New_carlike extends LinearOpMode { double vmean; double a; double b; + switch (mode) { case NORMAL: