Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void awdstrafe (char direction, double power, int inches) {
- int totalDistance = robot.inchesToTicks(inches);
- RobotCore.frontLeftBeforeTravel = robot.frontLeftDrive.getCurrentPosition();
- RobotCore.frontRightBeforeTravel = robot.frontRightDrive.getCurrentPosition();
- RobotCore.backLeftBeforeTravel = robot.backLeftDrive.getCurrentPosition();
- RobotCore.backRightBeforeTravel = robot.backRightDrive.getCurrentPosition();
- switch (direction)
- {
- case 'r':
- case 'R':
- RobotCore.frontLeftTargetPosition = RobotCore.frontLeftBeforeTravel + totalDistance;
- RobotCore.frontRightTargetPosition = RobotCore.frontRightBeforeTravel - totalDistance;
- RobotCore.backLeftTargetPosition = RobotCore.backLeftBeforeTravel - totalDistance;
- RobotCore.backRightTargetPosition = RobotCore.backRightBeforeTravel + totalDistance;
- break;
- case 'l':
- case 'L':
- RobotCore.frontLeftTargetPosition = RobotCore.frontLeftBeforeTravel - totalDistance;
- RobotCore.frontRightTargetPosition = RobotCore.frontRightBeforeTravel + totalDistance;
- RobotCore.backLeftTargetPosition = RobotCore.backLeftBeforeTravel + totalDistance;
- RobotCore.backRightTargetPosition = RobotCore.backRightBeforeTravel - totalDistance;
- break;
- }
- robot.setDrivePosition();
- robot.runToDrivePosition();
- while ( (robot.frontLeftDrive.isBusy() || robot.frontRightDrive.isBusy() || robot.backLeftDrive.isBusy() || robot.backRightDrive.isBusy() ) && opModeIsActive() )
- {
- robot.drive(power);
- // Doing nothing really
- }
- robot.drive(0);
- robot.runWithoutDriveEncoders();
- }
- public void arm (char direction, double power, double revolutions) {
- int totalDistance = (int) (revolutions * RobotCore.ARM_REV_TICKS);
- RobotCore.armBeforeTravel = RobotCore.armDrive.getCurrentPosition();
- switch (direction)
- {
- case 'F':
- RobotCore.armTargetPosition = RobotCore.armBeforeTravel + totalDistance;
- break;
- case 'R':
- RobotCore.armTargetPosition = RobotCore.armBeforeTravel - totalDistance;
- break;
- }
- robot.armDrive.setTargetPosition(RobotCore.armTargetPosition);
- robot.armDrive.setMode(DcMotor.RunMode.RUN_TO_POSITION);
- while (robot.armDrive.isBusy() && opModeIsActive() )
- {
- robot.armDrive.setPower(power);
- }
- robot.armDrive.setPower(0);
- robot.armDrive.setMode(DcMotor.RunMode.RUN_USING_ENCODER);
- }
- private static final String TFOD_MODEL_ASSET = "Skystone.tflite";
- private static final String LABEL_FIRST_ELEMENT = "Stone";
- private static final String LABEL_SECOND_ELEMENT = "Skystone";
- public static boolean skyStoneFound = false;
- public static char skyStonePosition = 'a';
- private static final String VUFORIA_KEY =
- "ATQ4vcD/////AAABmZ3iCVf0xE8/phuApYxF4HWNU6Aw4hYEvtvY+Dp2euVucTl6uFylVRjTTnRw2rVs3Ab5qmQSE+kctil2a1LM3+Y+vjsH9Hw4SAsYRiR8BcsFTGlpk1RzErueBhJA16Mil842aIFWHyhBWs9cR5nHvtbreTE+sRIpLy7SqnNeev5eNfA6NjRClC0UZ4/4ZL7CWjVy9paFUWXViw7yDvzlC1eXThfuwW2xjGX5Y7pwobmWe96hxsDsDhv+hL3WuSMaA3DPVu1G4vYiO1NoF6hJLVJ20GZwBm7DM8ehz1yIkg5rRSGRmhFavWO8DthV14LWnzp+fUXYt8BxuwrLS56Y5teWwGpIBssYUTzkngonug2m";
- public VuforiaLocalizer vuforia;
- public TFObjectDetector tfod;
- public void initVuforia() {
- /*
- * Configure Vuforia by creating a Parameter object, and passing it to the Vuforia engine.
- */
- VuforiaLocalizer.Parameters parameters = new VuforiaLocalizer.Parameters();
- parameters.vuforiaLicenseKey = VUFORIA_KEY;
- parameters.cameraDirection = VuforiaLocalizer.CameraDirection.BACK;
- // Instantiate the Vuforia engine
- vuforia = ClassFactory.getInstance().createVuforia(parameters);
- // Loading trackables is not necessary for the TensorFlow Object Detection engine.
- }
- public void initTfod() {
- int tfodMonitorViewId = hardwareMap.appContext.getResources().getIdentifier(
- "tfodMonitorViewId", "id", hardwareMap.appContext.getPackageName());
- TFObjectDetector.Parameters tfodParameters = new TFObjectDetector.Parameters(tfodMonitorViewId);
- tfodParameters.minimumConfidence = 0.6;
- tfod = ClassFactory.getInstance().createTFObjectDetector(tfodParameters, vuforia);
- tfod.loadModelFromAsset(TFOD_MODEL_ASSET, LABEL_FIRST_ELEMENT, LABEL_SECOND_ELEMENT);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement