change
This commit is contained in:
parent
abe8cb95fa
commit
94118433a0
2 changed files with 145 additions and 55 deletions
|
@ -17,7 +17,6 @@ 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.AxesOrder;
|
||||
import org.firstinspires.ftc.robotcore.external.navigation.AxesReference;
|
||||
|
@ -63,7 +62,7 @@ public class ftc2024_autonome extends LinearOpMode {
|
|||
double wheel_rayon = (wheel_width)/2;
|
||||
double wheel_perimeter = wheel_rayon*2*Math.PI;
|
||||
double speed = (tour_par_minute/60)*wheel_perimeter;//dist per second
|
||||
boolean mode = false;
|
||||
boolean mode = true;
|
||||
|
||||
YawPitchRollAngles robotOrientation;
|
||||
robotOrientation = imu.getRobotYawPitchRollAngles();
|
||||
|
@ -80,23 +79,45 @@ public class ftc2024_autonome extends LinearOpMode {
|
|||
runtime.reset();
|
||||
if (mode){
|
||||
//mode Elina
|
||||
while (opModeIsActive() && Yaw <= 90.0) {
|
||||
lm.setPower(0.5);
|
||||
rm.setPower(-0.5);
|
||||
/*while (opModeIsActive() && Yaw <= -90.0) {
|
||||
lm.setPower(0.2);
|
||||
rm.setPower(-0.2);
|
||||
robotOrientation = imu.getRobotYawPitchRollAngles();
|
||||
Yaw = robotOrientation.getYaw(AngleUnit.DEGREES);
|
||||
telemetry.addData("Yaw : ", Yaw);
|
||||
telemetry.update();
|
||||
yaw_sortie = Yaw;
|
||||
|
||||
}*/
|
||||
while (opModeIsActive() && Yaw < 90) {
|
||||
lm.setPower(0.2);
|
||||
rm.setPower(-0.2);
|
||||
robotOrientation = imu.getRobotYawPitchRollAngles();
|
||||
Yaw = robotOrientation.getYaw(AngleUnit.DEGREES);
|
||||
telemetry.addData("Leg 1", runtime.seconds());
|
||||
telemetry.addData("Yaw", Yaw);
|
||||
telemetry.update();
|
||||
}
|
||||
telemetry.addData("yaw_sortie", yaw_sortie);
|
||||
runtime.reset();
|
||||
while (opModeIsActive() && (runtime.seconds() <= 121.92e-2/speed)) {
|
||||
yaw_sortie = Yaw;
|
||||
|
||||
telemetry.update();
|
||||
|
||||
while (opModeIsActive()) {
|
||||
lm.setPower(0.1);
|
||||
rm.setPower(0.1);
|
||||
robotOrientation = imu.getRobotYawPitchRollAngles();
|
||||
Yaw = robotOrientation.getYaw(AngleUnit.DEGREES);
|
||||
telemetry.addData("yaw_sortie", yaw_sortie);
|
||||
telemetry.addData("Yaw", Yaw);
|
||||
telemetry.update();
|
||||
|
||||
}
|
||||
/*while (opModeIsActive() && (runtime.seconds() <= 121.92e-2/speed)) {
|
||||
lm.setPower(0.1);
|
||||
rm.setPower(0.1);
|
||||
telemetry.addData("Leg 2", runtime.seconds());
|
||||
telemetry.update();
|
||||
}
|
||||
}*/
|
||||
}
|
||||
else{
|
||||
while(opModeIsActive()){
|
||||
|
@ -112,7 +133,7 @@ public class ftc2024_autonome extends LinearOpMode {
|
|||
rm.setPower((Math.abs(Yaw-90.0)/90)*0.5);
|
||||
lm.setPower(-(Math.abs(Yaw-90.0)/90)*0.5);
|
||||
}
|
||||
}
|
||||
|
||||
if(false){
|
||||
double[][] operations = {
|
||||
{-1.0,1.0}, // vectors
|
||||
|
@ -134,7 +155,6 @@ public class ftc2024_autonome extends LinearOpMode {
|
|||
double lmvalue = (a/vmean);
|
||||
double rmvalue = (b/vmean);
|
||||
runtime.reset();
|
||||
|
||||
while (opModeIsActive() && (runtime.seconds() <= time)) {
|
||||
lm.setPower(lmvalue);
|
||||
rm.setPower(rmvalue);
|
||||
|
@ -142,10 +162,12 @@ public class ftc2024_autonome extends LinearOpMode {
|
|||
telemetry.addData("current_operation",operations[i]);
|
||||
telemetry.addData("current_op_id",i);
|
||||
|
||||
|
||||
telemetry.update();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Now use these simple methods to extract each angle
|
||||
// (Java type double) from the object you just created:
|
||||
|
@ -154,9 +176,9 @@ public class ftc2024_autonome extends LinearOpMode {
|
|||
|
||||
telemetry.update();
|
||||
// run until the end of the match (driver presses STOP
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
68
test.java
68
test.java
|
@ -1 +1,69 @@
|
|||
package org.firstinspires.ftc.teamcode;
|
||||
|
||||
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
|
||||
|
||||
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_test extends LinearOpMode {
|
||||
private DcMotor rm;
|
||||
private DcMotor lm;
|
||||
private IMU imu;
|
||||
|
||||
@Override
|
||||
|
||||
public void runOpMode() {
|
||||
lm = hardwareMap.get (DcMotor.class, "lm");
|
||||
rm = hardwareMap.get (DcMotor.class, "rm");
|
||||
|
||||
rm.setDirection(DcMotorSimple.Direction.REVERSE);
|
||||
|
||||
imu = hardwareMap.get(IMU.class, "imu");
|
||||
imu.initialize(
|
||||
new IMU.Parameters(
|
||||
new RevHubOrientationOnRobot(
|
||||
RevHubOrientationOnRobot.LogoFacingDirection.UP,
|
||||
RevHubOrientationOnRobot.UsbFacingDirection.FORWARD
|
||||
)
|
||||
)
|
||||
);
|
||||
imu.resetYaw();
|
||||
|
||||
YawPitchRollAngles robotOrientation;
|
||||
double Yaw = robotOrientation.getYaw(AngleUnit.DEGREES);
|
||||
double yaw_sortie1;
|
||||
double yaw_sortie2;
|
||||
double yaw_sortie3;
|
||||
double yaw_sortie4;
|
||||
|
||||
waitForStart();
|
||||
|
||||
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};
|
||||
for(int i = 0; i< p_t_g.length; i++){
|
||||
while (opModeIsActive() && Yaw < 90){
|
||||
lm.setPower = lm_p[i];
|
||||
rm.setPower = rm_p[i];
|
||||
Yaw = robotOrientation.getYaw(AngleUnit.DEGREES);
|
||||
telemetry.addData("Yaw : ", Yaw);
|
||||
telemetry.update();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue