he
This commit is contained in:
parent
e3ee807eaf
commit
fe41ddd424
11 changed files with 72 additions and 196 deletions
14
create_all_files.py
Normal file
14
create_all_files.py
Normal file
|
@ -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()));
|
7
ftc2024_auto_b2d.java
Normal file
7
ftc2024_auto_b2d.java
Normal file
|
@ -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;
|
||||||
|
}
|
||||||
|
|
7
ftc2024_auto_b2n.java
Normal file
7
ftc2024_auto_b2n.java
Normal file
|
@ -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;
|
||||||
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package org.firstinspires.ftc.teamcode;
|
|
||||||
import org.firstinspires.ftc.teamcode.Ftc2024_autonome_api;
|
package org.firstinspires.ftc.teamcode;
|
||||||
public class ftc2024_auto_b4d extends Ftc2024_autonome_api{
|
import org.firstinspires.ftc.teamcode.Ftc2024_autonome_api;
|
||||||
|
public class ftc2024_auto_b4d extends Ftc2024_autonome_api{
|
||||||
public AutoMode autonomous_mode = AutoMode.B4D;
|
public AutoMode autonomous_mode = AutoMode.B4D;
|
||||||
}
|
}
|
||||||
|
|
7
ftc2024_auto_b4n.java
Normal file
7
ftc2024_auto_b4n.java
Normal file
|
@ -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;
|
||||||
|
}
|
||||||
|
|
7
ftc2024_auto_r2d.java
Normal file
7
ftc2024_auto_r2d.java
Normal file
|
@ -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;
|
||||||
|
}
|
||||||
|
|
7
ftc2024_auto_r2n.java
Normal file
7
ftc2024_auto_r2n.java
Normal file
|
@ -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;
|
||||||
|
}
|
||||||
|
|
7
ftc2024_auto_r4d.java
Normal file
7
ftc2024_auto_r4d.java
Normal file
|
@ -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;
|
||||||
|
}
|
||||||
|
|
7
ftc2024_auto_r4n.java
Normal file
7
ftc2024_auto_r4n.java
Normal file
|
@ -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;
|
||||||
|
}
|
||||||
|
|
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -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
|
* 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
|
* 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)));
|
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 vmean;
|
||||||
double a;
|
double a;
|
||||||
double b;
|
double b;
|
||||||
|
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
|
|
||||||
case NORMAL:
|
case NORMAL:
|
||||||
|
|
Loading…
Reference in a new issue