Pickup macro, teleop cleaned up a lil bit
This commit is contained in:
parent
3efb8adf21
commit
0ef239ca91
|
@ -1,5 +1,6 @@
|
||||||
package org.firstinspires.ftc.teamcode.hardware;
|
package org.firstinspires.ftc.teamcode.hardware;
|
||||||
|
|
||||||
|
import static org.firstinspires.ftc.robotcore.external.BlocksOpModeCompanion.gamepad2;
|
||||||
import static org.firstinspires.ftc.teamcode.util.Configurables.ARMACCSCORE;
|
import static org.firstinspires.ftc.teamcode.util.Configurables.ARMACCSCORE;
|
||||||
import static org.firstinspires.ftc.teamcode.util.Configurables.ARMPICKUPSTACK;
|
import static org.firstinspires.ftc.teamcode.util.Configurables.ARMPICKUPSTACK;
|
||||||
import static org.firstinspires.ftc.teamcode.util.Configurables.ARMREST;
|
import static org.firstinspires.ftc.teamcode.util.Configurables.ARMREST;
|
||||||
|
@ -34,10 +35,11 @@ import static org.firstinspires.ftc.teamcode.util.Constants.SLIDERIGHT;
|
||||||
import static org.firstinspires.ftc.teamcode.util.Constants.WRIST;
|
import static org.firstinspires.ftc.teamcode.util.Constants.WRIST;
|
||||||
|
|
||||||
import com.acmerobotics.dashboard.config.Config;
|
import com.acmerobotics.dashboard.config.Config;
|
||||||
|
import com.arcrobotics.ftclib.gamepad.GamepadEx;
|
||||||
|
import com.arcrobotics.ftclib.gamepad.GamepadKeys;
|
||||||
import com.qualcomm.hardware.rev.RevBlinkinLedDriver;
|
import com.qualcomm.hardware.rev.RevBlinkinLedDriver;
|
||||||
import com.qualcomm.robotcore.hardware.DcMotor;
|
import com.qualcomm.robotcore.hardware.DcMotor;
|
||||||
import com.qualcomm.robotcore.hardware.DcMotorSimple;
|
import com.qualcomm.robotcore.hardware.DcMotorSimple;
|
||||||
import com.qualcomm.robotcore.hardware.Gamepad;
|
|
||||||
import com.qualcomm.robotcore.hardware.HardwareMap;
|
import com.qualcomm.robotcore.hardware.HardwareMap;
|
||||||
import com.qualcomm.robotcore.hardware.Servo;
|
import com.qualcomm.robotcore.hardware.Servo;
|
||||||
|
|
||||||
|
@ -67,6 +69,8 @@ public class Robot {
|
||||||
@Getter
|
@Getter
|
||||||
private Slides slides;
|
private Slides slides;
|
||||||
|
|
||||||
|
GamepadEx controller2 = new GamepadEx(gamepad2);
|
||||||
|
|
||||||
public Robot init(HardwareMap hardwareMap) {
|
public Robot init(HardwareMap hardwareMap) {
|
||||||
this.drive = new MecanumDrive(hardwareMap);
|
this.drive = new MecanumDrive(hardwareMap);
|
||||||
this.hang = new Hang().init(hardwareMap);
|
this.hang = new Hang().init(hardwareMap);
|
||||||
|
@ -237,29 +241,33 @@ public class Robot {
|
||||||
public void wristScore() {
|
public void wristScore() {
|
||||||
this.wrist.setPosition(WRISTSCORE);
|
this.wrist.setPosition(WRISTSCORE);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Claw {
|
public static boolean clawIsOpen;
|
||||||
private static final double CLAW_KP = 0.15;
|
|
||||||
|
|
||||||
|
public static class Claw {
|
||||||
private Servo claw;
|
private Servo claw;
|
||||||
|
|
||||||
public Claw init(HardwareMap hardwareMap) {
|
public Claw init(HardwareMap hardwareMap) {
|
||||||
this.claw = hardwareMap.get(Servo.class, CLAW);
|
this.claw = hardwareMap.get(Servo.class, CLAW);
|
||||||
this.claw.setPosition(CLOSE);
|
close();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void close() {
|
public void close() {
|
||||||
this.claw.setPosition(CLOSE);
|
this.claw.setPosition(CLOSE);
|
||||||
|
clawIsOpen = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void open() {
|
public void open() {
|
||||||
this.claw.setPosition(OPEN);
|
this.claw.setPosition(OPEN);
|
||||||
|
clawIsOpen = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void openStack() {
|
public void openStack() {
|
||||||
this.claw.setPosition(BIGOPEN);
|
this.claw.setPosition(BIGOPEN);
|
||||||
|
clawIsOpen = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPos(double pos) {
|
public void setPos(double pos) {
|
||||||
|
@ -276,6 +284,14 @@ public class Robot {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void LED() {
|
||||||
|
if (clawIsOpen) {
|
||||||
|
white();
|
||||||
|
} else {
|
||||||
|
gold();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void gold() {
|
public void gold() {
|
||||||
this.led.setPattern(RevBlinkinLedDriver.BlinkinPattern.BLUE_VIOLET);
|
this.led.setPattern(RevBlinkinLedDriver.BlinkinPattern.BLUE_VIOLET);
|
||||||
}
|
}
|
||||||
|
@ -304,25 +320,45 @@ public class Robot {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void pickupMacro(Gamepad gamepad, Runtime runtime) {
|
public void pickupMacro(GamepadEx gamepadEx, double runtime) {
|
||||||
switch (pickupMacroState) {
|
switch (pickupMacroState) {
|
||||||
case IDLE:
|
case IDLE:
|
||||||
if (gamepad.dpad_down)
|
if (controller2.wasJustPressed(GamepadKeys.Button.DPAD_DOWN)){
|
||||||
|
pickupMacroState = pickupMacroStates.OPEN;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case OPEN:
|
case OPEN:
|
||||||
|
delay = runtime + .2;
|
||||||
|
this.getClaw().open();
|
||||||
|
pickupMacroState = pickupMacroStates.DROP;
|
||||||
break;
|
break;
|
||||||
case DROP:
|
case DROP:
|
||||||
|
if (runtime > delay) {
|
||||||
|
this.getArm().pickup();
|
||||||
|
delay= runtime + .2;
|
||||||
|
pickupMacroState = pickupMacroStates.CLOSE;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case CLOSE:
|
case CLOSE:
|
||||||
|
if (runtime > delay) {
|
||||||
|
this.getClaw().close();
|
||||||
|
delay= runtime + .1;
|
||||||
|
pickupMacroState = pickupMacroStates.NEUTRAL;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case NEUTRAL:
|
case NEUTRAL:
|
||||||
|
if (runtime > delay) {
|
||||||
|
this.getArm().armRest();
|
||||||
|
pickupMacroState = pickupMacroStates.IDLE;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pickupMacroStates pickupMacroState = pickupMacroStates.IDLE;
|
public pickupMacroStates pickupMacroState = pickupMacroStates.IDLE;
|
||||||
enum pickupMacroStates{
|
|
||||||
|
public enum pickupMacroStates{
|
||||||
IDLE,
|
IDLE,
|
||||||
OPEN,
|
OPEN,
|
||||||
DROP,
|
DROP,
|
||||||
|
@ -331,9 +367,7 @@ public class Robot {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
double runtime;
|
double delay;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public TrajectorySequenceBuilder getTrajectorySequenceBuilder() {
|
public TrajectorySequenceBuilder getTrajectorySequenceBuilder() {
|
||||||
this.drive.update();
|
this.drive.update();
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package org.firstinspires.ftc.teamcode.opmodes;
|
package org.firstinspires.ftc.teamcode.opmodes;
|
||||||
|
|
||||||
|
import com.arcrobotics.ftclib.gamepad.GamepadEx;
|
||||||
|
import com.arcrobotics.ftclib.gamepad.GamepadKeys;
|
||||||
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
|
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
|
||||||
|
|
||||||
import org.firstinspires.ftc.teamcode.hardware.Robot;
|
import org.firstinspires.ftc.teamcode.hardware.Robot;
|
||||||
|
@ -15,16 +17,11 @@ public class MainTeleOp extends OpMode {
|
||||||
this.robot = new Robot().init(hardwareMap);
|
this.robot = new Robot().init(hardwareMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
GamepadEx controller2 = new GamepadEx(gamepad2);
|
||||||
|
|
||||||
public void loop() {
|
public void loop() {
|
||||||
boolean slideUp = gamepad2.dpad_up;
|
boolean slideUp = gamepad2.dpad_up;
|
||||||
boolean restArm = gamepad2.x;
|
|
||||||
boolean pickupArm = gamepad2.dpad_down;
|
|
||||||
boolean scoreArm = gamepad2.a;
|
|
||||||
boolean plane = gamepad2.right_bumper;
|
boolean plane = gamepad2.right_bumper;
|
||||||
boolean claw = gamepad2.b;
|
|
||||||
boolean pickupWrist = gamepad2.x;
|
|
||||||
boolean scoreWrist = gamepad2.a;
|
|
||||||
boolean slideDown = gamepad2.dpad_left;
|
boolean slideDown = gamepad2.dpad_left;
|
||||||
boolean hang = gamepad2.left_bumper;
|
boolean hang = gamepad2.left_bumper;
|
||||||
boolean hangRelease = gamepad2.y;
|
boolean hangRelease = gamepad2.y;
|
||||||
|
@ -39,27 +36,23 @@ public class MainTeleOp extends OpMode {
|
||||||
} else {
|
} else {
|
||||||
this.robot.getSlides().slideStop();
|
this.robot.getSlides().slideStop();
|
||||||
}
|
}
|
||||||
//Arm
|
|
||||||
if (pickupArm) {
|
//Macros
|
||||||
this.robot.getArm().pickup();
|
this.robot.getLed().LED();
|
||||||
} else if (restArm) {
|
this.robot.pickupMacro(controller2,getRuntime());
|
||||||
this.robot.getArm().armRest();
|
|
||||||
} else if (scoreArm) {
|
//Arm and Wrist
|
||||||
|
if (controller2.wasJustPressed(GamepadKeys.Button.X)){
|
||||||
this.robot.getArm().armSecondaryScore();
|
this.robot.getArm().armSecondaryScore();
|
||||||
|
this.robot.getWrist().wristScore();
|
||||||
|
} else if (controller2.wasJustPressed(GamepadKeys.Button.A)){
|
||||||
|
this.robot.getArm().armRest();
|
||||||
|
this.robot.getWrist().wristPickup();
|
||||||
|
this.robot.getClaw().close();
|
||||||
}
|
}
|
||||||
//Claw
|
//Claw
|
||||||
if (claw) {
|
if (controller2.wasJustPressed(GamepadKeys.Button.B)){
|
||||||
this.robot.getClaw().open();
|
this.robot.getClaw().open();
|
||||||
this.robot.getLed().white();
|
|
||||||
} else {
|
|
||||||
this.robot.getClaw().close();
|
|
||||||
this.robot.getLed().gold();
|
|
||||||
}
|
|
||||||
//Wrist
|
|
||||||
if (pickupWrist) {
|
|
||||||
this.robot.getWrist().wristPickup();
|
|
||||||
} else if (scoreWrist) {
|
|
||||||
this.robot.getWrist().wristScore();
|
|
||||||
}
|
}
|
||||||
//Hang
|
//Hang
|
||||||
if (hang) {
|
if (hang) {
|
||||||
|
@ -68,17 +61,18 @@ public class MainTeleOp extends OpMode {
|
||||||
this.robot.getHang().hangRelease();
|
this.robot.getHang().hangRelease();
|
||||||
} else if (hangPlane) {
|
} else if (hangPlane) {
|
||||||
this.robot.getHang().hangPlane();
|
this.robot.getHang().hangPlane();
|
||||||
} else {
|
|
||||||
this.robot.getHang().hangIdle();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int Position = this.robot.getHang().hangRight.getCurrentPosition();
|
int Position = this.robot.getHang().hangRight.getCurrentPosition();
|
||||||
telemetry.addData("position",(Position));
|
telemetry.addData("position",(Position));
|
||||||
telemetry.update();
|
telemetry.update();
|
||||||
|
|
||||||
//Plane
|
//Plane
|
||||||
if (plane) {
|
if (plane) {
|
||||||
this.robot.getPlane().planeLaunch();
|
this.robot.getPlane().planeLaunch();
|
||||||
}else {
|
}else {
|
||||||
this.robot.getPlane().planeLock();
|
this.robot.getPlane().planeLock();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue