Actualiser WeRobot-Code.java
This commit is contained in:
parent
807649c996
commit
65844de4cb
1 changed files with 120 additions and 120 deletions
|
@ -2,6 +2,7 @@ package org.firstinspires.ftc.teamcode;
|
|||
//package fr.gzod01.werobot.competition_singapour_2023;
|
||||
|
||||
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
|
||||
import com.qualcomm.robotcore.robot.Robot;
|
||||
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
|
||||
import com.qualcomm.robotcore.hardware.DcMotor;
|
||||
import com.qualcomm.robotcore.hardware.DcMotorSimple;
|
||||
|
@ -72,7 +73,7 @@ public class DualDrive extends LinearOpMode {
|
|||
}
|
||||
}
|
||||
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;
|
||||
boolean xnozero = (x<-approx || x>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(y>0){
|
||||
// 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
|
||||
Robot.movement(flm,frm,blm,brm,[0,-1,-1,0]);
|
||||
Robot.movement(flm,frm,blm,brm,{0,-1,-1,0});
|
||||
}
|
||||
}else{
|
||||
if(y>0){
|
||||
//North West
|
||||
Robot.movement(flm,frm,blm,brm,[0,1,1,0]);
|
||||
Robot.movement(flm,frm,blm,brm,{0,1,1,0});
|
||||
}
|
||||
else{
|
||||
//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){
|
||||
Robot.movement(flm,frm,blm,brm,[1,-1,-1,1]);
|
||||
Robot.movement(flm,frm,blm,brm,{1,-1,-1,1});
|
||||
}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){
|
||||
Robot.movement(flm,frm,blm,brm,[1,1,1,1]);
|
||||
Robot.movement(flm,frm,blm,brm,{1,1,1,1});
|
||||
}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]);
|
||||
frm.setPower(list[1]);
|
||||
blm.setPower(list[2]);
|
||||
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;
|
||||
boolean xnozero = (g2x<-approx || g2x>approx);
|
||||
if(xnozero){
|
||||
if(x>0){
|
||||
Robot.movement(flm,frm,blm,brm,[1,-1,1,-1]);
|
||||
Robot.movement(flm,frm,blm,brm,{1,-1,1,-1});
|
||||
}else{
|
||||
Robot.movement(flm,frm,blm,brm,[-1,1,-1,1]);
|
||||
Robot.movement(flm,frm,blm,brm,{-1,1,-1,1});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue