Message
Message
teamcode;
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
import com.qualcomm.robotcore.hardware.DcMotor;
import com.qualcomm.robotcore.hardware.DcMotorSimple;
import com.qualcomm.robotcore.hardware.Servo;
import com.qualcomm.robotcore.util.ElapsedTime;
hR.setPosition(0.6);
hL.setPosition(0.475);
}
homePos();
zero_slides();
//reset everything
}
@Override
public void runOpMode() {
// wheels
LF = hardwareMap.get(DcMotor.class, "leftFrontDrive");
LB = hardwareMap.get(DcMotor.class, "leftBackDrive");
RF = hardwareMap.get(DcMotor.class, "rightFrontDrive");
RB = hardwareMap.get(DcMotor.class, "rightBackDrive");
// slides
verticalSlide = hardwareMap.get(DcMotor.class, "verticalSlide");
slideLeft = hardwareMap.get(DcMotor.class, "slideLeft");
slideRight = hardwareMap.get(DcMotor.class, "slideRight");
// servos
pitchServo = hardwareMap.get(Servo.class, "pitchIntake");
yawServo = hardwareMap.get(Servo.class, "yawIntake");
tipServo = hardwareMap.get(Servo.class, "tipIntake");
LF.setDirection(DcMotor.Direction.REVERSE);
LB.setDirection(DcMotor.Direction.REVERSE);
RF.setDirection(DcMotor.Direction.FORWARD);
RB.setDirection(DcMotor.Direction.FORWARD);
verticalSlide.setDirection(DcMotor.Direction.REVERSE);
slideLeft.setDirection(DcMotorSimple.Direction.REVERSE);
slideRight.setDirection(DcMotorSimple.Direction.FORWARD);
initializeAll();
telemetry.addData("Status", "Initialized");
telemetry.update();
waitForStart();
runtime.reset();
while (opModeIsActive()) {
double max;
double axial = -gamepad1.left_stick_y;
double lateral = gamepad1.left_stick_x;
double yaw = gamepad1.right_stick_x;
//GAMEPAD
1-----------------------------------------------------------------------------
double speed_factor=0.5;
if (gamepad1.right_bumper) {
speed_factor = 1;
}
if(gamepad1.left_bumper){
speed_factor = 0.2;
}
if(gamepad1.b){
tipServo.setPosition(0.5);
}
if (gamepad1.a) {
hR.setPosition(0.3);
hL.setPosition(0.65);
}
if(gamepad1.y){
initIntakePos();
}
//GAMEPAD
2-----------------------------------------------------------------------------
//handoff sequence and get position for basket
if (gamepad2.dpad_up) {
hR.setPosition(0.3);
hL.setPosition(0.65);
sleep(250);
tipServo.setPosition(0.5);
sleep(250);
hPitch.setPosition(0.85);
verticalSlide.setTargetPosition(3000);
verticalSlide.setPower(1);
verticalSlide.setMode(DcMotor.RunMode.RUN_TO_POSITION);
sleep(2000);
}
if (gamepad2.dpad_down) {
slideLeft.setTargetPosition(1000);
slideLeft.setPower(0.7);
slideLeft.setMode(DcMotor.RunMode.RUN_TO_POSITION);
slideRight.setTargetPosition(1000);
slideRight.setPower(0.7);
slideRight.setMode(DcMotor.RunMode.RUN_TO_POSITION);
}
if(gamepad2.b){
hR.setPosition(0.15);
hL.setPosition(0.8);
}
if(gamepad2.y){
homePos();
onlyVerZero();
}
if (gamepad2.a) {
hPitch.setPosition(0.9);
}
if (gamepad2.x) {
verticalSlide.setTargetPosition(100);
verticalSlide.setPower(1);
verticalSlide.setMode(DcMotor.RunMode.RUN_TO_POSITION);
hYaw.setPosition(0);
hPitch.setPosition(0.15);
hR.setPosition(0.6);
hL.setPosition(0.475);
sleep(100);
pitchServo.setPosition(1);
}
//commit hang
if(gamepad2.dpad_left){
verticalSlide.setTargetPosition(2500);
verticalSlide.setPower(0.8);
verticalSlide.setMode(DcMotor.RunMode.RUN_TO_POSITION);
}
LF.setPower(LFpw * speed_factor);
RF.setPower(RFpw * speed_factor);
LB.setPower(LBpw * speed_factor);
RB.setPower(RBpw * speed_factor);