helloworld, we added some features and we hope that the robot will work but we know that hope is often lies, so we have to hope even if we know that it's false, 'Measuring programming progree by lines of code is like measuring aircraft building progree by weight.' - Bill Gates
This commit is contained in:
parent
8e3b2196a1
commit
5da5ebbe1e
2 changed files with 36 additions and 28 deletions
|
@ -17,6 +17,7 @@ public class AutonomeTest extends LinearOpMode {
|
|||
private DcMotorEx boiteG;
|
||||
private DcMotorEx boiteD;
|
||||
private ElapsedTime runtime = new ElapsedTime();
|
||||
private DcMotor moissonneuse;
|
||||
|
||||
@Override
|
||||
public void runOpMode(){
|
||||
|
@ -34,7 +35,7 @@ public class AutonomeTest extends LinearOpMode {
|
|||
droit.setDirection(DcMotorSimple.Direction.REVERSE);
|
||||
droit.setMode(DcMotorEx.RunMode.STOP_AND_RESET_ENCODER);
|
||||
droit.setZeroPowerBehavior(DcMotorEx.ZeroPowerBehavior.FLOAT);
|
||||
moissonneuse = hardwareMap.get(DcMotor.class,"msn");
|
||||
moissonneuse = hardwareMap.get(DcMotor.class,"moissonneuse");
|
||||
|
||||
|
||||
waitForStart();
|
||||
|
@ -64,12 +65,14 @@ public class AutonomeTest extends LinearOpMode {
|
|||
gauche.setTargetPosition(165);
|
||||
droit.setTargetPosition(1235);
|
||||
|
||||
while (opModeIsActive() && gauche.getCurrentPosition()>gauche.getTargetPosition()){
|
||||
while (opModeIsActive() && droit.getCurrentPosition()>droit.getTargetPosition()){
|
||||
gauche.setVelocity(250);
|
||||
gauche.setMode(DcMotor.RunMode.RUN_TO_POSITION);
|
||||
droit.setVelocity(250);
|
||||
droit.setMode(DcMotor.RunMode.RUN_TO_POSITION);
|
||||
}
|
||||
gauche.setVelocity(0);
|
||||
droit.setVelocity(0);
|
||||
gauche.setTargetPosition(700*3);
|
||||
droit.setTargetPosition(700*3);
|
||||
|
||||
|
|
|
@ -22,8 +22,8 @@ import org.firstinspires.ftc.robotcore.external.navigation.Orientation;
|
|||
import org.firstinspires.ftc.robotcore.external.navigation.Position;
|
||||
import org.firstinspires.ftc.robotcore.external.navigation.Velocity;
|
||||
|
||||
@TeleOp(name = "WeRobot: FTC2024 NEW! Carlike", group = "WeRobot")
|
||||
public class WEROBOT_FTC2024_New_carlike extends LinearOpMode {
|
||||
@TeleOp(name = "FGC2024", group = "WeRobot")
|
||||
public class FGC_2024 extends LinearOpMode {
|
||||
|
||||
private DcMotorEx rm;
|
||||
private DcMotorEx lm;
|
||||
|
@ -32,24 +32,27 @@ public class WEROBOT_FTC2024_New_carlike extends LinearOpMode {
|
|||
@Override
|
||||
public void runOpMode() throws InterruptedException {
|
||||
|
||||
|
||||
telemetry.addData("Status"," Initialized");
|
||||
telemetry.update();
|
||||
|
||||
lm = hardwareMap.get(DcMotorEx.class, "lm");
|
||||
lm.setDirection(DcMotor.Direction.REVERSE);
|
||||
rm = hardwareMap.get(DcMotorEx.class, "rm");
|
||||
//lm.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.FLOAT);
|
||||
//rm.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.FLOAT);
|
||||
|
||||
waitForStart();
|
||||
while(opModeIsActive()){
|
||||
float x = gamepad1.left_stick_x; // abscisse joystick gauche
|
||||
double y = gamepad1.left_stick_y; // ordonnées joystick gauche
|
||||
double lpower = 0.0; //puissance moteur gauche
|
||||
double rpower = 0.0; //puissance moteur droit
|
||||
|
||||
telemetry.addData("Status"," Initialized");
|
||||
|
||||
lm = hardwareMap.get(DcMotorEx.class, "lm");
|
||||
rm = hardwareMap.get(DcMotorEx.class, "rm");
|
||||
lm.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
|
||||
rm.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
|
||||
lm.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.FLOAT);
|
||||
rm.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.FLOAT);
|
||||
|
||||
lpower = ((1+x)*Math.signum(y))/2;
|
||||
rpower = ((1-x)*Math.signum(y))/2;
|
||||
|
||||
if ( x=1 || x=-1 ){
|
||||
if (Math.abs(x)>0.8){
|
||||
lpower = 1*Math.signum(x);
|
||||
rpower = -lpower;
|
||||
}
|
||||
|
@ -59,5 +62,7 @@ public class WEROBOT_FTC2024_New_carlike extends LinearOpMode {
|
|||
|
||||
rm.setPower(rpower);
|
||||
lm.setPower(lpower);
|
||||
telemetry.update();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue