Actualiser WeRobot-Code.java

This commit is contained in:
Gzod01 2023-09-26 15:55:37 +00:00
parent 807649c996
commit 65844de4cb

View file

@ -2,6 +2,7 @@ package org.firstinspires.ftc.teamcode;
//package fr.gzod01.werobot.competition_singapour_2023; //package fr.gzod01.werobot.competition_singapour_2023;
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode; import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
import com.qualcomm.robotcore.robot.Robot;
import com.qualcomm.robotcore.eventloop.opmode.TeleOp; import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
import com.qualcomm.robotcore.hardware.DcMotor; import com.qualcomm.robotcore.hardware.DcMotor;
import com.qualcomm.robotcore.hardware.DcMotorSimple; import com.qualcomm.robotcore.hardware.DcMotorSimple;
@ -72,7 +73,7 @@ public class DualDrive extends LinearOpMode {
} }
} }
public class Robot{ public class Robot{
public void moves(float x, double y, DcMotor flm, DcMotor frm, DcMotor blm, DcMotor brm){ public static void moves(float x, double y, DcMotor flm, DcMotor frm, DcMotor blm, DcMotor brm){
float approx = 0.15; float approx = 0.15;
boolean xnozero = (x<-approx || x>approx); boolean xnozero = (x<-approx || x>approx);
boolean ynozero = (y<-approx || y>approx); boolean ynozero = (y<-approx || y>approx);
@ -98,60 +99,59 @@ public class Robot{
} }
} }
public void diagonal(float x, double y, DcMotor flm, DcMotor frm,DcMotor blm,DcMotor brm){ public static void diagonal(float x, double y, DcMotor flm, DcMotor frm,DcMotor blm,DcMotor brm){
if(x>0){ if(x>0){
if(y>0){ if(y>0){
// North East // North East
Robot.movement(flm,frm,blm,brm,[1,0,0,1]); Robot.movement(flm,frm,blm,brm,{1,0,0,1});
} }else{
else{
//South East //South East
Robot.movement(flm,frm,blm,brm,[0,-1,-1,0]); Robot.movement(flm,frm,blm,brm,{0,-1,-1,0});
} }
}else{ }else{
if(y>0){ if(y>0){
//North West //North West
Robot.movement(flm,frm,blm,brm,[0,1,1,0]); Robot.movement(flm,frm,blm,brm,{0,1,1,0});
} }
else{ else{
//South West //South West
Robot.movement(flm,frm,blm,brm,[-1,0,0,-1]); Robot.movement(flm,frm,blm,brm,{-1,0,0,-1});
} }
} }
} }
public void horizontal(float x,DcMotor flm,DcMotor frm,DcMotor blm,DcMotor brm){ public static void horizontal(float x,DcMotor flm,DcMotor frm,DcMotor blm,DcMotor brm){
if(x>0){ if(x>0){
Robot.movement(flm,frm,blm,brm,[1,-1,-1,1]); Robot.movement(flm,frm,blm,brm,{1,-1,-1,1});
}else{ }else{
Robot.movement(flm,frm,blm,brm,[-1,1,1,-1]); Robot.movement(flm,frm,blm,brm,;{-1,1,1,-1});
} }
} }
public void vertical(double y,DcMotor flm,DcMotor frm,DcMotor blm,DcMotor brm){ public static void vertical(double y,DcMotor flm,DcMotor frm,DcMotor blm,DcMotor brm){
if(y>0){ if(y>0){
Robot.movement(flm,frm,blm,brm,[1,1,1,1]); Robot.movement(flm,frm,blm,brm,{1,1,1,1});
}else{ }else{
Robot.movement(flm,frm,blm,brm,[-1,-1,-1,-1]); Robot.movement(flm,frm,blm,brm,{-1,-1,-1,-1});
} }
} }
public void movement(DcMotor flm,DcMotor frm,DcMotor blm,DcMotor brm,int[] list){ public static void movement(DcMotor flm,DcMotor frm,DcMotor blm,DcMotor brm,int[] list){
flm.setPower(list[0]); flm.setPower(list[0]);
frm.setPower(list[1]); frm.setPower(list[1]);
blm.setPower(list[2]); blm.setPower(list[2]);
brm.setPower(list[3]); brm.setPower(list[3]);
} }
public void Rotations(float g2x, DcMotor flm,DcMotor frm,DcMotor blm,DcMotor brm){ public static void Rotations(float g2x, DcMotor flm,DcMotor frm,DcMotor blm,DcMotor brm){
float approx = 0.15; float approx = 0.15;
boolean xnozero = (g2x<-approx || g2x>approx); boolean xnozero = (g2x<-approx || g2x>approx);
if(xnozero){ if(xnozero){
if(x>0){ if(x>0){
Robot.movement(flm,frm,blm,brm,[1,-1,1,-1]); Robot.movement(flm,frm,blm,brm,{1,-1,1,-1});
}else{ }else{
Robot.movement(flm,frm,blm,brm,[-1,1,-1,1]); Robot.movement(flm,frm,blm,brm,{-1,1,-1,1});
} }
} }
} }