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.*;
- import org.swerverobotics.library.*;
- import org.swerverobotics.library.interfaces.*;
- /**
- * 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;
- @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");
- 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);
- }
- // lower slide bar
- if (gamepad1.right_bumper){
- slide1.setPower(50);
- }
- else if (gamepad1.right_trigger > 0) {
- slide1.setPower(-50);
- }
- else {
- slide1.setPower(0);
- }
- //higher slide bar
- if (gamepad1.left_bumper){
- slide2.setPower(50);
- }
- else if (gamepad1.left_trigger > 0){
- slide2.setPower(-50);
- }
- else {
- slide2.setPower(0);
- }
- }
- telemetry.update();
- idle();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement