Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
535tobor authored Oct 2, 2023
1 parent df6c651 commit 853cbb1
Show file tree
Hide file tree
Showing 16 changed files with 738 additions and 0 deletions.
85 changes: 85 additions & 0 deletions teamcode/BlueBoardSide.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
package org.firstinspires.ftc.teamcode;

import static org.firstinspires.ftc.teamcode.operations.inputs.AprilTag.*;
import static org.firstinspires.ftc.teamcode.operations.outputs.DriverStation.output;
import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.HardcoreMovements.*;
import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.configureMotors.*;

import com.qualcomm.robotcore.eventloop.opmode.Autonomous;

import org.firstinspires.ftc.teamcode.operations.TargetOperations;

@Autonomous(name="Blue, Board Side")
public class BlueBoardSide extends TargetOperations {

@Override
public void runOpMode() throws InterruptedException {
// LinearOpMode that calls a different form of OpMode:
runInit();
while(opModeInInit()){runInitLoop();}
waitForStart();
runStart();
if (isStopRequested()){runStop();} // stop OpMode if the button is pressed
while (opModeIsActive()) {runLoop();}
visionPortal.close(); // close view for camera
}

@Override
public void runInit() {
mapMotors("fr","fl","br","bl");
forwardMotors(false,true,false,true);
// ^ set motor directions
initAprilTag("Camera 1");
}

@Override
public void runInitLoop(){}

@Override
public void runStart() {}
@Override
public void runStop() {
stopAll();
}
@Override
public void runLoop() {

setAprilTagVariables();
// ^ this line puts the april tag number into a variable, along with other april tag infromation
if (gamepad1.a) {
drive(0.5,0.5, 0.25,0.25);
}
else {
driveZeroPower();
}

if (gamepad1.x) {
drive(0.5,-0.5, 0.25,-0.25);
}
else {
driveZeroPower();
}

if (gamepad1.b) {
drive(-0.5,0.5, -0.25,0.25);
}
else {
driveZeroPower();
}
output(tagId);
if (tagId == 1){
output("The First Tag!");
runStop();
}
else if (tagId == 2){
output("The Second Tag!");
runStop();
}
else if (tagId == 3){
output("The Third Tag!");
runStop();
}

}
}

45 changes: 45 additions & 0 deletions teamcode/BlueFarSide.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package org.firstinspires.ftc.teamcode;

import com.qualcomm.robotcore.eventloop.opmode.Autonomous;

import org.firstinspires.ftc.teamcode.operations.TargetOperations;

@Autonomous(name="Blue, Far Side")
public class BlueFarSide extends TargetOperations {

@Override
public void runOpMode() {

runInit();
while(opModeInInit()){runInitLoop();}
waitForStart();
runStart();
if (isStopRequested()){runStop();}
while (opModeIsActive()) {runLoop();}
}

@Override
public void runInit() {

}

@Override
public void runInitLoop() {

}

@Override
public void runStart() {

}

@Override
public void runLoop() {

}

@Override
public void runStop() {

}
}
98 changes: 98 additions & 0 deletions teamcode/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
package org.firstinspires.ftc.teamcode;

import static org.firstinspires.ftc.teamcode.operations.inputs.Imu.*;
import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.configureMotors.*;
import static org.firstinspires.ftc.teamcode.operations.outputs.motors.pixelMotor.ConfigureMotorPixel.pixelMotor;

import com.qualcomm.robotcore.eventloop.opmode.TeleOp;

import org.firstinspires.ftc.robotcore.external.navigation.AngleUnit;
import org.firstinspires.ftc.teamcode.operations.TargetOperations;
import org.firstinspires.ftc.teamcode.operations.outputs.motors.barMotor.BarMotorMovements;

