diff --git a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/readme.md b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/readme.md index 326978d..1de2104 100644 --- a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/readme.md +++ b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/readme.md @@ -1,45 +1,2 @@ - -## Caution -No Team-specific code should be placed or modified in this ``.../samples`` folder. - -Samples should be Copied from here, and then Pasted into the team's -[/TeamCode/src/main/java/org/firstinspires/ftc/teamcode](../../../../../../../../../../TeamCode/src/main/java/org/firstinspires/ftc/teamcode) - folder, using the Android Studio cut and paste commands. This automatically changes all file and -class names to be consistent. From there, the sample can be modified to suit the team's needs. - -For more detailed instructions see the /teamcode readme. - -### Naming of Samples - -To gain a better understanding of how the samples are organized, and how to interpret the -naming system, it will help to understand the conventions that were used during their creation. - -These conventions are described (in detail) in the sample_conventions.md file in this folder. - -To summarize: A range of different samples classes will reside in the java/external/samples. -The class names will follow a naming convention which indicates the purpose of each class. -The prefix of the name will be one of the following: - -Basic: This is a minimally functional OpMode used to illustrate the skeleton/structure - of a particular style of OpMode. These are bare bones examples. - -Sensor: This is a Sample OpMode that shows how to use a specific sensor. - It is not intended to drive a functioning robot, it is simply showing the minimal code - required to read and display the sensor values. - -Robot: This is a Sample OpMode that assumes a simple two-motor (differential) drive base. - It may be used to provide a common baseline driving OpMode, or - to demonstrate how a particular sensor or concept can be used to navigate. - -Concept: This is a sample OpMode that illustrates performing a specific function or concept. - These may be complex, but their operation should be explained clearly in the comments, - or the comments should reference an external doc, guide or tutorial. - Each OpMode should try to only demonstrate a single concept so they are easy to - locate based on their name. These OpModes may not produce a drivable robot. - -After the prefix, other conventions will apply: - -* Sensor class names are constructed as: Sensor - Company - Type -* Robot class names are constructed as: Robot - Mode - Action - OpModetype -* Concept class names are constructed as: Concept - Topic - OpModetype - +# external.samples +> this is where the sdk's default sample projects are held. \ No newline at end of file diff --git a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/sample_conventions.md b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/sample_conventions.md deleted file mode 100644 index 45968ef..0000000 --- a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/sample_conventions.md +++ /dev/null @@ -1,108 +0,0 @@ -## Sample Class/Opmode conventions -#### V 1.1.0 8/9/2017 - -This document defines the FTC Sample OpMode and Class conventions. - -### OpMode Name - -To gain a better understanding of how the samples are organized, and how to interpret the -naming system, it will help to understand the conventions that were used during their creation. - -To summarize: A range of different samples classes will reside in the java/external/samples. -The class names will follow a naming convention which indicates the purpose of each class. -The prefix of the name will be one of the following: - -Basic: This is a minimally functional OpMode used to illustrate the skeleton/structure - of a particular style of OpMode. These are bare bones examples. - -Sensor: This is a Sample OpMode that shows how to use a specific sensor. - It is not intended to drive a functioning robot, it is simply showing the minimal code - required to read and display the sensor values. - -Robot: This is a Sample OpMode that assumes a simple two-motor (differential) drive base. - It may be used to provide a common baseline driving OpMode, or - to demonstrate how a particular sensor or concept can be used to navigate. - -Concept: This is a sample OpMode that illustrates performing a specific function or concept. - These may be complex, but their operation should be explained clearly in the comments, - or the comments should reference an external doc, guide or tutorial. - Each OpMode should try to only demonstrate a single concept so they are easy to - locate based on their name. These OpModes may not produce a drivable robot. - -After the prefix, other conventions will apply: - -* Sensor class names should constructed as: Sensor - Company - Type -* Robot class names should be constructed as: Robot - Mode - Action - OpModetype -* Concept class names should be constructed as: Concept - Topic - OpModetype - -### Sample OpMode Content/Style - -Code is formatted as per the Google Style Guide: - -https://google.github.io/styleguide/javaguide.html - -With “Sensor” and “Hardware” samples, the code should demonstrate the essential function, -and not be embellished with too much additional “clever” code. If a sensor has special -addressing needs, or has a variety of modes or outputs, these should be demonstrated as -simply as possible. - -Special programming methods, or robot control techniques should be reserved for “Concept” Samples, -and where possible, Samples should strive to only demonstrate a single concept, -eg: State machine coding, or a User Menu system, and not combine them into a single “all inclusive” -sample. This will prevent an “all inclusive” Sample being deleted just because one part of it -becomes obsolete. - -### Device Configuration Names - -The following device names are used in the external samples - -** Motors: -left_drive -right_drive -left_arm - -** Servos: -left_hand -right_hand -arm -claw - -** Sensors: -sensor_color -sensor_ir -sensor_light -sensor_ods -sensor_range -sensor_touch -sensor_color_distance -sensor_digital -digin -digout - -** Localization: -compass -gyro -imu -navx - -### Device Object Names - -Device Object names should use the same words as the device’s configuration name, but they -should be re-structured to be a suitable Java variable name. This should keep the same word order, -but adopt the style of beginning with a lower case letter, and then each subsequent word -starting with an upper case letter. - -Eg: from the examples above: tool, leftMotor, rightClawServo, rearLightSensor. - -Note: Sometimes it’s helpful to put the device type first, followed by the variant. -eg: motorLeft and motorRight, but this should only be done if the same word order -is used on the device configuration name. - -### OpMode code Comments - -Sample comments should read like normal code comments, that is, as an explanation of what the -sample code is doing. They should NOT be directives to the user, -like: “insert your joystick code here” as these comments typically aren’t -detailed enough to be useful. They also often get left in the code and become garbage. - -Instead, an example of the joystick code should be shown with a comment describing what it is doing. diff --git a/FtcRobotController/src/main/res/drawable-xhdpi/icon_robotcontroller.png b/FtcRobotController/src/main/res/drawable-xhdpi/icon_robotcontroller.png index 022552f..70c6638 100644 Binary files a/FtcRobotController/src/main/res/drawable-xhdpi/icon_robotcontroller.png and b/FtcRobotController/src/main/res/drawable-xhdpi/icon_robotcontroller.png differ diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/RedBoardSide.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/RedBoardSide.java deleted file mode 100644 index 8b93b2c..0000000 --- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/RedBoardSide.java +++ /dev/null @@ -1,45 +0,0 @@ -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() { - - } - -} \ No newline at end of file diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/BlueBoardSide.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/autonomous/BlueBoardSide.java similarity index 61% rename from TeamCode/src/main/java/org/firstinspires/ftc/teamcode/BlueBoardSide.java rename to TeamCode/src/main/java/org/firstinspires/ftc/teamcode/autonomous/BlueBoardSide.java index b55a155..310a931 100644 --- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/BlueBoardSide.java +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/autonomous/BlueBoardSide.java @@ -1,11 +1,14 @@ -package org.firstinspires.ftc.teamcode; +package org.firstinspires.ftc.teamcode.autonomous; import static org.firstinspires.ftc.teamcode.operations.inputs.AprilTag.initAprilTag; import static org.firstinspires.ftc.teamcode.operations.inputs.Camera.visionPortal; +import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.ConfigureMotors.bl; import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.ConfigureMotors.br; +import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.ConfigureMotors.fl; import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.ConfigureMotors.forwardMotors; +import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.ConfigureMotors.fr; import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.ConfigureMotors.mapMotors; -import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.DistanceMovements.forward; +import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.hardcoredMovements.EachMotorSet.drive; import com.qualcomm.robotcore.eventloop.opmode.Autonomous; import com.qualcomm.robotcore.hardware.DcMotor; @@ -14,7 +17,7 @@ import org.firstinspires.ftc.teamcode.operations.Wheels; import org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.Encoders; -@Autonomous(name="Blue, Board Side") +@Autonomous(name="Blue, Board Side", group="auto") public class BlueBoardSide extends TargetOperations { DcMotor arm; @@ -47,7 +50,19 @@ public void runInitLoop(){} @Override public void runStart() { - forward(300, 1); + // must set up methods for this later + Encoders.clear(); + Encoders.target(-5000,-5000,-5000,-5000); // - must be to go forward + Encoders.go(); + drive(-500,-500,-500,-500); + sleep(500); // wait this makes sure that the robot does not strafe when it should not + // ^ forward away from wall + + // strafe left into backstage + Encoders.clear(); + Encoders.target(1800,-1800,-1800,1800); // - must be to go forward + Encoders.go(); + drive(500,-500,-500,500); } @Override @@ -57,7 +72,10 @@ public void runStop() { @Override public void runLoop() { - telemetry.addData("position", br.getCurrentPosition()); + telemetry.addData("position FL ", fl.getCurrentPosition()); + telemetry.addData("position FR ", fr.getCurrentPosition()); + telemetry.addData("position BL ", bl.getCurrentPosition()); + telemetry.addData("position BR ", br.getCurrentPosition()); telemetry.update(); } } diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/BlueFarSide.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/autonomous/BlueFarSide.java similarity index 87% rename from TeamCode/src/main/java/org/firstinspires/ftc/teamcode/BlueFarSide.java rename to TeamCode/src/main/java/org/firstinspires/ftc/teamcode/autonomous/BlueFarSide.java index 5e6a879..814a7fc 100644 --- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/BlueFarSide.java +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/autonomous/BlueFarSide.java @@ -1,10 +1,10 @@ -package org.firstinspires.ftc.teamcode; +package org.firstinspires.ftc.teamcode.autonomous; import com.qualcomm.robotcore.eventloop.opmode.Autonomous; import org.firstinspires.ftc.teamcode.operations.TargetOperations; -@Autonomous(name="Blue, Far Side") +@Autonomous(name="Blue, Far Side", group="auto") public class BlueFarSide extends TargetOperations { @Override diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/autonomous/RedBoardSide.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/autonomous/RedBoardSide.java new file mode 100644 index 0000000..77ddeaa --- /dev/null +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/autonomous/RedBoardSide.java @@ -0,0 +1,76 @@ +package org.firstinspires.ftc.teamcode.autonomous; + +import static org.firstinspires.ftc.teamcode.operations.inputs.AprilTag.initAprilTag; +import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.ConfigureMotors.bl; +import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.ConfigureMotors.br; +import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.ConfigureMotors.fl; +import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.ConfigureMotors.forwardMotors; +import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.ConfigureMotors.fr; +import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.ConfigureMotors.mapMotors; +import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.hardcoredMovements.EachMotorSet.drive; + +import com.qualcomm.robotcore.eventloop.opmode.Autonomous; + +import org.firstinspires.ftc.teamcode.operations.TargetOperations; +import org.firstinspires.ftc.teamcode.operations.Wheels; +import org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.Encoders; + +@Autonomous(name="Red, Board Side", group="auto") +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() { + //arm = hardwareMap.dcMotor.get("arm"); + mapMotors(hardwareMap, Wheels.FRONT_LEFT.abbreviation(),Wheels.FRONT_RIGHT.abbreviation(),Wheels.BACK_LEFT.abbreviation(),Wheels.BACK_RIGHT.abbreviation()); + forwardMotors(true,false,true,false); + // ^ set motor directions + initAprilTag(hardwareMap, "Webcam 1"); + Encoders.clear(); + + } + + @Override + public void runInitLoop() { + + } + + @Override + public void runStart() { + // must set up methods for this later + Encoders.clear(); + Encoders.target(-1000,-1000,-1000,-1000); // - must be to go forward + Encoders.go(); + drive(500,500,500,500); + sleep(500); // wait this makes sure that the robot does not strafe when it should not + + Encoders.clear(); + Encoders.target(-1800,1800,1800,-1800); // - must be to go forward + Encoders.go(); + drive(-500,500,500,-500); + } + + @Override + public void runLoop() { + telemetry.addData("position FL ", fl.getCurrentPosition()); + telemetry.addData("position FR ", fr.getCurrentPosition()); + telemetry.addData("position BL ", bl.getCurrentPosition()); + telemetry.addData("position BR ", br.getCurrentPosition()); + telemetry.update(); + } + + @Override + public void runStop() { + + } + +} \ No newline at end of file diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/RedFarSide.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/autonomous/RedFarSide.java similarity index 87% rename from TeamCode/src/main/java/org/firstinspires/ftc/teamcode/RedFarSide.java rename to TeamCode/src/main/java/org/firstinspires/ftc/teamcode/autonomous/RedFarSide.java index 13ad2f9..67598eb 100644 --- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/RedFarSide.java +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/autonomous/RedFarSide.java @@ -1,10 +1,10 @@ -package org.firstinspires.ftc.teamcode; +package org.firstinspires.ftc.teamcode.autonomous; import com.qualcomm.robotcore.eventloop.opmode.Autonomous; import org.firstinspires.ftc.teamcode.operations.TargetOperations; -@Autonomous(name="Red, Far Side") +@Autonomous(name="Red, Far Side", group="auto") public class RedFarSide extends TargetOperations { @Override diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/autonomous/SeeTeamProp.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/autonomous/SeeTeamProp.java new file mode 100644 index 0000000..8577489 --- /dev/null +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/autonomous/SeeTeamProp.java @@ -0,0 +1,125 @@ +package org.firstinspires.ftc.teamcode.autonomous; + +import static org.firstinspires.ftc.teamcode.operations.inputs.TeamProps.initFlow; +import static org.firstinspires.ftc.teamcode.operations.inputs.TeamProps.propFound; +import static org.firstinspires.ftc.teamcode.operations.inputs.TeamProps.runFlow; +import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.ConfigureMotors.forwardMotors; +import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.ConfigureMotors.mapMotors; +import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.hardcoredMovements.EachMotorSet.drive; + +import com.qualcomm.robotcore.eventloop.opmode.Autonomous; + +import org.firstinspires.ftc.teamcode.operations.TargetOperations; +import org.firstinspires.ftc.teamcode.operations.Wheels; +import org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.Encoders; +import org.firstinspires.ftc.vision.VisionPortal; +import org.firstinspires.ftc.vision.tfod.TfodProcessor; +@Autonomous(name="See Team Prop", group="auto") +public class SeeTeamProp extends TargetOperations { + + /** + * The variable to store our instance of the TensorFlow Object Detection processor. + */ + private TfodProcessor tfod; + + /** + * The variable to store our instance of the vision portal. + */ + private VisionPortal visionPortal; + + private static final String TFOD_MODEL_ASSET = "toborprops.tflite"; + + // Define the labels recognized in the model for TFOD (must be in training order!) + private static final String[] LABELS = { + "blue", + "red", + }; + + @Override + public void runOpMode() { + runInit(); + waitForStart(); + // forward + Encoders.clear(); + Encoders.target(-4000,-4000,-4000,-4000); + Encoders.go(); + drive(-500,-500,-500,-500); + sleep(1200); + + // - is forward, I can change that later + // turn Left so that the robot looks at the team prop on left tape + Encoders.clear(); + Encoders.target(200,-200,200,-200); + Encoders.go(); + drive(500,-500,500,-500); + stop(); + sleep(500); + + + if (opModeIsActive()) { + while (opModeIsActive()) { + + runFlow(gamepad1, telemetry); + + // Share the CPU. + sleep(20); + + if (propFound) { + // turn right + Encoders.clear(); + Encoders.target(-200,200,-200,200); + Encoders.go(); + drive(-500,500,-500,500); + stop(); + sleep(500); + + // back up + Encoders.clear(); + Encoders.target(4000,4000,4000,4000); + Encoders.go(); + drive(500,500,500,500); + sleep(1200); + } + } + } + + // Save more CPU resources when camera is no longer needed. + visionPortal.close(); + + } // end runOpMode() + + @Override + public void runInit() { + //arm = hardwareMap.dcMotor.get("arm"); + mapMotors(hardwareMap, Wheels.FRONT_LEFT.abbreviation(),Wheels.FRONT_RIGHT.abbreviation(),Wheels.BACK_LEFT.abbreviation(),Wheels.BACK_RIGHT.abbreviation()); + forwardMotors(true,false,true,false); + // ^ set motor directions + //initAprilTag(hardwareMap, "Webcam 1"); + initFlow(hardwareMap, "Webcam 1"); + + // Wait for the DS start button to be touched. + telemetry.addData("DS preview on/off", "3 dots, Camera Stream"); + telemetry.addData(">", "Touch Play to start OpMode"); + telemetry.update(); + } + + @Override + public void runInitLoop() { + + } + + @Override + public void runStart() { + + } + + @Override + public void runLoop() { + + } + + @Override + public void runStop() { + + } +} \ No newline at end of file diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/autonomous/readme.md b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/autonomous/readme.md new file mode 100644 index 0000000..f84945c --- /dev/null +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/autonomous/readme.md @@ -0,0 +1,2 @@ +# Autonomous +Here is where the FTC autonomous code is placed \ No newline at end of file diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/operations/inputs/AprilTag.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/operations/inputs/AprilTag.java index 0f1a3a7..cca6202 100644 --- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/operations/inputs/AprilTag.java +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/operations/inputs/AprilTag.java @@ -1,6 +1,6 @@ package org.firstinspires.ftc.teamcode.operations.inputs; -import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.HardcoreMovements.*; +import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.hardcoredMovements.CentricMovements.*; import com.qualcomm.robotcore.hardware.Gamepad; import com.qualcomm.robotcore.hardware.HardwareMap; diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/operations/inputs/TeamProps.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/operations/inputs/TeamProps.java index 4cee383..e51c14d 100644 --- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/operations/inputs/TeamProps.java +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/operations/inputs/TeamProps.java @@ -20,6 +20,7 @@ public class TeamProps { */ public static TfodProcessor tfod; public static String prop; + public static boolean propFound = false; /** * The variable to store our instance of the vision portal. @@ -124,20 +125,11 @@ public static void telemetryFlow(Telemetry telemetry) { telemetry.addData("- Position", "%.0f / %.0f", x, y); telemetry.addData("- Size", "%.0f x %.0f", recognition.getWidth(), recognition.getHeight()); telemetry.addData("", currentRecognitions.lastIndexOf(recognition)); - - if (currentRecognitions.lastIndexOf(recognition) == 1) { - Recognition recognition1 = currentRecognitions.get(0); - Recognition recognition2 = currentRecognitions.get(1); - telemetry.addData("", recognition1.getConfidence()); - telemetry.addData("", recognition2.getConfidence()); - if (recognition1.getConfidence() > recognition2.getConfidence()) { - prop = "recognition 1"; - } - - else { - prop = "recognition 2"; - } + telemetry.addData("-->", recognition.getLabel()); + if (prop == "blue" || prop == "red") { + propFound = true; } + telemetry.addData("", prop); } // end for() loop diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/operations/outputs/motors/drive/DistanceMovements.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/operations/outputs/motors/drive/DistanceMovements.java index 097b1de..6ba827d 100644 --- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/operations/outputs/motors/drive/DistanceMovements.java +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/operations/outputs/motors/drive/DistanceMovements.java @@ -1,6 +1,6 @@ package org.firstinspires.ftc.teamcode.operations.outputs.motors.drive; -import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.HardcoreMovements.drive; +import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.hardcoredMovements.EachMotorSet.driveRaw; public class DistanceMovements { @@ -16,7 +16,7 @@ public static void forward(double inches, double speed) { Encoders.clear(); Encoders.target(tp, tp, tp, tp); Encoders.go(); - drive(speed,speed,speed,speed); + driveRaw(speed,speed,speed,speed); } @@ -27,7 +27,7 @@ public static void right(double inches, double speed) { Encoders.clear(); Encoders.target(tp, tp, tp, tp); Encoders.go(); - drive(speed,speed,speed,speed); + driveRaw(speed,speed,speed,speed); } @@ -38,7 +38,7 @@ public static void turnRight(double degrees, double speed) { Encoders.clear(); Encoders.target(tp, tp, tp, tp); Encoders.go(); - drive(speed,speed,speed,speed); + driveRaw(speed,speed,speed,speed); } diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/operations/outputs/motors/drive/Encoders.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/operations/outputs/motors/drive/Encoders.java index e7802bb..b121845 100644 --- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/operations/outputs/motors/drive/Encoders.java +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/operations/outputs/motors/drive/Encoders.java @@ -1,5 +1,9 @@ package org.firstinspires.ftc.teamcode.operations.outputs.motors.drive; -import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.ConfigureMotors.*; + +import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.ConfigureMotors.bl; +import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.ConfigureMotors.br; +import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.ConfigureMotors.fl; +import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.ConfigureMotors.fr; import com.qualcomm.robotcore.hardware.DcMotor; @@ -10,6 +14,13 @@ public static void target(int frontLeft, int frontRight, int backLeft, int backR bl.setTargetPosition(backLeft); br.setTargetPosition(backRight); } + + public static void targetAll(int position){ + fl.setTargetPosition(position); + fr.setTargetPosition(position); + bl.setTargetPosition(position); + br.setTargetPosition(position); + } public static void go() { fl.setMode(DcMotor.RunMode.RUN_TO_POSITION); fr.setMode(DcMotor.RunMode.RUN_TO_POSITION); diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/operations/outputs/motors/drive/Mecanum.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/operations/outputs/motors/drive/Mecanum.java index c7dc587..cb75964 100644 --- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/operations/outputs/motors/drive/Mecanum.java +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/operations/outputs/motors/drive/Mecanum.java @@ -1,7 +1,7 @@ package org.firstinspires.ftc.teamcode.operations.outputs.motors.drive; import static org.firstinspires.ftc.teamcode.operations.inputs.TargetInputs.imu; -import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.HardcoreMovements.fieldCentric; +import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.hardcoredMovements.CentricMovements.fieldCentric; import com.qualcomm.robotcore.hardware.Gamepad; diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/operations/outputs/motors/drive/HardcoreMovements.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/operations/outputs/motors/drive/hardcoredMovements/CentricMovements.java similarity index 62% rename from TeamCode/src/main/java/org/firstinspires/ftc/teamcode/operations/outputs/motors/drive/HardcoreMovements.java rename to TeamCode/src/main/java/org/firstinspires/ftc/teamcode/operations/outputs/motors/drive/hardcoredMovements/CentricMovements.java index 52f748c..88fa130 100644 --- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/operations/outputs/motors/drive/HardcoreMovements.java +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/operations/outputs/motors/drive/hardcoredMovements/CentricMovements.java @@ -1,39 +1,18 @@ -package org.firstinspires.ftc.teamcode.operations.outputs.motors.drive; +package org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.hardcoredMovements; import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.ConfigureMotors.bl; -import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.ConfigureMotors.br; import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.ConfigureMotors.fl; -import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.ConfigureMotors.fr; -import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.HardcoreMovements.fieldCentric.left; -import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.HardcoreMovements.fieldCentric.right; import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.Mecanum.backLeftPower; import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.Mecanum.backRightPower; import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.Mecanum.fieldCentricMath; import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.Mecanum.frontLeftPower; import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.Mecanum.frontRightPower; import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.Mecanum.waypoints; +import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.hardcoredMovements.EachMotorSet.driveRaw; +import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.hardcoredMovements.CentricMovements.fieldCentric.left; +import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.hardcoredMovements.CentricMovements.fieldCentric.right; -import com.qualcomm.robotcore.hardware.DcMotor; - -public class HardcoreMovements { - - public static void drive(double frontLeftSpeed, double frontRightSpeed, double backLeftSpeed, double backRightSpeed) { - fr.setPower(frontRightSpeed); - fl.setPower(frontLeftSpeed); - br.setPower(backRightSpeed); - bl.setPower(backLeftSpeed); - - } - - - public static void driveStop() { - - drive(0,0,0,0); - fl.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE); - fr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE); - bl.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE); - br.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE); - } +public class CentricMovements { // ^ set all motors to 0, this stops all movements public static void goDirection(boolean left, boolean right, double speed) { @@ -51,24 +30,24 @@ public static class fieldCentric { public static void left(double speed) { waypoints(0, -speed, 0); fieldCentricMath(); - drive(frontLeftPower,backLeftPower,frontRightPower,backRightPower); + driveRaw(frontLeftPower,backLeftPower,frontRightPower,backRightPower); } public static void right(double speed) { waypoints(0, speed, 0); fieldCentricMath(); - drive(frontLeftPower,backLeftPower,frontRightPower,backRightPower); + driveRaw(frontLeftPower,backLeftPower,frontRightPower,backRightPower); } public static void forward(double speed) { waypoints(speed, 0, 0); fieldCentricMath(); - drive(frontLeftPower,backLeftPower,frontRightPower,backRightPower); + driveRaw(frontLeftPower,backLeftPower,frontRightPower,backRightPower); } public static void backward(double speed) { waypoints(-speed, 0, 0); fieldCentricMath(); - drive(frontLeftPower,backLeftPower,frontRightPower,backRightPower); + driveRaw(frontLeftPower,backLeftPower,frontRightPower,backRightPower); } public static void turn(double speed) { diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/operations/outputs/motors/drive/hardcoredMovements/EachMotorSet.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/operations/outputs/motors/drive/hardcoredMovements/EachMotorSet.java new file mode 100644 index 0000000..760e472 --- /dev/null +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/operations/outputs/motors/drive/hardcoredMovements/EachMotorSet.java @@ -0,0 +1,35 @@ +package org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.hardcoredMovements; + +import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.ConfigureMotors.bl; +import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.ConfigureMotors.br; +import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.ConfigureMotors.fl; +import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.ConfigureMotors.fr; + +import com.qualcomm.robotcore.hardware.DcMotorEx; + +public class EachMotorSet { + public static void driveRaw(double frontLeftSpeed, double frontRightSpeed, double backLeftSpeed, double backRightSpeed) { + fr.setPower(frontRightSpeed); + fl.setPower(frontLeftSpeed); + br.setPower(backRightSpeed); + bl.setPower(backLeftSpeed); + + } + + public static void drive(int frontLeftSpeed, int frontRightSpeed, int backLeftSpeed, int backRightSpeed) { + fr.setVelocity(frontRightSpeed); + fl.setVelocity(frontLeftSpeed); + br.setVelocity(backRightSpeed); + bl.setVelocity(backLeftSpeed); + + } + + public static void driveStop() { + + driveRaw(0,0,0,0); + fl.setZeroPowerBehavior(DcMotorEx.ZeroPowerBehavior.BRAKE); + fr.setZeroPowerBehavior(DcMotorEx.ZeroPowerBehavior.BRAKE); + bl.setZeroPowerBehavior(DcMotorEx.ZeroPowerBehavior.BRAKE); + br.setZeroPowerBehavior(DcMotorEx.ZeroPowerBehavior.BRAKE); + } +} diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/operations/outputs/motors/drive/hardcoredMovements/EncoderTickDefinitions.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/operations/outputs/motors/drive/hardcoredMovements/EncoderTickDefinitions.java new file mode 100644 index 0000000..44e523b --- /dev/null +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/operations/outputs/motors/drive/hardcoredMovements/EncoderTickDefinitions.java @@ -0,0 +1,58 @@ +package org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.hardcoredMovements; + +import static android.os.SystemClock.sleep; +import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.hardcoredMovements.EachMotorSet.drive; +import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.hardcoredMovements.TargetHardcoreMovements.encoderSpeed; +import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.hardcoredMovements.TargetHardcoreMovements.strafeTicksPerInch; +import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.hardcoredMovements.TargetHardcoreMovements.ticksPerInch; +import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.hardcoredMovements.TargetHardcoreMovements.turningTicksPerInch; + +import org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.Encoders; + +public class EncoderTickDefinitions { + + public void backward(double inches, long seconds) { + int finalTicks = (int) (inches * ticksPerInch); + Encoders.clear(); + Encoders.target(finalTicks,finalTicks,finalTicks,finalTicks); + Encoders.go(); + drive(encoderSpeed,encoderSpeed,encoderSpeed,encoderSpeed); + sleep(seconds*1000); + } + + public void leftward(double inches, long seconds) { + int finalTicks = (int) (inches * strafeTicksPerInch); + Encoders.clear(); + Encoders.target(finalTicks,-finalTicks,-finalTicks,finalTicks); + Encoders.go(); + drive(encoderSpeed,-encoderSpeed,-encoderSpeed,encoderSpeed); + sleep(seconds*1000); + } + + public void rightward(double inches, long seconds) { + int finalTicks = (int) (inches * strafeTicksPerInch); + Encoders.clear(); + Encoders.target(-finalTicks,finalTicks,finalTicks,-finalTicks); + Encoders.go(); + drive(-encoderSpeed,encoderSpeed,encoderSpeed,-encoderSpeed); + sleep(seconds*1000); + } + + public void turnLeft(double inches, long seconds) { + int finalTicks = (int) (inches * turningTicksPerInch); + Encoders.clear(); + Encoders.target(-finalTicks,finalTicks,-finalTicks,finalTicks); + Encoders.go(); + drive(-encoderSpeed,encoderSpeed,-encoderSpeed,encoderSpeed); + sleep(seconds*1000); + } + + public void turnRight(double inches, long seconds) { + int finalTicks = (int) (inches * turningTicksPerInch); + Encoders.clear(); + Encoders.target(finalTicks,-finalTicks,finalTicks,-finalTicks); + Encoders.go(); + drive(encoderSpeed,-encoderSpeed,encoderSpeed,-encoderSpeed); + sleep(seconds*1000); + } +} diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/operations/outputs/motors/drive/hardcoredMovements/TargetHardcoreMovements.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/operations/outputs/motors/drive/hardcoredMovements/TargetHardcoreMovements.java new file mode 100644 index 0000000..07e2c2a --- /dev/null +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/operations/outputs/motors/drive/hardcoredMovements/TargetHardcoreMovements.java @@ -0,0 +1,8 @@ +package org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.hardcoredMovements; + +public class TargetHardcoreMovements { + public static int ticksPerInch = 1000; // how many ticks per inch + public static int strafeTicksPerInch = 1000; // how many ticks per inch when strafing + public static int turningTicksPerInch = 1000; // how many ticks per inch for turning + public static int encoderSpeed = 500; +} diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/operations/outputs/motors/pixelMotor/PixelMotorMovements.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/operations/outputs/motors/pixelMotor/PixelMotorMovements.java index 5dcd8a4..f2343c1 100644 --- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/operations/outputs/motors/pixelMotor/PixelMotorMovements.java +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/operations/outputs/motors/pixelMotor/PixelMotorMovements.java @@ -9,13 +9,12 @@ public class PixelMotorMovements { public static void motorEncoder () { pixelMotor.setMode(DcMotor.RunMode.RUN_USING_ENCODER); pixelMotor.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER); - pixelMotor.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE); } - public static void rotate (int rotations, int speed) { + public static void rotate (int rotations, int power) { pixelMotor.setTargetPosition(rotations); pixelMotor.setMode(DcMotor.RunMode.RUN_TO_POSITION); - pixelMotor.setPower(speed); + pixelMotor.setPower(power); } } diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/operations/readme.md b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/operations/readme.md index 3d4e273..92f0cf9 100644 --- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/operations/readme.md +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/operations/readme.md @@ -1,55 +1,2 @@ -## HardwareMap -Any class that does not extend LinearOpMode or OpMode must include HardwareMap inside the method, -this way it can be set where the OpMode/LinearOpMode is extended. - -### here is an example: -
-public static void mapMotors (HardwareMap mapHardware, String frontLeftMotor, String frontRightMotor, String backLeftMotor, String backRightMotor){
-        fl = mapHardware.dcMotor.get(frontLeftMotor);
-        fr = mapHardware.dcMotor.get(frontRightMotor);
-        bl = mapHardware.dcMotor.get(backLeftMotor);
-        br = mapHardware.dcMotor.get(backRightMotor);
-    }
-
-This is how hardwareMap can be used, by renaming in within the methods and calling it from the code that extends a class that allows the hardwareMap to be used. - -### here is an example of the method being called: -
-package org.firstinspires.ftc.teamcode;
-
-import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.configureMotors.mapMotors;
-
-import com.qualcomm.robotcore.eventloop.opmode.OpMode;
-
-public class example extends OpMode {
-    @Override
-    public void init() {
-        mapMotors(hardwareMap, "fr","fl","br","bl");
-    }
-
-    @Override
-    public void loop() {
-
-    }
-}
-
-In green is the mapMotors being called out off the example class and being ran inside the init method. This method will send hardwareMap to the mapMotors method and map the motors "fr", "fl", "br", and "bl". - -## Telemetry -The same notation must be acquired for telemetry. If I wanted to call telemetry from a class that has no extensions that connect to the OpMode class than I need to call a value in my meathod that gets the telementry for me, using the Telementry module. - -### here is an example of the method: -
-public static void output(Telemetry display, Object output) {
-        // display to telemetry without a caption
-        display.addData("", output);
-        display.update();
-    }
-
-Again this works just like the HardwareMap module, but with telemetry. In order for telemetry to operate correctly outside of an extention of OpMode it must look for an input of telementry on the other side. -### here is an example of the output method being called: -
-output(telemetry, "Robot Stopped.");
-
-once the output method is called it sends a message to the driver station that the robot has been stopped. -##### There are also other keywords that might need to be called such as Gamepad if your using gamepad1 or gamepad2 outside of an extension of OpMode. \ No newline at end of file +# Operational Layout +> An Operational Layout is laying out the code in a way that all the code is organized in folders and classes according to operation. Within this mode each folder contains a readme.md file along with a Java class with the name 'Target' at the beginning. The 'Target' class is what holds variable information on any other root information. An Operational Layout also includes a TargetSetup at in the operations folder, this is an interface for when running operations. \ No newline at end of file diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/refrence/autonomous/DriveByDistanceConcept.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/refrence/autonomous/DriveByDistanceConcept.java new file mode 100644 index 0000000..90e3462 --- /dev/null +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/refrence/autonomous/DriveByDistanceConcept.java @@ -0,0 +1,20 @@ +package org.firstinspires.ftc.teamcode.refrence.autonomous; + +import com.qualcomm.robotcore.eventloop.opmode.Disabled; + +@Disabled +public class DriveByDistanceConcept { + /* + public void driveForward(double speed, double distance){ + double newPosLeft = encoderLeft.getCurrentPosition() + (distance/cm_per_tick); + ; + while ((opModeIsActive()) && (encoderLeft.getCurrentPosition() < newPosLeft)){ + setPowerAll(speed); + } + setPowerAllZero(); + } + + ^ using a while loop is a way I can tell if the robot's odometers has moved according to what I want + This way I can accurately tell the robot to move a distance without using motor encoders, just odometers + */ +} diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/refrence/Forwardbackward_Autonomous.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/refrence/autonomous/Forwardbackward_Autonomous.java similarity index 97% rename from TeamCode/src/main/java/org/firstinspires/ftc/teamcode/refrence/Forwardbackward_Autonomous.java rename to TeamCode/src/main/java/org/firstinspires/ftc/teamcode/refrence/autonomous/Forwardbackward_Autonomous.java index 8668522..1c3285b 100644 --- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/refrence/Forwardbackward_Autonomous.java +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/refrence/autonomous/Forwardbackward_Autonomous.java @@ -1,4 +1,4 @@ -package org.firstinspires.ftc.teamcode.refrence; +package org.firstinspires.ftc.teamcode.refrence.autonomous; import com.qualcomm.robotcore.eventloop.opmode.Autonomous; import com.qualcomm.robotcore.eventloop.opmode.Disabled; diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/refrence/Gamepad.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/refrence/teleop/Gamepad.java similarity index 98% rename from TeamCode/src/main/java/org/firstinspires/ftc/teamcode/refrence/Gamepad.java rename to TeamCode/src/main/java/org/firstinspires/ftc/teamcode/refrence/teleop/Gamepad.java index d94637d..f8c3372 100644 --- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/refrence/Gamepad.java +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/refrence/teleop/Gamepad.java @@ -29,7 +29,7 @@ are permitted (subject to the limitations in the disclaimer below) provided that OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package org.firstinspires.ftc.teamcode.refrence; +package org.firstinspires.ftc.teamcode.refrence.teleop; import com.qualcomm.robotcore.eventloop.opmode.Disabled; import com.qualcomm.robotcore.eventloop.opmode.OpMode; diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/refrence/Tank.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/refrence/teleop/Tank.java similarity index 94% rename from TeamCode/src/main/java/org/firstinspires/ftc/teamcode/refrence/Tank.java rename to TeamCode/src/main/java/org/firstinspires/ftc/teamcode/refrence/teleop/Tank.java index 417ab1f..e1676fc 100644 --- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/refrence/Tank.java +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/refrence/teleop/Tank.java @@ -1,5 +1,6 @@ -package org.firstinspires.ftc.teamcode.refrence; +package org.firstinspires.ftc.teamcode.refrence.teleop; +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.DcMotor; @@ -7,6 +8,7 @@ @TeleOp /* this program will fall under TeleOp, if it said @Autonomous then it would fall under the autonomous catigory on the drop down screen. */ +@Disabled public class Tank extends OpMode{ /* Declare OpMode members. */ diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/GameCode.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/teleop/GameCode.java similarity index 87% rename from TeamCode/src/main/java/org/firstinspires/ftc/teamcode/GameCode.java rename to TeamCode/src/main/java/org/firstinspires/ftc/teamcode/teleop/GameCode.java index b080eb1..0d63474 100644 --- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/GameCode.java +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/teleop/GameCode.java @@ -1,4 +1,4 @@ -package org.firstinspires.ftc.teamcode; +package org.firstinspires.ftc.teamcode.teleop; import static com.qualcomm.hardware.rev.RevHubOrientationOnRobot.LogoFacingDirection.UP; import static com.qualcomm.hardware.rev.RevHubOrientationOnRobot.UsbFacingDirection.BACKWARD; @@ -8,14 +8,14 @@ import static org.firstinspires.ftc.teamcode.operations.inputs.Imu.imuReset; import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.ConfigureMotors.forwardMotors; import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.ConfigureMotors.mapMotors; -import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.HardcoreMovements.drive; -import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.HardcoreMovements.driveStop; import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.Mecanum.backLeftPower; import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.Mecanum.backRightPower; import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.Mecanum.dpadMovements; import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.Mecanum.fieldCentricMath; import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.Mecanum.frontLeftPower; import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.Mecanum.frontRightPower; +import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.hardcoredMovements.EachMotorSet.driveRaw; +import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.hardcoredMovements.EachMotorSet.driveStop; import com.qualcomm.robotcore.eventloop.opmode.TeleOp; @@ -24,7 +24,6 @@ @TeleOp public class GameCode extends TargetOperations { - double speed = 0.5; // speed used when using hardcore mode @Override @@ -46,6 +45,9 @@ public void runInit() { // ConfigureMotorPixel.mapMotor("pixel"); imuGet(hardwareMap, DeviceNames.DEFAULT_IMU.hardwareMapName(), UP.name(), BACKWARD.name()); initAprilTag(hardwareMap, DeviceNames.DEFAULT_CAMERA.hardwareMapName()); + + // ConfigureMotorPixel.mapMotor(hardwareMap, "pixel"); + // PixelMotorMovements.motorEncoder(); // pixel motor not connected } @Override @@ -69,11 +71,21 @@ public void runLoop() { //runBarMotor(gamepad2.y); // just guesses to how the code might look, this part of the robot has not been built yet. - drive(frontLeftPower,frontRightPower,backLeftPower,backRightPower); + driveRaw(frontLeftPower,frontRightPower,backLeftPower,backRightPower); // sets each motor to the speed given by the waypoints method // odometer will fix issues with the robot not moving directly forward. // ^ this is not a problem for TeleOp, but is a problem in autonomous. + /* if (gamepad2.a) { + + PixelMotorMovements.rotate(100, 1); + } + else { + PixelMotorMovements.rotate(100, 0); + } + + */ + } @Override diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/teleop/readme.md b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/teleop/readme.md new file mode 100644 index 0000000..c82070f --- /dev/null +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/teleop/readme.md @@ -0,0 +1,2 @@ +# TeleOp +Here is where all the FTC TeleOp files are held \ No newline at end of file diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/tests/ColorSensor.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/tests/ColorSensor.java new file mode 100644 index 0000000..7e18288 --- /dev/null +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/tests/ColorSensor.java @@ -0,0 +1,4 @@ +package org.firstinspires.ftc.teamcode.tests; + +public class ColorSensor { +} diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/tests/DistanceSensor.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/tests/DistanceSensor.java new file mode 100644 index 0000000..c97abc8 --- /dev/null +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/tests/DistanceSensor.java @@ -0,0 +1,4 @@ +package org.firstinspires.ftc.teamcode.tests; + +public class DistanceSensor { +} diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/DriveTest.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/tests/DriveTest.java similarity index 52% rename from TeamCode/src/main/java/org/firstinspires/ftc/teamcode/DriveTest.java rename to TeamCode/src/main/java/org/firstinspires/ftc/teamcode/tests/DriveTest.java index f931649..e8a0d54 100644 --- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/DriveTest.java +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/tests/DriveTest.java @@ -1,19 +1,34 @@ -package org.firstinspires.ftc.teamcode; +package org.firstinspires.ftc.teamcode.tests; -import com.qualcomm.robotcore.eventloop.opmode.TeleOp; +import com.qualcomm.robotcore.eventloop.opmode.Autonomous; +import com.qualcomm.robotcore.eventloop.opmode.Disabled; import com.qualcomm.robotcore.hardware.DcMotor; import com.qualcomm.robotcore.hardware.DcMotorSimple; import org.firstinspires.ftc.teamcode.operations.TargetOperations; - -@TeleOp +@Autonomous(name="Drive Test", group="test") +@Disabled // test files are disabled if not in use public class DriveTest extends TargetOperations { + DcMotor frontLeftMotor; DcMotor backLeftMotor; DcMotor frontRightMotor; DcMotor backRightMotor; - double speed = 0.5; // speed used when using hardcore mode + // wants to turn left + // means that right wheels are higher power than other + + // I am using only two motors so that way I can make the 2 motors go the same speeds + // later I can do the last two + // less fr less than 0.254615 + // more fr more than 0.254615 + // if right less the less + // if left more the less + double speed = 1; // speed used when using hardcore mode + double blSpeed = 0; + double brSpeed = 0; + double flSpeed = speed; + double frSpeed = speed; @Override public void runOpMode() { @@ -38,8 +53,6 @@ public void runInit() { // See the note about this earlier on this page. frontLeftMotor.setDirection(DcMotorSimple.Direction.REVERSE); backLeftMotor.setDirection(DcMotorSimple.Direction.REVERSE); - - forward(); } @Override @@ -54,7 +67,7 @@ public void runStart() { @Override public void runLoop() { - + forward(); } @Override @@ -63,30 +76,30 @@ public void runStop() { } public void forward() { - frontLeftMotor.setPower(speed); - backLeftMotor.setPower(speed); - frontRightMotor.setPower(speed); - backRightMotor.setPower(speed); + frontLeftMotor.setPower(flSpeed); + backLeftMotor.setPower(blSpeed); + frontRightMotor.setPower(frSpeed); + backRightMotor.setPower(brSpeed); } public void backward() { - frontLeftMotor.setPower(speed); - backLeftMotor.setPower(speed); - frontRightMotor.setPower(speed); - backRightMotor.setPower(speed); + frontLeftMotor.setPower(-flSpeed); + backLeftMotor.setPower(-blSpeed); + frontRightMotor.setPower(-frSpeed); + backRightMotor.setPower(-brSpeed); } public void leftward() { - frontLeftMotor.setPower(-speed); - backLeftMotor.setPower(speed); - frontRightMotor.setPower(speed); - backRightMotor.setPower(-speed); + frontLeftMotor.setPower(-flSpeed); + backLeftMotor.setPower(blSpeed); + frontRightMotor.setPower(frSpeed); + backRightMotor.setPower(-brSpeed); } public void rightward() { - frontLeftMotor.setPower(speed); - backLeftMotor.setPower(-speed); - frontRightMotor.setPower(-speed); - backRightMotor.setPower(speed); + frontLeftMotor.setPower(flSpeed); + backLeftMotor.setPower(-blSpeed); + frontRightMotor.setPower(-frSpeed); + backRightMotor.setPower(brSpeed); } } diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/tests/EncoderTest.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/tests/EncoderTest.java new file mode 100644 index 0000000..20ef703 --- /dev/null +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/tests/EncoderTest.java @@ -0,0 +1,86 @@ +package org.firstinspires.ftc.teamcode.tests; + +import static org.firstinspires.ftc.teamcode.operations.inputs.AprilTag.initAprilTag; +import static org.firstinspires.ftc.teamcode.operations.inputs.Camera.visionPortal; +import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.ConfigureMotors.bl; +import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.ConfigureMotors.br; +import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.ConfigureMotors.fl; +import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.ConfigureMotors.forwardMotors; +import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.ConfigureMotors.fr; +import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.ConfigureMotors.mapMotors; +import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.hardcoredMovements.EachMotorSet.drive; +import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.hardcoredMovements.TargetHardcoreMovements.encoderSpeed; +import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.hardcoredMovements.TargetHardcoreMovements.ticksPerInch; + +import com.qualcomm.robotcore.eventloop.opmode.Autonomous; + +import org.firstinspires.ftc.teamcode.operations.TargetOperations; +import org.firstinspires.ftc.teamcode.operations.Wheels; +import org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.Encoders; + + +@Autonomous(name="Encoder Test", group="test") +// @Disabled // test files are disabled if not in use +public class EncoderTest 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() { + //arm = hardwareMap.dcMotor.get("arm"); + mapMotors(hardwareMap, Wheels.FRONT_LEFT.abbreviation(),Wheels.FRONT_RIGHT.abbreviation(),Wheels.BACK_LEFT.abbreviation(),Wheels.BACK_RIGHT.abbreviation()); + forwardMotors(true,false,true,false); + // ^ set motor directions + initAprilTag(hardwareMap, "Webcam 1"); + Encoders.use(); + Encoders.clear(); + } + + @Override + public void runInitLoop(){} + + @Override + public void runStart() { + int ticksPer123Inches = 000; // how many ticks = ___ inches + forward(1, 1); + } + + public void forward(double inches, long seconds) { + int finalTicks = (int) (inches * ticksPerInch); + Encoders.clear(); + Encoders.target(-finalTicks,-finalTicks,-finalTicks,-finalTicks); + Encoders.go(); + drive(-encoderSpeed,-encoderSpeed,-encoderSpeed,-encoderSpeed); + sleep(seconds*1000); + } + + // - forward here. + + + + + @Override + public void runStop() { + stopAll(); + } + @Override + public void runLoop() { + + telemetry.addData("position br ", br.getCurrentPosition()); + telemetry.addData("position bl ", bl.getCurrentPosition()); + telemetry.addData("position fr ", fr.getCurrentPosition()); + telemetry.addData("position fl ", fl.getCurrentPosition()); + telemetry.update(); + } +} + diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/TeamProps.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/tests/TeamProps.java similarity index 85% rename from TeamCode/src/main/java/org/firstinspires/ftc/teamcode/TeamProps.java rename to TeamCode/src/main/java/org/firstinspires/ftc/teamcode/tests/TeamProps.java index b7b97f3..dde5d72 100644 --- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/TeamProps.java +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/tests/TeamProps.java @@ -1,14 +1,16 @@ -package org.firstinspires.ftc.teamcode; +package org.firstinspires.ftc.teamcode.tests; -import static org.firstinspires.ftc.teamcode.operations.inputs.TeamProps.*; +import static org.firstinspires.ftc.teamcode.operations.inputs.TeamProps.initFlow; +import static org.firstinspires.ftc.teamcode.operations.inputs.TeamProps.runFlow; import com.qualcomm.robotcore.eventloop.opmode.Autonomous; +import com.qualcomm.robotcore.eventloop.opmode.Disabled; import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode; import org.firstinspires.ftc.vision.VisionPortal; import org.firstinspires.ftc.vision.tfod.TfodProcessor; - -@Autonomous(name="Team props") +@Autonomous(name="Team props", group="test") +@Disabled public class TeamProps extends LinearOpMode { /** diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/tests/readme.md b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/tests/readme.md new file mode 100644 index 0000000..123abb4 --- /dev/null +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/tests/readme.md @@ -0,0 +1,2 @@ +# Testing Codes +This is where Autonomous and TeleOp codes are placed for tests, these codes are not what is going to be ran in autonomous or TeleOp \ No newline at end of file diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/wifi_connect.md b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/wifi_connect.md new file mode 100644 index 0000000..946babc --- /dev/null +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/wifi_connect.md @@ -0,0 +1,2 @@ +# Wi-Fi Connect With Control Hub +> To connect the control hub to android studio using Wi-Fi use ADB Wi-Fi. Double Click on shift and click the green connect button in the ADB Wi-Fi window. \ No newline at end of file