Skip to content

Commit

Permalink
Merge pull request FIRST-Tech-Challenge#3 from aashrithbandaru/master
Browse files Browse the repository at this point in the history
Update
  • Loading branch information
Sweekrit-B committed Dec 22, 2020
2 parents 5ae5a82 + ef03d61 commit 49c6c1a
Show file tree
Hide file tree
Showing 9 changed files with 491 additions and 67 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public class ConceptTensorFlowObjectDetectionWebcam extends LinearOpMode {
* and paste it in to your code on the next line, between the double quotes.
*/
private static final String VUFORIA_KEY =
" -- YOUR NEW VUFORIA KEY GOES HERE --- ";
"Acb+W7P/////AAABmQi/NsuJ7kjnr7uhGM4oRFVKne6Cb6AiWhmKA4Z/is1/Ecpi0VRxI+bAtTQDRFT42HMUbTNV7109rlTUAbJknxi51kWI0E2RDAPb2Ohc9NlA+qnhHX7Inwgy0Gft+sI7CX2vt0lbukqyvjt3MkwYKtmnHou/UXRkbjQmpl1g8MM62h6IYaZEL27hCsnEIvGzQEi+PgVVng8hPeomjQ7lJO8BOUgcWQR3RG5iwQor0lbwADBYJm3X/+ZnE+nC9ef4g42IrTZhdnHfIpisC8ZnTYmllB6WOBsOD0u4GyeiRyVPBtU+hlhzRRpsihr6yugms29vpMKDUsPu1czDeBN5U5OJZAalMo5ET1V1IS0PWioD";

/**
* {@link #vuforia} is the variable we will use to store our instance of the Vuforia
Expand Down Expand Up @@ -170,4 +170,4 @@ private void initTfod() {
tfod = ClassFactory.getInstance().createTFObjectDetector(tfodParameters, vuforia);
tfod.loadModelFromAsset(TFOD_MODEL_ASSET, LABEL_FIRST_ELEMENT, LABEL_SECOND_ELEMENT);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,32 @@ public void runOpModeImpl() {
while(true) {
// Gamepad 1 controls:

if (gamepad2.a)
while (gamepad2.a) {
intake.setPower(1);
}
else{
intake.setPower(0);
}

if (gamepad2.x) {
intake.setPower(1);
}

if (gamepad2.y) {
intake.setPower(0);
}



// Left trigger - to move left sideways
strafeRight(-gamepad1.right_trigger, 0);

// Right trigger - to move right sideways
strafeLeft(-gamepad1.left_trigger, 0);

/*shooter.setPower(1);*/

// Left stick y - to go forward or backward
double drive = -gamepad1.left_stick_y;

Expand All @@ -37,31 +57,20 @@ public void runOpModeImpl() {
double leftPower = Range.clip(drive + turn, -1.0, 1.0) ;
double rightPower = Range.clip(drive - turn, -1.0, 1.0) ;

leftFront.setPower(leftPower*2);
leftBack.setPower(leftPower*2);
rightFront.setPower(rightPower*2);
rightBack.setPower(rightPower*2);
leftFront.setPower(leftPower);
leftBack.setPower(leftPower);
rightFront.setPower(rightPower);
rightBack.setPower(rightPower);

// left bumper - to close claw (front servo)

/*
// Gamepad 2 Controls
// Left stick y - to move arm up or down
arm.setPower(-gamepad2.left_stick_y*0.66);
// left bumper - to close claw (front servo)
if (gamepad2.left_bumper) {
//frontServo.setPosition(0.4);
//sleep(100);
frontServo.setPosition(0.4);
telemetry.addData("front servo open", "clawposition: 0.4" );
}
// right bumper - to open claw (front servo)
if (gamepad2.right_bumper) {
frontServo.setPosition(0.0);
telemetry.addData("front servo closed", "clawposition: 0.1" );
}
// a - arm target position
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
package org.firstinspires.ftc.teamcode;

import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
import com.qualcomm.robotcore.util.ElapsedTime;
import com.qualcomm.robotcore.util.Range;

@TeleOp(name="DriverControltest", group="Linear Opmode")
public class DriverControltest extends Movement {
private ElapsedTime runtime = new ElapsedTime();


@Override
public void runOpModeImpl() {
// TODO Set up frontServo in movement

waitForStart();
runtime.reset();


while(opModeIsActive()) {
while(true) {
// Gamepad 1 controls:

/*
// Left trigger - to move left sideways
strafeRight(-gamepad1.right_trigger, 0);
// Right trigger - to move right sideways
strafeLeft(-gamepad1.left_trigger, 0);
shooter.setPower(1);
// Left stick y - to go forward or backward
double drive = -gamepad1.left_stick_y;
// Right stick x - to turn left or right
double turn = gamepad1.right_stick_x;
double leftPower = Range.clip(drive + turn, -1.0, 1.0) ;
leftFront.setPower(leftPower);
leftBack.setPower(leftPower);
rightFront.setPower(rightPower); */
double leftPower = 1;
double rightPower = -gamepad1.left_stick_y;
rightBack.setPower(rightPower);
/*
// Gamepad 2 Controls
// Left stick y - to move arm up or down
arm.setPower(-gamepad2.left_stick_y*0.66);
// left bumper - to close claw (front servo)
if (gamepad2.left_bumper) {
//frontServo.setPosition(0.4);
//sleep(100);
frontServo.setPosition(0.4);
telemetry.addData("front servo open", "clawposition: 0.4" );
}
// right bumper - to open claw (front servo)
if (gamepad2.right_bumper) {
frontServo.setPosition(0.0);
telemetry.addData("front servo closed", "clawposition: 0.1" );
}
// a - arm target position
// if (gamepad2.a) {
// arm.setTargetPosition(1);
// arm.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
// arm.setPower(0);
// sleep(100);
// }
// x - to move back servo down
if (gamepad2.x) {
leftConstruction.setPosition(0.35);
rightConstruction.setPosition(0.43);
telemetry.addData("back servos down", "servoposition: 0,0" );
}
q
// y - to move back servo up
if (gamepad2.y) {
leftConstruction.setPosition(1);
rightConstruction. setPosition(1);
telemetry.addData("back servos up", "servoposition: 0.95" );
}
*/
telemetry.addData("Status", "Run Time: " + runtime.toString());
telemetry.addData("Motors", "left (%.2f), right (%.2f)", leftPower, rightPower);
telemetry.update();
}
}

}
}
31 changes: 6 additions & 25 deletions TeamCode/src/main/java/org/firstinspires/ftc/teamcode/Forward.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import com.qualcomm.robotcore.util.ElapsedTime;

@Autonomous(name="Forward", group="Linear Opmode")
//Disabled


public class Forward extends Movement {
private ElapsedTime runtime = new ElapsedTime();
Expand All @@ -15,36 +15,17 @@ public class Forward extends Movement {
waitForStart();
runtime.reset();

sleep(50);

goForward(1, 20);
/*sense*/
goForward(1, 20);

strafeRight(0.5, 500);

//drive backward
goBackward(0.5, 1800);



//stop motors
stopWithSleep("motors stopped",300);

//drive forward
goForward(0.5,2250);



//stop motors
stopWithSleep("motors stopped",300);

goForward(1,10);


//strafe to the left (maybe park under the bridge)
strafeLeft(1,2250);

telemetry.addData("Status", "Stop Program");
telemetry.update();



}
}
}
113 changes: 113 additions & 0 deletions TeamCode/src/main/java/org/firstinspires/ftc/teamcode/IntakeClass.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
package org.firstinspires.ftc.teamcode;

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

/**
This is an abstract class that handles 4 drive train motors.
*/
abstract class IntakeClass extends LinearOpMode
{

protected DcMotor intake;

public void runOpMode() {
setupDriveMotors();
runOpModeImpl();
}

public abstract void runOpModeImpl();

protected void setupDriveMotors() {
// Initialize the motor references for all the wheels
// Initialize the hardware variables. Note that the strings used here as parameters

updateTelemetryMessage("Initializing Motors");
intake = hardwareMap.get(DcMotor.class, "intake");


// Most robots need the motor on one side to be reve`rsed to drive goBackward
// Reverse the motor that runs backwards when connected directly to the battery

intake.setDirection(DcMotor.Direction.FORWARD);


/* */

updateTelemetryMessage("Initialized Motors");
/*
arm = hardwareMap.get(DcMotor.class, "Arm");
arm.setDirection(DcMotor.Direction.FORWARD);qa
rightConstruction = hardwareMap.servo.get("rightConstruction");
*/
}

public void stop(final String message) {
intake.setPower(0.0);


updateTelemetryMessage(message);
}

public void stopWithSleep(final String message, final long duration) {
stop(message);
sleep(duration);
}

public void stopWithSleep(final long duration) {
stop("Stopping");
sleep(duration);
}



protected void updateTelemetryMessage(String message) {
updateTelemetryMessage("Status", message);
}

protected void updateTelemetryMessage(String caption, String message) {
telemetry.addData("Status", message);
telemetry.update();
}



public void intake(final double intakepower, final int duration){
intake.setPower(intakepower);
sleep(duration);
}



/*
public void armUp(final double armpower, final int duration) {
arm.setPower(armpower);
sleep(duration);
updateTelemetryMessage("Arm going up");
}
public void armDown(final double armpower, final int duration) {
armUp(-armpower, duration);
}
public void backServosDown() {
rightConstruction.setPosition(0.43);
leftConstruction.setPosition(0.35);
updateTelemetryMessage("Foundation Servos Down");
}
public void backServosUp() {
rightConstruction.setPosition(1);
leftConstruction.setPosition(1);
updateTelemetryMessage("Foundation Servos Up");
}
*/
}
Loading

0 comments on commit 49c6c1a

Please sign in to comment.