Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package org.usfirst.ftc.exampleteam.yourcodehere;
- import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
- import com.qualcomm.robotcore.hardware.DcMotor;
- import com.qualcomm.robotcore.hardware.Servo;
- import org.swerverobotics.library.SynchronousOpMode;
- /**
- * A skeletal example of a do-nothing first OpMode. Go ahead and change this code
- * to suit your needs, or create sibling OpModes adjacent to this one in the same
- * Java package.
- */
- @TeleOp(name = "My First OpMode")
- public class MyFirstOpMode extends SynchronousOpMode {
- /* Declare here any fields you might find useful. */
- public DcMotor motorLeft = null;
- public DcMotor motorRight = null;
- public DcMotor slide1 = null;
- public DcMotor slide2 = null;
- public Servo pusher = null;
- public Servo P1 = null;
- public Servo P2 = null;
- @Override
- public void main() throws InterruptedException {
- /* Initialize our hardware variables. Note that the strings used here as parameters
- * to 'get' must correspond to the names you assigned during the robot configuration
- * step you did in the FTC Robot Controller app on the phone.
- */
- motorLeft = this.hardwareMap.dcMotor.get("motorLeft");
- motorRight = this.hardwareMap.dcMotor.get("motorRight");
- pusher = hardwareMap.servo.get("pusher");
- slide1 = hardwareMap.dcMotor.get("slide1");
- slide2 = hardwareMap.dcMotor.get("slide2");
- P1 = hardwareMap.servo.get("P1");
- P2 = hardwareMap.servo.get("P2");
- motorRight.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
- motorLeft.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
- slide1.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
- slide2.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
- waitForStart();
- // Go go gadget robot!
- while (opModeIsActive()) {
- double powerRight = 0;
- double powerLeft = 0;
- if (updateGamepads()) {
- powerLeft = gamepad1.left_stick_y * 0.7;
- powerRight = gamepad1.right_stick_y * 0.7;
- this.motorLeft.setPower(powerLeft);
- this.motorRight.setPower(-powerRight);
- if (gamepad1.dpad_up) {
- pusher.setPosition(100);
- }
- else if (gamepad1.dpad_down) {
- pusher.setPosition(0.5);
- }
- // lower slide bar
- if (gamepad1.right_bumper) {
- slide1.setPower(25);
- } else if (gamepad1.right_trigger > 0) {
- slide1.setPower(-25);
- } else {
- slide1.setPower(0);
- }
- //higher slide bar
- if (gamepad1.left_bumper) {
- slide2.setPower(-25);
- } else if (gamepad1.left_trigger > 0) {
- slide2.setPower(25);
- } else {
- slide2.setPower(0);
- }
- //pincers
- if(gamepad1.a){
- P1.setPosition(0);
- P2.setPosition(1);
- }
- if(gamepad1.b){
- P1.setPosition(1);
- P2.setPosition(0);
- }
- }
- telemetry.update();
- idle();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement