helloworld
This commit is contained in:
parent
79ec807735
commit
64f9226d29
1 changed files with 26 additions and 20 deletions
|
@ -6,10 +6,15 @@ 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;
|
||||||
|
|
||||||
@TeleOp
|
@TeleOp(name="WeRobot: FGC2023 OpMode", group="WeRobot")
|
||||||
public class DualDrive extends LinearOpMode {
|
public class DualDrive extends LinearOpMode {
|
||||||
private DcMotor rightmotor;
|
private DcMotor flm;
|
||||||
private DcMotor leftmotor;
|
private DcMotor frm;
|
||||||
|
private DcMotor brm;
|
||||||
|
private DcMotor blm;
|
||||||
|
private DcMotor moissonmotor;
|
||||||
|
private DcMotor launchermotor;
|
||||||
|
private DcMotor mountmotor;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void runOpMode() {
|
public void runOpMode() {
|
||||||
|
@ -17,23 +22,23 @@ public class DualDrive extends LinearOpMode {
|
||||||
double y;
|
double y;
|
||||||
float g2x;
|
float g2x;
|
||||||
boolean ismoissonactive=false;
|
boolean ismoissonactive=false;
|
||||||
boolean a;
|
boolean ga;
|
||||||
boolean y;
|
boolean gy;
|
||||||
boolean preva =false;
|
boolean preva =false;
|
||||||
flm = hardwareMap.get(DcMotor.class, "0");
|
flm = hardwareMap.get(DcMotor.class, "flm");
|
||||||
frm = hardwareMap.get(DcMotor.class, "1");
|
frm = hardwareMap.get(DcMotor.class, "frm");
|
||||||
blm = hardwareMap.get(DcMotor.class, "2");
|
blm = hardwareMap.get(DcMotor.class, "blm");
|
||||||
brm = hardwareMap.get(DcMotor.class, "3");
|
brm = hardwareMap.get(DcMotor.class, "brm");
|
||||||
moissonmotor = hardwareMap.get(DcMotor.class, "4");
|
moissonmotor = hardwareMap.get(DcMotor.class, "msn");
|
||||||
launchermotor = hardwareMap.get(DcMotor.class, "5");
|
launchermotor = hardwareMap.get(DcMotor.class, "lnc");
|
||||||
mountmotor = hardwareMap.get(DcMotor.class, "6");
|
mountmotor = hardwareMap.get(DcMotor.class, "mnt");
|
||||||
waitForStart();
|
waitForStart();
|
||||||
|
|
||||||
while (opModeIsActive()) {
|
while (opModeIsActive()) {
|
||||||
x = gamepad1.left_stick_x;
|
x = gamepad1.left_stick_x;
|
||||||
y = -gamepad1.left_stick_y;
|
y = -gamepad1.left_stick_y;
|
||||||
a = gamepad1.a;
|
a = gamepad1.a;
|
||||||
gy = gamepad.y;
|
gy = gamepad1.y;
|
||||||
if(a & !preva){
|
if(a & !preva){
|
||||||
ismoissonactive=!ismoissonactive;
|
ismoissonactive=!ismoissonactive;
|
||||||
preva=true;
|
preva=true;
|
||||||
|
@ -67,7 +72,7 @@ public class DualDrive extends LinearOpMode {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public class Robot{
|
public class Robot{
|
||||||
public void moves(x,y,flm,frm,blm,brm){
|
public 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);
|
||||||
|
@ -93,13 +98,14 @@ public class Robot{
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
public void diagonal(x,y,flm,frm,blm,brm){
|
public 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]);
|
||||||
}
|
}
|
||||||
|
@ -114,7 +120,7 @@ public class Robot{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void horizontal(x,flm,frm,blm,brm){
|
public 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{
|
||||||
|
@ -124,7 +130,7 @@ public class Robot{
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
public void vertical(y,flm,frm,blm,brm){
|
public 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{
|
||||||
|
@ -132,13 +138,13 @@ public class Robot{
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
public void movement(flm,frm,blm,brm,list){
|
public 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(g2x,flm,frm,blm,brm){
|
public 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){
|
||||||
|
|
Loading…
Reference in a new issue