SHARE
TWEET

Untitled

a guest Jan 14th, 2020 92 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     public void awdstrafe (char direction, double power, int inches) {
  2.         int totalDistance = robot.inchesToTicks(inches);
  3.  
  4.         RobotCore.frontLeftBeforeTravel = robot.frontLeftDrive.getCurrentPosition();
  5.         RobotCore.frontRightBeforeTravel = robot.frontRightDrive.getCurrentPosition();
  6.         RobotCore.backLeftBeforeTravel = robot.backLeftDrive.getCurrentPosition();
  7.         RobotCore.backRightBeforeTravel = robot.backRightDrive.getCurrentPosition();
  8.  
  9.         switch (direction)
  10.         {
  11.             case 'r':
  12.             case 'R':
  13.                 RobotCore.frontLeftTargetPosition = RobotCore.frontLeftBeforeTravel + totalDistance;
  14.                 RobotCore.frontRightTargetPosition = RobotCore.frontRightBeforeTravel - totalDistance;
  15.                 RobotCore.backLeftTargetPosition = RobotCore.backLeftBeforeTravel - totalDistance;
  16.                 RobotCore.backRightTargetPosition = RobotCore.backRightBeforeTravel + totalDistance;
  17.                 break;
  18.  
  19.             case 'l':
  20.             case 'L':
  21.                 RobotCore.frontLeftTargetPosition = RobotCore.frontLeftBeforeTravel - totalDistance;
  22.                 RobotCore.frontRightTargetPosition = RobotCore.frontRightBeforeTravel + totalDistance;
  23.                 RobotCore.backLeftTargetPosition = RobotCore.backLeftBeforeTravel + totalDistance;
  24.                 RobotCore.backRightTargetPosition = RobotCore.backRightBeforeTravel - totalDistance;
  25.                 break;
  26.         }
  27.  
  28.         robot.setDrivePosition();
  29.         robot.runToDrivePosition();
  30.  
  31.         while (  (robot.frontLeftDrive.isBusy() || robot.frontRightDrive.isBusy() || robot.backLeftDrive.isBusy() || robot.backRightDrive.isBusy() ) && opModeIsActive() )
  32.         {
  33.          
  34.             robot.drive(power);
  35.             // Doing nothing really
  36.         }
  37.  
  38.         robot.drive(0);
  39.         robot.runWithoutDriveEncoders();
  40.     }
  41.  
  42.  
  43.     public void arm (char direction, double power, double revolutions) {
  44.  
  45.         int totalDistance = (int) (revolutions * RobotCore.ARM_REV_TICKS);
  46.  
  47.         RobotCore.armBeforeTravel = RobotCore.armDrive.getCurrentPosition();
  48.         switch (direction)
  49.         {
  50.             case 'F':
  51.                 RobotCore.armTargetPosition = RobotCore.armBeforeTravel + totalDistance;
  52.                 break;
  53.             case 'R':
  54.                 RobotCore.armTargetPosition = RobotCore.armBeforeTravel - totalDistance;
  55.                 break;
  56.         }
  57.  
  58.         robot.armDrive.setTargetPosition(RobotCore.armTargetPosition);
  59.         robot.armDrive.setMode(DcMotor.RunMode.RUN_TO_POSITION);
  60.  
  61.         while (robot.armDrive.isBusy() && opModeIsActive() )
  62.         {
  63.             robot.armDrive.setPower(power);
  64.         }
  65.  
  66.         robot.armDrive.setPower(0);
  67.         robot.armDrive.setMode(DcMotor.RunMode.RUN_USING_ENCODER);
  68.  
  69.     }
  70.  
  71.     private static final String TFOD_MODEL_ASSET = "Skystone.tflite";
  72.     private static final String LABEL_FIRST_ELEMENT = "Stone";
  73.     private static final String LABEL_SECOND_ELEMENT = "Skystone";
  74.     public static boolean skyStoneFound = false;
  75.     public static char skyStonePosition = 'a';
  76.     private static final String VUFORIA_KEY =
  77.             "ATQ4vcD/////AAABmZ3iCVf0xE8/phuApYxF4HWNU6Aw4hYEvtvY+Dp2euVucTl6uFylVRjTTnRw2rVs3Ab5qmQSE+kctil2a1LM3+Y+vjsH9Hw4SAsYRiR8BcsFTGlpk1RzErueBhJA16Mil842aIFWHyhBWs9cR5nHvtbreTE+sRIpLy7SqnNeev5eNfA6NjRClC0UZ4/4ZL7CWjVy9paFUWXViw7yDvzlC1eXThfuwW2xjGX5Y7pwobmWe96hxsDsDhv+hL3WuSMaA3DPVu1G4vYiO1NoF6hJLVJ20GZwBm7DM8ehz1yIkg5rRSGRmhFavWO8DthV14LWnzp+fUXYt8BxuwrLS56Y5teWwGpIBssYUTzkngonug2m";
  78.     public VuforiaLocalizer vuforia;
  79.     public TFObjectDetector tfod;
  80.  
  81.     public void initVuforia() {
  82.         /*
  83.          * Configure Vuforia by creating a Parameter object, and passing it to the Vuforia engine.
  84.          */
  85.         VuforiaLocalizer.Parameters parameters = new VuforiaLocalizer.Parameters();
  86.  
  87.         parameters.vuforiaLicenseKey = VUFORIA_KEY;
  88.         parameters.cameraDirection = VuforiaLocalizer.CameraDirection.BACK;
  89.  
  90.         //  Instantiate the Vuforia engine
  91.         vuforia = ClassFactory.getInstance().createVuforia(parameters);
  92.  
  93.         // Loading trackables is not necessary for the TensorFlow Object Detection engine.
  94.     }
  95.     public void initTfod() {
  96.         int tfodMonitorViewId = hardwareMap.appContext.getResources().getIdentifier(
  97.                 "tfodMonitorViewId", "id", hardwareMap.appContext.getPackageName());
  98.         TFObjectDetector.Parameters tfodParameters = new TFObjectDetector.Parameters(tfodMonitorViewId);
  99.         tfodParameters.minimumConfidence = 0.6;
  100.         tfod = ClassFactory.getInstance().createTFObjectDetector(tfodParameters, vuforia);
  101.         tfod.loadModelFromAsset(TFOD_MODEL_ASSET, LABEL_FIRST_ELEMENT, LABEL_SECOND_ELEMENT);
  102.     }
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