@TeleOp
public class Main extends TargetOperations {

@Override
public void runOpMode() {
runInit();
while(opModeInInit()){runInitLoop();}
waitForStart();
runStart();
if (isStopRequested()){runStop();}
while (opModeIsActive()) {runLoop();}
}

@Override
public void runInit() {
mapMotors("fr","fl","br","bl");
forwardMotors(false,true,false,true);
//ConfigureMotorBar.mapMotor("bar");
//ConfigureMotorPixel.mapMotor("pixel");
imuGet("imu", "LEFT", "UP");
}

@Override
public void runInitLoop() {

}

@Override
public void runStart() {

}

@Override
public void runLoop() {
double y = -gamepad1.left_stick_y; // Remember, Y stick value is reversed
double x = gamepad1.left_stick_x;
double rx = gamepad1.right_stick_x;

// This button choice was made so that it is hard to hit on accident,
// it can be freely changed based on preference.
// The equivalent button is start on Xbox-style controllers.
if (gamepad1.options) {
imu.resetYaw();
}

double botHeading = imu.getRobotYawPitchRollAngles().getYaw(AngleUnit.RADIANS);

// Rotate the movement direction counter to the bot's rotation
double rotX = x * Math.cos(-botHeading) - y * Math.sin(-botHeading);
double rotY = x * Math.sin(-botHeading) + y * Math.cos(-botHeading);

rotX = rotX * 1.1; // Counteract imperfect strafing

// Denominator is the largest motor power (absolute value) or 1
// This ensures all the powers maintain the same ratio,
// but only if at least one is out of the range [-1, 1]
double denominator = Math.max(Math.abs(rotY) + Math.abs(rotX) + Math.abs(rx), 1);
double frontLeftPower = (rotY + rotX + rx) / denominator;
double backLeftPower = (rotY - rotX + rx) / denominator;
double frontRightPower = (rotY - rotX - rx) / denominator;
double backRightPower = (rotY + rotX - rx) / denominator;

if (gamepad2.a) {
pixelMotor.setPower(1); // set speed to pixel motor to pick up pixels
}
else if (gamepad2.y) { // run to position for bar motor
pixelMotor.setPower(0);
BarMotorMovements.rotate(50, 1);

}

fl.setPower(frontLeftPower);
bl.setPower(backLeftPower);
fr.setPower(frontRightPower);
br.setPower(backRightPower);


// speed is still there, more force given to joystick, more power.

}

@Override
public void runStop() {

}
}
45 changes: 45 additions & 0 deletions teamcode/RedBoardSide.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package org.firstinspires.ftc.teamcode;

import com.qualcomm.robotcore.eventloop.opmode.Autonomous;

import org.firstinspires.ftc.teamcode.operations.TargetOperations;

@Autonomous(name="Red, Board Side")
public class RedBoardSide extends TargetOperations {
@Override
public void runOpMode() {

runInit();
while(opModeInInit()){runInitLoop();}
waitForStart();
runStart();
if (isStopRequested()){runStop();}
while (opModeIsActive()) {runLoop();}
}

@Override
public void runInit() {

}

@Override
public void runInitLoop() {

}

@Override
public void runStart() {

}

@Override
public void runLoop() {

}

@Override
public void runStop() {

}

}
46 changes: 46 additions & 0 deletions teamcode/RedFarSide.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package org.firstinspires.ftc.teamcode;

import com.qualcomm.robotcore.eventloop.opmode.Autonomous;

import org.firstinspires.ftc.teamcode.operations.TargetOperations;

@Autonomous(name="Red, Far Side")
public class RedFarSide extends TargetOperations {

@Override
public void runOpMode() {

runInit();
while(opModeInInit()){runInitLoop();}
waitForStart();
runStart();
if (isStopRequested()){runStop();}
while (opModeIsActive()) {runLoop();}
}

@Override
public void runInit() {

}

@Override
public void runInitLoop() {

}

@Override
public void runStart() {

}

@Override
public void runLoop() {

}

@Override
public void runStop() {

}

}
10 changes: 10 additions & 0 deletions teamcode/operations/TargetOperations.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.firstinspires.ftc.teamcode.operations;

import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
public abstract class TargetOperations extends LinearOpMode implements TargetSetup {

public void stopAll() {
requestOpModeStop();
}

}
15 changes: 15 additions & 0 deletions teamcode/operations/TargetSetup.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// public is not needed, because Interface has public by default
package org.firstinspires.ftc.teamcode.operations;

interface TargetSetup {
/*
this interface was made so that
both LinearOpMode and OpMode can be
ran within the same class
*/
void runInit();
void runInitLoop();
void runStart();
void runLoop();
void runStop();
}
Loading

0 comments on commit 853cbb1

Please sign in to comment.