Skip to content

Commit

Permalink
02/05/22
Browse files Browse the repository at this point in the history
Adjusted autonomous code for Pahrump League Meet FIRST-Tech-Challenge#4
  • Loading branch information
Ghostjammer128 committed Feb 9, 2022
1 parent e3f38b9 commit 72a7353
Show file tree
Hide file tree
Showing 18 changed files with 45 additions and 82 deletions.
83 changes: 16 additions & 67 deletions TeamCode/src/main/java/org/firstinspires/ftc/teamcode/bob/Bob.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,99 +3,48 @@
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
import com.qualcomm.robotcore.hardware.CRServo;
import com.qualcomm.robotcore.hardware.DcMotor;
import com.qualcomm.robotcore.hardware.Servo;

@TeleOp
@SuppressWarnings({"unused"})
public class Bob extends OpMode
{
private DcMotor driveRF, driveRB, driveLF, driveLB, liftRight, liftLeft, intakeLeft, intakeRight;
private Servo dropIntake;
private DcMotor driveR, driveL;
private CRServo carousel;

@Override
public void init()
{
driveRF = hardwareMap.get(DcMotor.class, "driveRF");
driveRB = hardwareMap.get(DcMotor.class, "driveRB");
driveLF = hardwareMap.get(DcMotor.class, "driveLF");
driveLB = hardwareMap.get(DcMotor.class, "driveLB");
liftRight = hardwareMap.get(DcMotor.class, "liftRight");
liftLeft = hardwareMap.get(DcMotor.class, "liftLeft");
intakeLeft = hardwareMap.get(DcMotor.class, "intakeLeft");
intakeRight = hardwareMap.get(DcMotor.class, "intakeRight");
dropIntake = hardwareMap.get(Servo.class, "dropIntake");
driveR = hardwareMap.get(DcMotor.class, "driveR");
driveL = hardwareMap.get(DcMotor.class, "driveL");
carousel = hardwareMap.get(CRServo.class, "carousel");

driveRF.setDirection(DcMotor.Direction.FORWARD);
driveRB.setDirection(DcMotor.Direction.FORWARD);
driveLF.setDirection(DcMotor.Direction.REVERSE);
driveLB.setDirection(DcMotor.Direction.REVERSE);
liftRight.setDirection(DcMotor.Direction.FORWARD);
liftLeft.setDirection(DcMotor.Direction.FORWARD);
intakeLeft.setDirection(DcMotor.Direction.FORWARD);
intakeRight.setDirection(DcMotor.Direction.FORWARD);
dropIntake.setDirection(Servo.Direction.FORWARD);
driveR.setDirection(DcMotor.Direction.FORWARD);
driveL.setDirection(DcMotor.Direction.FORWARD);

telemetry.addData("Status", "Initialized");
telemetry.update();
}

public void loop()
{
//power values for drive train
double xPow, yPow, rxPow;
xPow = gamepad1.left_stick_x;
yPow = gamepad1.left_stick_y;
rxPow = gamepad1.right_stick_x;

//power to drive train (mecanum wheel movement)
driveRF.setPower(yPow - xPow - rxPow);
driveRB.setPower(yPow + xPow - rxPow);
driveLF.setPower(yPow + xPow + rxPow);
driveLB.setPower(yPow - xPow + rxPow);
driveL.setPower(-gamepad1.left_stick_y);
driveR.setPower(gamepad1.right_stick_y);

//servo to rotate intake up and down
if(gamepad1.a) //up
if (gamepad1.right_bumper) //clockwise
{
dropIntake.setPosition(0.2);
carousel.setPower(1.0);
}
else if (gamepad1.b) //down
else if (gamepad1.left_bumper) //counter-clockwise
{
dropIntake.setPosition(0.7);
carousel.setPower(-1.0);
}

//power linear slide to raise and lower intake
if (gamepad1.right_trigger > 0) //expand linear slides
{
liftRight.setPower(gamepad1.right_trigger/2);
liftLeft.setPower(gamepad1.right_trigger/2);
}
else if (gamepad1.left_trigger > 0) //contract linear slides
{
liftRight.setPower(-gamepad1.left_trigger/2);
liftLeft.setPower(-gamepad1.left_trigger/2);
}
else //supply no power to motors
{
liftRight.setPower(0.2);
liftRight.setPower(0.2);
}

//power intake mechanism to grab and release cargo
if (gamepad1.right_bumper) //take in cargo
{
intakeLeft.setPower(1.0);
intakeRight.setPower(-1.0);
}
else if (gamepad1.left_bumper) //release cargo
{
intakeLeft.setPower(-1.0);
intakeRight.setPower(1.0);
}
else //supply no power to motor
else //turn off power
{
intakeLeft.setPower(0.0);
intakeRight.setPower(0.0);
carousel.setPower(0.0);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.firstinspires.ftc.teamcode;
package org.firstinspires.ftc.teamcode.camera;

import com.qualcomm.robotcore.eventloop.opmode.Disabled;
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
Expand All @@ -9,7 +9,6 @@
import org.openftc.easyopencv.OpenCvCamera;
import org.openftc.easyopencv.OpenCvCameraFactory;
import org.openftc.easyopencv.OpenCvCameraRotation;
import org.openftc.easyopencv.OpenCvInternalCamera;

@Disabled
@TeleOp
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.firstinspires.ftc.teamcode;
package org.firstinspires.ftc.teamcode.camera;

import org.opencv.core.Mat;
import org.opencv.core.Scalar;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.firstinspires.ftc.teamcode;
package org.firstinspires.ftc.teamcode.camera;

import com.qualcomm.robotcore.eventloop.opmode.Disabled;
import com.qualcomm.robotcore.hardware.HardwareMap;
Expand All @@ -12,7 +12,6 @@
import org.opencv.imgproc.Imgproc;
import org.openftc.easyopencv.OpenCvCamera;
import org.openftc.easyopencv.OpenCvCameraFactory;
import org.openftc.easyopencv.OpenCvCameraRotation;
import org.openftc.easyopencv.OpenCvInternalCamera;
import org.openftc.easyopencv.OpenCvPipeline;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.firstinspires.ftc.teamcode;
package org.firstinspires.ftc.teamcode.camera;

import com.qualcomm.robotcore.eventloop.opmode.Disabled;
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//Meet #1 @ Legacy HS 11/20/2021
package org.firstinspires.ftc.teamcode.legacy;
package org.firstinspires.ftc.teamcode.legacy1;

import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
import com.qualcomm.robotcore.eventloop.opmode.Disabled;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//Meet #1 @ Legacy HS 11/20/2021
package org.firstinspires.ftc.teamcode.legacy;
package org.firstinspires.ftc.teamcode.legacy1;

import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
import com.qualcomm.robotcore.eventloop.opmode.Disabled;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.firstinspires.ftc.teamcode.mojave;
package org.firstinspires.ftc.teamcode.mojave3;

import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
import com.qualcomm.robotcore.eventloop.opmode.Disabled;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.firstinspires.ftc.teamcode.mojave;
package org.firstinspires.ftc.teamcode.mojave3;

import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
import com.qualcomm.robotcore.eventloop.opmode.Disabled;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.firstinspires.ftc.teamcode.mojave;
package org.firstinspires.ftc.teamcode.mojave3;

import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
import com.qualcomm.robotcore.eventloop.opmode.Disabled;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.firstinspires.ftc.teamcode.mojave;
package org.firstinspires.ftc.teamcode.mojave3;

import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
import com.qualcomm.robotcore.eventloop.opmode.Disabled;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.qualcomm.robotcore.hardware.Servo;
import com.qualcomm.robotcore.util.ElapsedTime;

@Disabled
@Autonomous(name = "Shirley Blue Storage Unit BASE")
@SuppressWarnings({"unused"})
public class AUTO_Shirley_Blue1 extends LinearOpMode
Expand Down Expand Up @@ -116,7 +117,7 @@ public void runOpMode() throws InterruptedException
frontDrive.setPower(1.0);
backDrive.setPower(0.5);
runtime.reset();
while(opModeIsActive() && runtime.seconds() < 0.75)//previously 0.6
while(opModeIsActive() && runtime.seconds() < 0.85)//previously 0.6, 0.75
{
telemetry.update();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
import com.qualcomm.robotcore.hardware.Servo;
import com.qualcomm.robotcore.util.ElapsedTime;

@Autonomous(name = "Shirley Blue Warehouse")
@Disabled
@Autonomous(name = "Shirley Blue Warehouse BASE")
@SuppressWarnings({"unused"})
public class AUTO_Shirley_Blue2 extends LinearOpMode
{
Expand All @@ -32,6 +33,10 @@ public void runOpMode() throws InterruptedException
telemetry.addData("Status", "Initialized");
telemetry.update();

//initialize claw
rotateClaw.setPosition(0.75);
claw.setPosition(1.0);

waitForStart();

//turn towards warehouse
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.qualcomm.robotcore.hardware.Servo;
import com.qualcomm.robotcore.util.ElapsedTime;

@Disabled
@Autonomous(name = "Shirley Red Storage Unit BASE")
@SuppressWarnings({"unused"})
public class AUTO_Shirley_Red1 extends LinearOpMode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
import com.qualcomm.robotcore.hardware.Servo;
import com.qualcomm.robotcore.util.ElapsedTime;

@Autonomous(name = "Shirley Red Warehouse")
@Disabled
@Autonomous(name = "Shirley Red Warehouse BASE")
@SuppressWarnings({"unused"})
public class AUTO_Shirley_Red2 extends LinearOpMode
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.firstinspires.ftc.teamcode.shirley;

import com.qualcomm.hardware.rev.RevColorSensorV3;
import com.qualcomm.robotcore.eventloop.opmode.Disabled;
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
import com.qualcomm.robotcore.hardware.CRServo;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.firstinspires.ftc.teamcode.shirley;

import com.qualcomm.hardware.rev.RevColorSensorV3;
import com.qualcomm.robotcore.eventloop.opmode.Disabled;
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
import com.qualcomm.robotcore.hardware.CRServo;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package org.firstinspires.ftc.teamcode.shirley;

public class ShirleyBob
{

}

0 comments on commit 72a7353

Please sign in to comment.