helloworldhellow

This commit is contained in:
GZod01 2024-03-08 14:30:01 +01:00
commit f1b4a60c76
5 changed files with 462 additions and 39 deletions

View file

@ -1,36 +1,29 @@
package org.firstinspires.ftc.teamcode;
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
import com.qualcomm.robotcore.hardware.AnalogInput;
import com.qualcomm.robotcore.hardware.Gyroscope;
import com.qualcomm.robotcore.hardware.ColorSensor;
import com.qualcomm.robotcore.hardware.Servo;
import com.qualcomm.robotcore.hardware.DigitalChannel;
import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
import com.qualcomm.robotcore.eventloop.opmode.Disabled;
import com.qualcomm.robotcore.hardware.DcMotor;
import com.qualcomm.robotcore.hardware.DcMotorSimple;
import com.qualcomm.robotcore.util.ElapsedTime;
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.AngleUnit;
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.Orientation;
import org.firstinspires.ftc.robotcore.external.navigation.Position;
import org.firstinspires.ftc.robotcore.external.navigation.Velocity;
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 extends LinearOpMode {
public class ftc2024_autonome_test extends LinearOpMode {
private DcMotor rm;
private DcMotor lm;
private IMU imu;
<<<<<<< HEAD
private ElapsedTime runtime = new ElapsedTime();
YawPitchRollAngles robotOrientation;
@ -60,11 +53,16 @@ public class ftc2024_autonome extends LinearOpMode {
double clamp(double value, double max) {
return Math.max(-max, Math.min(max, value));
}
=======
>>>>>>> 7cd7be1f14eec5f1be12b9f60543771de58ca782
@Override
public void runOpMode() {
lm = hardwareMap.get(DcMotor.class, "blm");
rm = hardwareMap.get(DcMotor.class, "brm");
lm = hardwareMap.get (DcMotor.class, "blm");
rm = hardwareMap.get (DcMotor.class, "brm");
rm.setDirection(DcMotor.Direction.REVERSE);
imu = hardwareMap.get(IMU.class, "imu");
imu.initialize(
@ -76,6 +74,7 @@ public class ftc2024_autonome extends LinearOpMode {
)
);
imu.resetYaw();
<<<<<<< HEAD
rm.setDirection(DcMotorSimple.Direction.REVERSE);
telemetry.addData("Status", "Initialized");
@ -87,17 +86,16 @@ public class ftc2024_autonome extends LinearOpMode {
double speed = (tour_par_minute/60)*wheel_perimeter;//dist per second
boolean mode = true;
=======
YawPitchRollAngles robotOrientation;
>>>>>>> 7cd7be1f14eec5f1be12b9f60543771de58ca782
robotOrientation = imu.getRobotYawPitchRollAngles();
double Yaw = robotOrientation.getYaw(AngleUnit.DEGREES);
double Pitch = robotOrientation.getPitch(AngleUnit.DEGREES);
double Roll = robotOrientation.getRoll(AngleUnit.DEGREES);
double yaw_sortie = 0.0;
double yaw_sortie;
// Wait for the game to start (driver presses PLAY)
waitForStart();
<<<<<<< HEAD
runtime.reset();
if (mode){
//mode Elina
@ -165,20 +163,44 @@ public class ftc2024_autonome extends LinearOpMode {
telemetry.addData("current_op_id",i);
=======
while (opModeIsActive()){
double [] lm_p = {0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1};
double [] rm_p = {-0.1,-0.2,-0.3,-0.4,-0.5,-0.6,-0.7,-0.8,-0.9,-1};
double [] x = new double[lm_p.length];
for(int i = 0; i< 9; i++){
while (opModeIsActive() && Yaw < 90){
lm.setPower(lm_p[i]);
rm.setPower(rm_p[i]);
robotOrientation = imu.getRobotYawPitchRollAngles();
Yaw = robotOrientation.getYaw(AngleUnit.DEGREES);
telemetry.addData("Yaw ", Yaw);
>>>>>>> 7cd7be1f14eec5f1be12b9f60543771de58ca782
telemetry.update();
yaw_sortie = Yaw;
}
telemetry.addData("Yaw sortie", yaw_sortie);
telemetry.update();
Yaw = robotOrientation.getYaw(AngleUnit.DEGREES);
x [i]= Yaw - yaw_sortie;
imu.resetYaw();
Yaw = robotOrientation.getYaw(AngleUnit.DEGREES);
telemetry.addData("Yaw", Yaw);
telemetry.update();
}
while (opModeIsActive()){
telemetry.addData("0.1", x[0]);
telemetry.addData("0.2", x[1]);
telemetry.addData("0.3", x[2]);
telemetry.addData("0.4", x[3]);
telemetry.addData("0.5", x[4]);
telemetry.addData("0.6", x[5]);
telemetry.addData("0.7", x[6]);
telemetry.addData("0.8", x[7]);
telemetry.addData("0.9", x[8]);
telemetry.addData("1", x[9]);
}
}
// Now use these simple methods to extract each angle
// (Java type double) from the object you just created:
telemetry.addData("yaw",Yaw);
telemetry.update();
// run until the end of the match (driver presses STOP
}
}
}