Skip to content

Commit

Permalink
Finish code for meet
Browse files Browse the repository at this point in the history
  • Loading branch information
iamwood committed Jan 28, 2019
1 parent 856a336 commit 689ede4
Show file tree
Hide file tree
Showing 9 changed files with 210 additions and 280 deletions.
8 changes: 4 additions & 4 deletions TeamCode/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

//FTC libraries
implementation "com.github.modular-ftc:robotcontroller-repackaged:$ftc_version.0-lite"
implementation "com.github.modular-ftc:robotcore-repackaged:$ftc_version.0-lite"
implementation "com.github.modular-ftc:ftc-common-repackaged:$ftc_version.0-lite"
implementation "com.github.modular-ftc:robotcontroller-repackaged:$ftc_version.0"
implementation "com.github.modular-ftc:robotcore-repackaged:$ftc_version.0"
implementation "com.github.modular-ftc:ftc-common-repackaged:$ftc_version.0"

implementation "org.first.ftc:hardware:$ftc_version"

//The Pattonville Robotics shared libraries are included by default. Remove the following line to stop using them.
implementation "com.github.Pattonville-Robotics:Common-Code:7d468d4ce4"
implementation "com.github.Pattonville-Robotics:Common-Code:a91da37ecf"

implementation 'org.apache.commons:commons-math3:3.6.1'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
import com.qualcomm.robotcore.hardware.DcMotor;
import com.qualcomm.robotcore.hardware.Servo;

