Merge branch 'master' of https://github.com/GZod01/ftc2024-robotcode
This commit is contained in:
commit
fb8f6ead0d
1 changed files with 252 additions and 138 deletions
|
@ -25,40 +25,122 @@ import org.firstinspires.ftc.robotcore.external.navigation.Velocity;
|
||||||
//test
|
//test
|
||||||
@TeleOp(name="WeRobot: FTC2024 Carlike", group="WeRobot")
|
@TeleOp(name="WeRobot: FTC2024 Carlike", group="WeRobot")
|
||||||
public class Werobot_FTC2024_carlike extends LinearOpMode {
|
public class Werobot_FTC2024_carlike extends LinearOpMode {
|
||||||
|
/*
|
||||||
|
* Le moteur de droite
|
||||||
|
*/
|
||||||
private DcMotor rm;
|
private DcMotor rm;
|
||||||
|
/*
|
||||||
|
* Le moteur de gauche
|
||||||
|
*/
|
||||||
private DcMotor lm;
|
private DcMotor lm;
|
||||||
|
/*
|
||||||
|
* La moissoneuse
|
||||||
|
*/
|
||||||
private DcMotor moissoneuse;
|
private DcMotor moissoneuse;
|
||||||
|
/*
|
||||||
|
* L'IMU
|
||||||
|
*/
|
||||||
private IMU imu;
|
private IMU imu;
|
||||||
|
/*
|
||||||
|
* La fonction pour faire des exponentielles spécifiques
|
||||||
|
* @param double t => le nombre dont on veut faire l'exponentielle
|
||||||
|
* @return double une_exponentielle_très_spéciale_de_t
|
||||||
|
*/
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
* La fonction du thread principal
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void runOpMode() throws InterruptedException {
|
public void runOpMode() throws InterruptedException {
|
||||||
|
/*
|
||||||
|
* l'axe x du joystick gauche de la manette
|
||||||
|
*/
|
||||||
float x;
|
float x;
|
||||||
|
/*
|
||||||
|
* l'axe y du joystick gauche de la manette
|
||||||
|
*/
|
||||||
double y;
|
double y;
|
||||||
|
/*
|
||||||
|
* variation 1 du left trigger
|
||||||
|
*/
|
||||||
double t;
|
double t;
|
||||||
|
/*
|
||||||
|
* variation 2 du left trigger
|
||||||
|
*/
|
||||||
double t2;
|
double t2;
|
||||||
|
/*
|
||||||
|
* variation 3 du left trigger
|
||||||
|
*/
|
||||||
double t3;
|
double t3;
|
||||||
|
/*
|
||||||
|
* le mode du robot
|
||||||
|
*/
|
||||||
String mode = "normal";
|
String mode = "normal";
|
||||||
|
/*
|
||||||
|
* b est il déjà préssé?
|
||||||
|
*/
|
||||||
boolean already_b = false;
|
boolean already_b = false;
|
||||||
|
/*
|
||||||
|
* a est il déjà préssé?
|
||||||
|
*/
|
||||||
boolean already_a = false;
|
boolean already_a = false;
|
||||||
|
/*
|
||||||
|
* x est il déjà préssé?
|
||||||
|
*/
|
||||||
boolean already_x = false;
|
boolean already_x = false;
|
||||||
|
/*
|
||||||
|
* ajout de la donnée status sur telemetry, initialisé
|
||||||
|
*/
|
||||||
telemetry.addData("Status", "Initialized");
|
telemetry.addData("Status", "Initialized");
|
||||||
|
/*
|
||||||
|
* mise a jour de la telemetry
|
||||||
|
*/
|
||||||
telemetry.update();
|
telemetry.update();
|
||||||
|
/*
|
||||||
|
* récupération du moteur gauche pour {@link lm}
|
||||||
|
*/
|
||||||
lm = hardwareMap.get(DcMotor.class, "blm");
|
lm = hardwareMap.get(DcMotor.class, "blm");
|
||||||
|
/*
|
||||||
|
* récupération du moteur droit pour {@link rm}
|
||||||
|
*/
|
||||||
rm = hardwareMap.get(DcMotor.class, "brm");
|
rm = hardwareMap.get(DcMotor.class, "brm");
|
||||||
|
/*
|
||||||
|
* récupération du moteur de moissoneuse pour {@link moissoneuse}
|
||||||
|
*/
|
||||||
moissoneuse = hardwareMap.get(DcMotor.class, "flm");
|
moissoneuse = hardwareMap.get(DcMotor.class, "flm");
|
||||||
|
|
||||||
|
/*
|
||||||
|
* récupération de l'imu pour {@link imu}
|
||||||
|
*/
|
||||||
imu = hardwareMap.get(IMU.class, "imu");
|
imu = hardwareMap.get(IMU.class, "imu");
|
||||||
|
/*
|
||||||
|
* initialisation de l'imu
|
||||||
|
*/
|
||||||
imu.initialize(
|
imu.initialize(
|
||||||
|
/*
|
||||||
|
* paramètres de l'imu
|
||||||
|
*/
|
||||||
new IMU.Parameters(
|
new IMU.Parameters(
|
||||||
|
/*
|
||||||
|
* orientation initiale du robot
|
||||||
|
*/
|
||||||
new RevHubOrientationOnRobot(
|
new RevHubOrientationOnRobot(
|
||||||
|
/*
|
||||||
|
* logo vers le haut
|
||||||
|
*/
|
||||||
RevHubOrientationOnRobot.LogoFacingDirection.UP,
|
RevHubOrientationOnRobot.LogoFacingDirection.UP,
|
||||||
|
/*
|
||||||
|
* usb vers l'avant
|
||||||
|
*/
|
||||||
RevHubOrientationOnRobot.UsbFacingDirection.FORWARD
|
RevHubOrientationOnRobot.UsbFacingDirection.FORWARD
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
/*
|
||||||
|
* réinitialisation du yaw de l'imu
|
||||||
|
*/
|
||||||
imu.resetYaw();
|
imu.resetYaw();
|
||||||
//telemetry.addData("Mode", "calibrating...");
|
//telemetry.addData("Mode", "calibrating...");
|
||||||
//telemetry.update();
|
//telemetry.update();
|
||||||
|
@ -70,19 +152,51 @@ public class Werobot_FTC2024_carlike extends LinearOpMode {
|
||||||
// idle();
|
// idle();
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ajout de la donnée en "mode": "en attente de démarrage" sur telemetry
|
||||||
|
*/
|
||||||
telemetry.addData("Mode", "waiting for start");
|
telemetry.addData("Mode", "waiting for start");
|
||||||
//telemetry.addData("imu calib status", imu.getCalibrationStatus().toString());
|
//telemetry.addData("imu calib status", imu.getCalibrationStatus().toString());
|
||||||
|
/*
|
||||||
|
* mise à jour de la telemetry
|
||||||
|
*/
|
||||||
telemetry.update();
|
telemetry.update();
|
||||||
|
/*
|
||||||
|
* en attente du démarrage
|
||||||
|
*/
|
||||||
waitForStart();
|
waitForStart();
|
||||||
|
|
||||||
//test
|
/*
|
||||||
|
* le robot a démarré, le tant que le robot est activé et donc qu'il n'a pas été stoppé:
|
||||||
|
*/
|
||||||
while (opModeIsActive()) {
|
while (opModeIsActive()) {
|
||||||
|
/*
|
||||||
|
* définition de {@link x} sur la valeur de x du joystick gauche du gamepad 1
|
||||||
|
*/
|
||||||
x = gamepad1.left_stick_x;
|
x = gamepad1.left_stick_x;
|
||||||
|
/*
|
||||||
|
* définition de {@link y} sur la valeur de y du joystick gauche du gamepad 1
|
||||||
|
*/
|
||||||
y = gamepad1.left_stick_y;
|
y = gamepad1.left_stick_y;
|
||||||
|
/*
|
||||||
|
* définition de {@link t} sur la valeur du trigger droit du gamepad 1
|
||||||
|
*/
|
||||||
t= gamepad1.right_trigger;
|
t= gamepad1.right_trigger;
|
||||||
|
/*
|
||||||
|
* définition de {@link t2} par utilisation de la fonction {@link helloexp} sur {@link t}
|
||||||
|
*/
|
||||||
t2 = helloexp(t);
|
t2 = helloexp(t);
|
||||||
|
/*
|
||||||
|
* 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é
|
||||||
|
*/
|
||||||
t3 = helloexp(Math.sqrt(Math.pow(x,2)+Math.pow(y,2)));
|
t3 = helloexp(Math.sqrt(Math.pow(x,2)+Math.pow(y,2)));
|
||||||
|
/*
|
||||||
|
* ajout de la donnée "statut":"entrain de courrir" sur telemetry
|
||||||
|
*/
|
||||||
telemetry.addData("Status", "Running");
|
telemetry.addData("Status", "Running");
|
||||||
|
/*
|
||||||
|
* 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";
|
||||||
|
|
Loading…
Reference in a new issue