SHARE
TWEET

Untitled

a guest Feb 16th, 2019 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package org.firstinspires.ftc.teamcode;
  2.  
  3. import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
  4. import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
  5. import com.qualcomm.robotcore.hardware.DcMotor;
  6. import com.qualcomm.robotcore.hardware.DcMotorSimple;
  7. import com.qualcomm.robotcore.hardware.Servo;
  8.  
  9. /**
  10.  *Autonomous program for Swerve Robotics tutorial
  11.  */
  12.  
  13. @Autonomous(name = "AutoRedFront", group = "Autonomous")
  14.  
  15.  
  16. public class AutoRedFront extends LinearOpMode
  17. {
  18.     //declare motors
  19.     DcMotor motorLeft = null;
  20.     DcMotor motorRight = null;
  21.  
  22.     DcMotor armLeft = null;
  23.     DcMotor armRight = null;
  24.  
  25.     DcMotor pullLeft = null;
  26.     DcMotor pullRight = null;
  27.  
  28.     //declare servo
  29.     Servo collector = null;
  30.  
  31.  
  32.     @Override public void runOpMode () throws InterruptedException
  33.     {
  34.         /* initialize our hardware variables. Note that the strings used here as parameters
  35.          * to 'get' must correspond to the name you assigned during the robot configuration
  36.          * step you did in the FTC Robot Controller app on the phone
  37.          */
  38.  
  39.         //initialize motors
  40.         motorLeft = hardwareMap.dcMotor.get("motorLeft");
  41.         motorRight = hardwareMap.dcMotor.get("motorRight");
  42.  
  43.         motorLeft.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
  44.         motorRight.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
  45.  
  46.         motorLeft.setDirection(DcMotor.Direction.REVERSE);
  47.         motorRight.setDirection(DcMotor.Direction.FORWARD);
  48.  
  49.  
  50.  
  51.  
  52.  
  53.         //wait for the game to start
  54.         waitForStart ();
  55.  
  56.        DriveBackwards(DRIVE_POWER,500);
  57.  
  58.         TurnLeftTime(DRIVE_POWER,2000);
  59.  
  60.         DriveFowardTime(DRIVE_POWER,3000);
  61.  
  62.         TurnLeftTime(DRIVE_POWER,4000);
  63.  
  64.  
  65.         DriveFowardTime(DRIVE_POWER,3000);
  66.  
  67.  
  68.         //finish the objective and stop
  69.         StopDriving();
  70.  
  71.  
  72.  
  73.     }
  74.  
  75.     //make "method" for functions
  76.  
  77.     double DRIVE_POWER = 1.0;
  78.  
  79.     public void DriveForward (double power)
  80.     {
  81.         motorLeft.setPower(0.4);
  82.         motorRight.setPower(0.4);
  83.     }
  84.  
  85.     public void DriveFowardTime (double power, long time) throws InterruptedException
  86.     {
  87.         DriveForward(0.4);
  88.         Thread.sleep(2000);
  89.     }
  90.  
  91.     public void DriveBackwards (double power) {
  92.         motorLeft.setPower(-0.4);
  93.         motorRight.setPower(-0.4);
  94.     }
  95.         public void DriveBackwards (double power, long time) throws InterruptedException
  96.         {
  97.             DriveBackwards(0.4);
  98.             Thread.sleep(3000);
  99.         }
  100.  
  101.     public void StopDriving ()
  102.     {
  103.         DriveForward(0);
  104.     }
  105.  
  106.     public void TurnLeft (double power)
  107.     {
  108.         motorLeft.setPower(-0.4);
  109.         motorRight.setPower(0.4);
  110.     }
  111.  
  112.     public void TurnLeftTime (double power, long time) throws InterruptedException
  113.     {
  114.         TurnLeft(0.4);
  115.         Thread.sleep(2000);
  116.     }
  117.  
  118.     public void TurnRight (double power)
  119.     {
  120.         TurnLeft(-0.4);
  121.     }
  122.  
  123.     public void TurnRightTime (double power, long time) throws InterruptedException
  124.     {
  125.         TurnRight(0.4);
  126.         Thread.sleep(2000);
  127.     }
  128.  
  129.  
  130.  
  131.  
  132.  
  133. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top