import org.pattonvillerobotics.commoncode.enums.ColorSensorColor;
import org.pattonvillerobotics.commoncode.enums.Direction;
import org.pattonvillerobotics.commoncode.opmodes.OpModeGroups;
import org.pattonvillerobotics.commoncode.robotclasses.drive.MecanumEncoderDrive;
Expand All @@ -25,105 +21,70 @@ public class CraterAutonomous extends LinearOpMode {
private VuforiaNavigation vuforia;

private TapeMeasureLifter lifter;
private IntakeMechanism intakeMechanism;

@Override
public void runOpMode() {
initialize();
waitForStart();

int mineralCompensationDistance;

lifter.winchMotor.setPower(0.5);

sleep(3300);
sleep(2300);

lifter.winchMotor.setPower(0.1);
lifter.winchMotor.setPower(0.2);

drive.moveInches(Direction.FORWARD,1, 0.3);
drive.moveInches(Direction.FORWARD,1, 0.5);

drive.moveInches(Direction.LEFT, 6, 0.4);
sleep(100);

lifter.winchMotor.setPower(-0.5);
drive.moveInches(Direction.BACKWARD,0.7, 0.4);

sleep(2900);
drive.moveInches(Direction.LEFT, 4, 0.3);

lifter.winchMotor.setPower(0);
lifter.winchMotor.setPower(-0.3);

drive.moveInches(Direction.FORWARD, 12, 0.7);
drive.moveInches(Direction.FORWARD, 3, 0.8);

drive.rotateDegrees(Direction.CLOCKWISE, 6, 0.4);
drive.moveInches(Direction.RIGHT, 8, 0.8);

drive.moveInches(Direction.BACKWARD, 4, 0.8);

// take picture, analyze
mineralDetector.process(vuforia.getImage());

if(mineralDetector.getAnalysis() == ColorSensorColor.YELLOW) {
//for determining what distance will get the robot to a specific point, depending on which mineral is "chosen"
mineralCompensationDistance = 43;
drive.moveInches(Direction.RIGHT, 4, 0.7);
} else {
drive.moveInches(Direction.RIGHT, 16, 0.7);
lifter.winchMotor.setPower(0);

//take picture, analyze
for (int i = 0; i < 7; i++) {
mineralDetector.process(vuforia.getImage());

if(mineralDetector.getAnalysis() == ColorSensorColor.YELLOW) {
drive.moveInches(Direction.RIGHT, 5, 0.7);
mineralCompensationDistance = 62;

} else {
drive.moveInches(Direction.LEFT, 27, 0.7);
mineralCompensationDistance = 25;
}
}

drive.moveInches(Direction.FORWARD, 8, 0.7);
drive.moveInches(Direction.BACKWARD, 10, 0.7);

drive.moveInches(Direction.LEFT, mineralCompensationDistance, 0.8);

/*
drive.rotateDegrees(Direction.CLOCKWISE, 50, 0.7);
drive.moveInches(Direction.LEFT, 10, 0.6);
drive.moveInches(Direction.RIGHT, 2, 0.5);
drive.moveInches(Direction.BACKWARD, 35, 1);
drive.rotateDegrees(Direction.CLOCKWISE, 6, 0.5);

sleep(500);
intakeMechanism.raise();
sleep(600);
intakeMechanism.expulsion();
sleep(1000);
intakeMechanism.turnOffIntake();
intakeMechanism.raise();
drive.rotateDegrees(Direction.COUNTERCLOCKWISE, 180, 0.7);
drive.moveInches(Direction.FORWARD, 12, 0.7);

drive.moveInches(Direction.BACKWARD, 40, 1);
switch (mineralDetector.getHorizontalAnalysis()) {
case RIGHT:
drive.moveInches(Direction.RIGHT, 8, 0.7);
break;
case MIDDLE:
drive.moveInches(Direction.LEFT, 7, 0.7);
break;
case LEFT:
default:
drive.moveInches(Direction.LEFT, 28, 0.7);
}

intakeMechanism.drop();*/
drive.moveInches(Direction.FORWARD, 25, 1);
}

public void initialize() {
ImageProcessor.initOpenCV(hardwareMap, this);
mineralDetector = new MineralDetector(CustomizedRobotParameters.PHONE_ORIENTATION, true);

mineralDetector = new MineralDetector(CustomizedRobotParameters.PHONE_ORIENTATION, false);

vuforia = new VuforiaNavigation(CustomizedRobotParameters.VUFORIA_PARAMETERS);

drive = new MecanumEncoderDrive(hardwareMap, this, CustomizedRobotParameters.ROBOT_PARAMETERS);

lifter = new TapeMeasureLifter(hardwareMap, this);

intakeMechanism = new IntakeMechanism(hardwareMap, this);

intakeMechanism.raise();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,77 +24,38 @@ public class CraterWithoutLanderAuto extends LinearOpMode {
private MineralDetector mineralDetector;
private VuforiaNavigation vuforia;

private TapeMeasureLifter lifter;
private IntakeMechanism intakeMechanism;

@Override
public void runOpMode() {
initialize();
waitForStart();

int mineralCompensationDistance;

drive.moveInches(Direction.FORWARD, 7, 0.7);
drive.moveInches(Direction.RIGHT, 4, 0.8);

drive.moveInches(Direction.LEFT, 6, 0.7);
drive.moveInches(Direction.BACKWARD, 2, 0.8);

// take picture, analyze

mineralDetector.process(vuforia.getImage());

if(mineralDetector.getAnalysis() == ColorSensorColor.YELLOW) {
//for determining what distance will get the robot to a specific point, depending on which mineral is "chosen"
mineralCompensationDistance = 43;
drive.moveInches(Direction.RIGHT, 4, 0.7);
} else {
drive.moveInches(Direction.RIGHT, 16, 0.7);
//take picture, analyze

for (int i = 0; i < 7; i++) {
mineralDetector.process(vuforia.getImage());

if(mineralDetector.getAnalysis() == ColorSensorColor.YELLOW) {
drive.moveInches(Direction.RIGHT, 5, 0.7);
mineralCompensationDistance = 62;

} else {
//program failed. Zero stars.
drive.moveInches(Direction.LEFT, 27, 0.7);
mineralCompensationDistance = 25;
}
}

drive.moveInches(Direction.FORWARD, 12, 0.7);
drive.moveInches(Direction.BACKWARD, 10, 0.7);

drive.moveInches(Direction.LEFT, mineralCompensationDistance, 0.8);

drive.rotateDegrees(Direction.CLOCKWISE, 50, 0.7);

drive.moveInches(Direction.LEFT, 10, 0.6);

drive.moveInches(Direction.RIGHT, 2, 0.5);

drive.moveInches(Direction.BACKWARD, 35, 1);
drive.rotateDegrees(Direction.CLOCKWISE, 6, 0.5);

sleep(500);

intakeMechanism.raise();

sleep(600);

intakeMechanism.expulsion();

sleep(1000);

intakeMechanism.turnOffIntake();

intakeMechanism.raise();

drive.rotateDegrees(Direction.COUNTERCLOCKWISE, 180, 0.7);
drive.moveInches(Direction.FORWARD, 12, 0.7);

drive.moveInches(Direction.BACKWARD, 40, 1);
switch (mineralDetector.getHorizontalAnalysis()) {
case RIGHT:
drive.moveInches(Direction.RIGHT, 8, 0.7);
break;
case MIDDLE:
drive.moveInches(Direction.LEFT, 7, 0.7);
break;
case LEFT:
default:
drive.moveInches(Direction.LEFT, 28, 0.7);
}

intakeMechanism.drop();
drive.moveInches(Direction.FORWARD, 25, 1);
}

public void initialize() {
Expand All @@ -103,11 +64,5 @@ public void initialize() {
vuforia = new VuforiaNavigation(CustomizedRobotParameters.VUFORIA_PARAMETERS);

drive = new MecanumEncoderDrive(hardwareMap, this, CustomizedRobotParameters.ROBOT_PARAMETERS);

lifter = new TapeMeasureLifter(hardwareMap, this);

intakeMechanism = new IntakeMechanism(hardwareMap, this);

intakeMechanism.drop();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.pattonvillerobotics.commoncode.robotclasses.opencv.roverruckus.minerals.MineralDetector;
import org.pattonvillerobotics.commoncode.robotclasses.vuforia.VuforiaNavigation;
import org.pattonvillerobotics.robotclasses.CustomizedRobotParameters;
import org.pattonvillerobotics.robotclasses.TapeMeasureLifter;

@Autonomous(name="Depot Autonomous", group = "Competition")
public class DepotAutonomous extends LinearOpMode {
Expand All @@ -20,42 +21,61 @@ public class DepotAutonomous extends LinearOpMode {
private MineralDetector mineralDetector;
private VuforiaNavigation vuforia;

private TapeMeasureLifter lifter;

@Override
public void runOpMode() {
initialize();
waitForStart();

double mineralCompensationDistance;
int mineralCompensationDistance;

// lower the robot
lifter.winchMotor.setPower(0.5);

drive.moveInches(Direction.FORWARD, 8, 0.5);
drive.moveInches(Direction.LEFT, 6, 0.5);
sleep(2300);

// take picture, analyze
lifter.winchMotor.setPower(0.2);

drive.moveInches(Direction.FORWARD,1, 0.5);

sleep(100);

drive.moveInches(Direction.BACKWARD,0.7, 0.4);

drive.moveInches(Direction.LEFT, 4, 0.3);

lifter.winchMotor.setPower(-0.3);

drive.moveInches(Direction.FORWARD, 3, 0.8);

mineralDetector.process(vuforia.getImage());
drive.moveInches(Direction.RIGHT, 8, 0.8);

if(mineralDetector.getAnalysis() == ColorSensorColor.YELLOW) {
//for determining what distance will get the robot to a specific point, depending on which mineral is "chosen"
mineralCompensationDistance = 15;
//drive.moveInches(Direction.RIGHT, 4, 0.5);
} else {
drive.moveInches(Direction.RIGHT, 14, 0.5);
//take picture, analyze
drive.moveInches(Direction.BACKWARD, 4, 0.8);

// take picture, analyze

lifter.winchMotor.setPower(0);
// take picture, analyze

for (int i = 0; i < 7; i++) {
mineralDetector.process(vuforia.getImage());
}

if(mineralDetector.getAnalysis() == ColorSensorColor.YELLOW) {
//drive.moveInches(Direction.RIGHT, 5, 0.5);
switch (mineralDetector.getHorizontalAnalysis()) {
case RIGHT:
drive.moveInches(Direction.RIGHT, 8, 0.7);
mineralCompensationDistance = 15;
break;
case MIDDLE:
drive.moveInches(Direction.LEFT, 7, 0.7);
mineralCompensationDistance = 0;

} else {
//program failed. Zero stars.
drive.moveInches(Direction.LEFT, 27, 0.5);
break;
case LEFT:
default:
drive.moveInches(Direction.LEFT, 28, 0.7);
mineralCompensationDistance = 30;
}
}

drive.moveInches(Direction.RIGHT, 7, 0.5);
drive.moveInches(Direction.FORWARD, 29, 1);
drive.moveInches(Direction.RIGHT, mineralCompensationDistance, 1);
Expand All @@ -72,5 +92,7 @@ public void initialize() {
vuforia = new VuforiaNavigation(CustomizedRobotParameters.VUFORIA_PARAMETERS);

drive = new MecanumEncoderDrive(hardwareMap, this, CustomizedRobotParameters.ROBOT_PARAMETERS);

lifter = new TapeMeasureLifter(hardwareMap, this);
}
}
Loading

0 comments on commit 689ede4

Please sign in to comment.