-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
535tobor
authored
Oct 5, 2023
1 parent
4f6c71f
commit 4c8412b
Showing
18 changed files
with
829 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { | ||
driveStop(); | ||
} | ||
|
||
if (gamepad1.x) { | ||
drive(0.5,-0.5, 0.25,-0.25); | ||
} | ||
else { | ||
driveStop(); | ||
} | ||
|
||
if (gamepad1.b) { | ||
drive(-0.5,0.5, -0.25,0.25); | ||
} | ||
else { | ||
driveStop(); | ||
} | ||
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(); | ||
} | ||
|
||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() { | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
package org.firstinspires.ftc.teamcode; | ||
|
||
import static org.firstinspires.ftc.teamcode.operations.inOut.Gamepad2.*; | ||
import static org.firstinspires.ftc.teamcode.operations.inputs.AprilTag.tagId; | ||
import static org.firstinspires.ftc.teamcode.operations.inputs.Imu.imuGet; | ||
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.Mecanum.*; | ||
import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.configureMotors.*; | ||
|
||
import com.qualcomm.robotcore.eventloop.opmode.TeleOp; | ||
|
||
import org.firstinspires.ftc.teamcode.operations.TargetOperations; | ||
|
||
@TeleOp | ||
public class Main extends TargetOperations { | ||
|
||
double speed = 0.5; // speed used when using hardcore mode | ||
|
||
@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() { | ||
waypoints(-gamepad1.left_stick_y, gamepad1.left_stick_x, gamepad1.right_stick_x); // Remember, Y stick value is reversed | ||
imuReset(gamepad1.options); // resets imu case of accidents or incidences | ||
fieldCentricMath(); // does the required math for Mecanum drive as well as getting imu for field centric | ||
runPixelMotor(gamepad2.a); | ||
runBarMotor(gamepad2.y); | ||
drive(frontLeftPower,backLeftPower,frontRightPower,backRightPower); | ||
|
||
/// Hardcore movements for Mecanum, but no turn: | ||
|
||
if (gamepad1.dpad_left) { | ||
left(speed); | ||
} | ||
|
||
else if (gamepad1.dpad_right) { | ||
right(speed); | ||
} | ||
|
||
else if (gamepad1.dpad_up) { | ||
forward(speed); | ||
} | ||
|
||
else if (gamepad1.dpad_down) { | ||
backward(speed); | ||
} | ||
|
||
else { | ||
driveStop(); | ||
} | ||
|
||
/// | ||
|
||
if (gamepad1.x) { | ||
// go to april tag 1 | ||
if (tagId != 1) { | ||
left(speed); | ||
} | ||
else if (tagId == 1) { | ||
output("tag 1"); | ||
} | ||
} | ||
|
||
} | ||
|
||
@Override | ||
public void runStop() { | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() { | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() { | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package org.firstinspires.ftc.teamcode.operations.inOut; | ||
|
||
import static org.firstinspires.ftc.teamcode.operations.outputs.motors.pixelMotor.ConfigureMotorPixel.pixelMotor; | ||
|
||
import org.firstinspires.ftc.teamcode.operations.outputs.motors.barMotor.BarMotorMovements; | ||
|
||
public class Gamepad2 { | ||
|
||
public static void runPixelMotor(boolean button) { | ||
if (button) { | ||
pixelMotor.setPower(1); | ||
} | ||
else { | ||
pixelMotor.setPower(0); | ||
} | ||
} | ||
|
||
|
||
public static void runBarMotor(boolean button) { | ||
if (button) { | ||
BarMotorMovements.rotate(50,1); | ||
} | ||
} | ||
} |
Oops, something went wrong.