From f7fea788ccb59262ac2f07873b536fe851ba2e65 Mon Sep 17 00:00:00 2001 From: Nick Garnsworthy Date: Wed, 22 Oct 2025 19:49:29 -0500 Subject: [PATCH 1/9] Created the UserDrive command and the Drivetrain subsystem. Added the new subsystem and command. Fixed PrimaryOpMode to be proper type. --- .../ftc/teamcode/PrimaryOpMode.java | 35 ++++++------------- .../ftc/teamcode/commands/UserDrive.java | 30 ++++++++++++++++ .../ftc/teamcode/subsystems/Drivetrain.java | 28 +++++++++++++++ 3 files changed, 68 insertions(+), 25 deletions(-) create mode 100644 TeamCode/src/main/java/org/firstinspires/ftc/teamcode/commands/UserDrive.java create mode 100644 TeamCode/src/main/java/org/firstinspires/ftc/teamcode/subsystems/Drivetrain.java diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/PrimaryOpMode.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/PrimaryOpMode.java index 33347058d842..e91e88b8dcfa 100644 --- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/PrimaryOpMode.java +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/PrimaryOpMode.java @@ -1,47 +1,32 @@ package org.firstinspires.ftc.teamcode; -import com.arcrobotics.ftclib.drivebase.MecanumDrive; +import com.arcrobotics.ftclib.command.CommandOpMode; import com.arcrobotics.ftclib.gamepad.GamepadEx; import com.arcrobotics.ftclib.gamepad.GamepadKeys; -import com.arcrobotics.ftclib.hardware.motors.Motor; -import com.qualcomm.robotcore.eventloop.opmode.OpMode; import com.qualcomm.robotcore.eventloop.opmode.TeleOp; -import com.qualcomm.robotcore.hardware.HardwareMap; import org.firstinspires.ftc.teamcode.commands.RunShooter; +import org.firstinspires.ftc.teamcode.commands.UserDrive; +import org.firstinspires.ftc.teamcode.subsystems.Drivetrain; import org.firstinspires.ftc.teamcode.subsystems.Shooter; @TeleOp(name = "PrimaryOpMode", group= "NormalOpModes") -public class PrimaryOpMode extends OpMode { - private Motor fL, fR, bL, bR; - private MecanumDrive drive; +public class PrimaryOpMode extends CommandOpMode { private Shooter shooter; - private GamepadEx driverOp; + private Drivetrain drivetrain; + private GamepadEx driverOp; private GamepadEx coOp; @Override - public void init() { - fL = new Motor(hardwareMap, "frontLeftDrive"); - fR = new Motor(hardwareMap, "frontRightDrive"); - bL = new Motor(hardwareMap, "backLeftDrive"); - bR = new Motor(hardwareMap, "backRightDrive"); - - drive = new MecanumDrive(fL, fR, bL, bR); + public void initialize() { driverOp = new GamepadEx(gamepad1); coOp = new GamepadEx(gamepad2); - shooter = new Shooter(hardwareMap, "shooterMotor"); + drivetrain = new Drivetrain(hardwareMap, "frontLeftDrive", "frontRightDrive", "backLeftDrive", "backRightDrive"); + drivetrain.setDefaultCommand(new UserDrive(drivetrain, driverOp)); + shooter = new Shooter(hardwareMap, "shooterMotor"); coOp.getGamepadButton(GamepadKeys.Button.A).whileHeld(new RunShooter(shooter, 1)); } - - @Override - public void loop() { - drive.driveRobotCentric( - driverOp.getLeftX(), - driverOp.getLeftY(), - driverOp.getRightX() - ); - } } diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/commands/UserDrive.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/commands/UserDrive.java new file mode 100644 index 000000000000..326c49ed62e2 --- /dev/null +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/commands/UserDrive.java @@ -0,0 +1,30 @@ +package org.firstinspires.ftc.teamcode.commands; + +import com.arcrobotics.ftclib.command.CommandBase; +import com.arcrobotics.ftclib.gamepad.GamepadEx; + +import org.firstinspires.ftc.teamcode.subsystems.Drivetrain; + +public class UserDrive extends CommandBase { + private final Drivetrain drivetrain; + private final GamepadEx gamepad; + + public UserDrive(Drivetrain drivetrain, GamepadEx gamepad){ + this.drivetrain = drivetrain; + this.gamepad = gamepad; + } + + @Override + public void execute() { + drivetrain.move( + gamepad.getLeftX(), + gamepad.getLeftY(), + gamepad.getRightY() + ); + } + + @Override + public void end(boolean interrupted) { + drivetrain.stop(); + } +} diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/subsystems/Drivetrain.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/subsystems/Drivetrain.java new file mode 100644 index 000000000000..684278d7dd92 --- /dev/null +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/subsystems/Drivetrain.java @@ -0,0 +1,28 @@ +package org.firstinspires.ftc.teamcode.subsystems; + +import com.arcrobotics.ftclib.command.SubsystemBase; +import com.arcrobotics.ftclib.drivebase.MecanumDrive; +import com.arcrobotics.ftclib.hardware.motors.Motor; +import com.qualcomm.robotcore.hardware.HardwareMap; + +public class Drivetrain extends SubsystemBase { + private final Motor fL, fR, bL, bR; + private final MecanumDrive drive; + + public Drivetrain(HardwareMap hardwareMap, String flName, String frName, String blName, String brName){ + fL = new Motor(hardwareMap, flName); + fR = new Motor(hardwareMap, frName); + bL = new Motor(hardwareMap, blName); + bR = new Motor(hardwareMap, brName); + + drive = new MecanumDrive(fL, fR, bL, bR); + } + + public void move(double strafe, double forward, double rotate) { + drive.driveRobotCentric(strafe, forward, rotate); + } + + public void stop() { + drive.stop(); + } +} From bdf07c27320db3c1c18663762be8d2b926871b67 Mon Sep 17 00:00:00 2001 From: Nick Garnsworthy Date: Wed, 22 Oct 2025 19:56:13 -0500 Subject: [PATCH 2/9] Run formatting command --- .../ftc/teamcode/NicksFIRSTJavaOpMode.java | 4 +- .../ftc/teamcode/PrimaryOpMode.java | 2 +- .../ftc/teamcode/commands/RunShooter.java | 15 ++-- .../ftc/teamcode/commands/UserDrive.java | 2 +- .../org/firstinspires/ftc/teamcode/readme.md | 79 +++++++++---------- .../ftc/teamcode/subsystems/Drivetrain.java | 2 +- .../ftc/teamcode/subsystems/Shooter.java | 2 +- 7 files changed, 50 insertions(+), 56 deletions(-) diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/NicksFIRSTJavaOpMode.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/NicksFIRSTJavaOpMode.java index 8c087394df20..72f40efef832 100644 --- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/NicksFIRSTJavaOpMode.java +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/NicksFIRSTJavaOpMode.java @@ -5,7 +5,7 @@ import com.qualcomm.robotcore.hardware.DcMotor; import com.qualcomm.robotcore.hardware.DcMotorSimple; -@TeleOp(name="Nick's OpMode", group="Example OpMode") +@TeleOp(name = "Nick's OpMode", group = "Example OpMode") public class NicksFIRSTJavaOpMode extends OpMode { private DcMotor frontLeftMotor; private DcMotor frontRightMotor; @@ -48,7 +48,7 @@ public void loop() { } @Override - public void stop() { + public void stop() { telemetry.addData("Status", "Stopped"); telemetry.update(); } diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/PrimaryOpMode.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/PrimaryOpMode.java index e91e88b8dcfa..e5820c11e57f 100644 --- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/PrimaryOpMode.java +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/PrimaryOpMode.java @@ -10,7 +10,7 @@ import org.firstinspires.ftc.teamcode.subsystems.Drivetrain; import org.firstinspires.ftc.teamcode.subsystems.Shooter; -@TeleOp(name = "PrimaryOpMode", group= "NormalOpModes") +@TeleOp(name = "PrimaryOpMode", group = "NormalOpModes") public class PrimaryOpMode extends CommandOpMode { private Shooter shooter; private Drivetrain drivetrain; diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/commands/RunShooter.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/commands/RunShooter.java index 3bfb61f4fe68..9a23e2ad6868 100644 --- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/commands/RunShooter.java +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/commands/RunShooter.java @@ -5,13 +5,13 @@ import org.firstinspires.ftc.teamcode.subsystems.Shooter; public class RunShooter extends CommandBase { - private Shooter subsystem; - private double speed; + private final Shooter subsystem; + private final double speed; public RunShooter(Shooter _subsystem, double _speed) { - subsystem = _subsystem; - addRequirements(subsystem); - speed = _speed; + subsystem = _subsystem; + addRequirements(subsystem); + speed = _speed; } @Override @@ -19,11 +19,6 @@ public void initialize() { subsystem.run(speed); } - @Override - public boolean isFinished() { - return false; - } - @Override public void end(boolean interrupted) { subsystem.stop(); diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/commands/UserDrive.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/commands/UserDrive.java index 326c49ed62e2..8c875be841f0 100644 --- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/commands/UserDrive.java +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/commands/UserDrive.java @@ -9,7 +9,7 @@ public class UserDrive extends CommandBase { private final Drivetrain drivetrain; private final GamepadEx gamepad; - public UserDrive(Drivetrain drivetrain, GamepadEx gamepad){ + public UserDrive(Drivetrain drivetrain, GamepadEx gamepad) { this.drivetrain = drivetrain; this.gamepad = gamepad; } diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/readme.md b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/readme.md index 4d1da42de0c0..64177c6d372c 100644 --- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/readme.md +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/readme.md @@ -14,7 +14,7 @@ Sample opmodes exist in the FtcRobotController module. To locate these samples, find the FtcRobotController module in the "Project/Android" tab. Expand the following tree elements: - FtcRobotController/java/org.firstinspires.ftc.robotcontroller/external/samples +FtcRobotController/java/org.firstinspires.ftc.robotcontroller/external/samples ### Naming of Samples @@ -27,22 +27,22 @@ To summarize: A range of different samples classes will reside in the java/exter 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. +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. +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. +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. +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: @@ -51,22 +51,22 @@ After the prefix, other conventions will apply: * Concept class names are constructed as: Concept - Topic - OpModetype Once you are familiar with the range of samples available, you can choose one to be the -basis for your own robot. In all cases, the desired sample(s) needs to be copied into +basis for your own robot. In all cases, the desired sample(s) needs to be copied into your TeamCode module to be used. This is done inside Android Studio directly, using the following steps: - 1) Locate the desired sample class in the Project/Android tree. +1) Locate the desired sample class in the Project/Android tree. - 2) Right click on the sample class and select "Copy" +2) Right click on the sample class and select "Copy" - 3) Expand the TeamCode/java folder +3) Expand the TeamCode/java folder - 4) Right click on the org.firstinspires.ftc.teamcode folder and select "Paste" +4) Right click on the org.firstinspires.ftc.teamcode folder and select "Paste" - 5) You will be prompted for a class name for the copy. - Choose something meaningful based on the purpose of this class. - Start with a capital letter, and remember that there may be more similar classes later. +5) You will be prompted for a class name for the copy. + Choose something meaningful based on the purpose of this class. + Start with a capital letter, and remember that there may be more similar classes later. Once your copy has been created, you should prepare it for use on your robot. This is done by adjusting the OpMode's name, and enabling it to be displayed on the @@ -80,16 +80,14 @@ Each OpMode sample class begins with several lines of code like the ones shown b ``` The name that will appear on the driver station's "opmode list" is defined by the code: - ``name="Template: Linear OpMode"`` +``name="Template: Linear OpMode"`` You can change what appears between the quotes to better describe your opmode. The "group=" portion of the code can be used to help organize your list of OpModes. As shown, the current OpMode will NOT appear on the driver station's OpMode list because of the - ``@Disabled`` annotation which has been included. +``@Disabled`` annotation which has been included. This line can simply be deleted , or commented out, to make the OpMode visible. - - ## ADVANCED Multi-Team App management: Cloning the TeamCode Module In some situations, you have multiple teams in your club and you want them to all share @@ -106,26 +104,27 @@ prior to clicking to the green Run arrow. Warning: This is not for the inexperienced Software developer. You will need to be comfortable with File manipulations and managing Android Studio Modules. These changes are performed OUTSIDE of Android Studios, so close Android Studios before you do this. - + Also.. Make a full project backup before you start this :) To clone TeamCode, do the following: -Note: Some names start with "Team" and others start with "team". This is intentional. +Note: Some names start with "Team" and others start with "team". This is intentional. + +1) Using your operating system file management tools, copy the whole "TeamCode" + folder to a sibling folder with a corresponding new name, eg: "Team0417". -1) Using your operating system file management tools, copy the whole "TeamCode" - folder to a sibling folder with a corresponding new name, eg: "Team0417". +2) In the new Team0417 folder, delete the TeamCode.iml file. -2) In the new Team0417 folder, delete the TeamCode.iml file. +3) the new Team0417 folder, rename the "src/main/java/org/firstinspires/ftc/teamcode" folder + to a matching name with a lowercase 'team' eg: "team0417". -3) the new Team0417 folder, rename the "src/main/java/org/firstinspires/ftc/teamcode" folder - to a matching name with a lowercase 'team' eg: "team0417". +4) In the new Team0417/src/main folder, edit the "AndroidManifest.xml" file, change the line that + contains + package="org.firstinspires.ftc.teamcode" + to be + package="org.firstinspires.ftc.team0417" -4) In the new Team0417/src/main folder, edit the "AndroidManifest.xml" file, change the line that contains - package="org.firstinspires.ftc.teamcode" - to be - package="org.firstinspires.ftc.team0417" +5) Add: include ':Team0417' to the "/settings.gradle" file. -5) Add: include ':Team0417' to the "/settings.gradle" file. - -6) Open up Android Studios and clean out any old files by using the menu to "Build/Clean Project"" \ No newline at end of file +6) Open up Android Studios and clean out any old files by using the menu to "Build/Clean Project"" \ No newline at end of file diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/subsystems/Drivetrain.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/subsystems/Drivetrain.java index 684278d7dd92..c717e67e8c50 100644 --- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/subsystems/Drivetrain.java +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/subsystems/Drivetrain.java @@ -9,7 +9,7 @@ public class Drivetrain extends SubsystemBase { private final Motor fL, fR, bL, bR; private final MecanumDrive drive; - public Drivetrain(HardwareMap hardwareMap, String flName, String frName, String blName, String brName){ + public Drivetrain(HardwareMap hardwareMap, String flName, String frName, String blName, String brName) { fL = new Motor(hardwareMap, flName); fR = new Motor(hardwareMap, frName); bL = new Motor(hardwareMap, blName); diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/subsystems/Shooter.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/subsystems/Shooter.java index f3a19e0a88d6..3cceb09fdc6a 100644 --- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/subsystems/Shooter.java +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/subsystems/Shooter.java @@ -5,7 +5,7 @@ import com.qualcomm.robotcore.hardware.HardwareMap; public class Shooter extends SubsystemBase { - private Motor shooterMotor; + private final Motor shooterMotor; public Shooter(HardwareMap map, String motorName) { shooterMotor = new Motor(map, motorName); From 74f7f2e8b14b1543ebbbfeb16f1772918f291b11 Mon Sep 17 00:00:00 2001 From: Nicholas Garnsworthy Date: Wed, 22 Oct 2025 20:05:31 -0500 Subject: [PATCH 3/9] Fix the lack of a requirement for UserDrive command Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .../java/org/firstinspires/ftc/teamcode/commands/UserDrive.java | 1 + 1 file changed, 1 insertion(+) diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/commands/UserDrive.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/commands/UserDrive.java index 8c875be841f0..c4379a4dc17f 100644 --- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/commands/UserDrive.java +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/commands/UserDrive.java @@ -12,6 +12,7 @@ public class UserDrive extends CommandBase { public UserDrive(Drivetrain drivetrain, GamepadEx gamepad) { this.drivetrain = drivetrain; this.gamepad = gamepad; + addRequirements(drivetrain); } @Override From 3495d62c33779168035443fc33f0422df10edc42 Mon Sep 17 00:00:00 2001 From: Nicholas Garnsworthy Date: Wed, 22 Oct 2025 20:08:45 -0500 Subject: [PATCH 4/9] I can't copy code over very well Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .../java/org/firstinspires/ftc/teamcode/commands/UserDrive.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/commands/UserDrive.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/commands/UserDrive.java index c4379a4dc17f..8fe2689a2dc9 100644 --- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/commands/UserDrive.java +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/commands/UserDrive.java @@ -20,7 +20,7 @@ public void execute() { drivetrain.move( gamepad.getLeftX(), gamepad.getLeftY(), - gamepad.getRightY() + gamepad.getRightX() ); } From abcd4f33b093acc42846ad6deb2c14bd9068450e Mon Sep 17 00:00:00 2001 From: Nick Garnsworthy Date: Thu, 23 Oct 2025 07:59:54 -0500 Subject: [PATCH 5/9] Add documentation --- .../teamcode/{ => OpModes}/PrimaryOpMode.java | 2 +- .../learning}/BrodysFIRSTOpMode.java | 6 +- .../learning}/NicksFIRSTJavaOpMode.java | 4 +- .../org/firstinspires/ftc/teamcode/readme.md | 145 ++++-------------- 4 files changed, 38 insertions(+), 119 deletions(-) rename TeamCode/src/main/java/org/firstinspires/ftc/teamcode/{ => OpModes}/PrimaryOpMode.java (96%) rename TeamCode/src/main/java/org/firstinspires/ftc/teamcode/{ => OpModes/learning}/BrodysFIRSTOpMode.java (91%) rename TeamCode/src/main/java/org/firstinspires/ftc/teamcode/{ => OpModes/learning}/NicksFIRSTJavaOpMode.java (93%) diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/PrimaryOpMode.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/OpModes/PrimaryOpMode.java similarity index 96% rename from TeamCode/src/main/java/org/firstinspires/ftc/teamcode/PrimaryOpMode.java rename to TeamCode/src/main/java/org/firstinspires/ftc/teamcode/OpModes/PrimaryOpMode.java index e5820c11e57f..6d54b704e043 100644 --- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/PrimaryOpMode.java +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/OpModes/PrimaryOpMode.java @@ -1,4 +1,4 @@ -package org.firstinspires.ftc.teamcode; +package org.firstinspires.ftc.teamcode.OpModes; import com.arcrobotics.ftclib.command.CommandOpMode; import com.arcrobotics.ftclib.gamepad.GamepadEx; diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/BrodysFIRSTOpMode.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/OpModes/learning/BrodysFIRSTOpMode.java similarity index 91% rename from TeamCode/src/main/java/org/firstinspires/ftc/teamcode/BrodysFIRSTOpMode.java rename to TeamCode/src/main/java/org/firstinspires/ftc/teamcode/OpModes/learning/BrodysFIRSTOpMode.java index e8c62d1ee960..78bf22063050 100644 --- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/BrodysFIRSTOpMode.java +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/OpModes/learning/BrodysFIRSTOpMode.java @@ -1,11 +1,13 @@ -package org.firstinspires.ftc.teamcode; +package org.firstinspires.ftc.teamcode.OpModes.learning; +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; import com.qualcomm.robotcore.hardware.DcMotorSimple; -@TeleOp(name = "Brodys OpMode", group = "Example OpMode") +@TeleOp(name = "Brody's OpMode", group = "Example OpMode") +@Disabled public class BrodysFIRSTOpMode extends OpMode { private DcMotor frontLeftMotor; private DcMotor frontRightMotor; diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/NicksFIRSTJavaOpMode.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/OpModes/learning/NicksFIRSTJavaOpMode.java similarity index 93% rename from TeamCode/src/main/java/org/firstinspires/ftc/teamcode/NicksFIRSTJavaOpMode.java rename to TeamCode/src/main/java/org/firstinspires/ftc/teamcode/OpModes/learning/NicksFIRSTJavaOpMode.java index 72f40efef832..228e64fef023 100644 --- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/NicksFIRSTJavaOpMode.java +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/OpModes/learning/NicksFIRSTJavaOpMode.java @@ -1,11 +1,13 @@ -package org.firstinspires.ftc.teamcode; +package org.firstinspires.ftc.teamcode.OpModes.learning; +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; import com.qualcomm.robotcore.hardware.DcMotorSimple; @TeleOp(name = "Nick's OpMode", group = "Example OpMode") +@Disabled public class NicksFIRSTJavaOpMode extends OpMode { private DcMotor frontLeftMotor; private DcMotor frontRightMotor; diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/readme.md b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/readme.md index 64177c6d372c..0569f5877804 100644 --- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/readme.md +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/readme.md @@ -1,130 +1,45 @@ -## TeamCode Module +All code should use [FTCLib](https://docs.ftclib.org/ftclib/). -Welcome! +# OpModes -This module, TeamCode, is the place where you will write/paste the code for your team's -robot controller App. This module is currently empty (a clean slate) but the -process for adding OpModes is straightforward. +## Example OpModes -## Creating your own OpModes +- Brody's FIRST OpMode +- Nick's FIRST OpMode -The easiest way to create your own OpMode is to copy a Sample OpMode and make it your own. +These OpModes were created for learning purposes and are not intended for use in competition. -Sample opmodes exist in the FtcRobotController module. -To locate these samples, find the FtcRobotController module in the "Project/Android" tab. +## Normal OpModes -Expand the following tree elements: -FtcRobotController/java/org.firstinspires.ftc.robotcontroller/external/samples +- PrimaryOpMode + - Used for normal driving + - Contains all features +- BackupOpMode + - Used for driving if there are issues with the primary + - Only drive and basic subsystem actions -### Naming of Samples +# Subsystems -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. +## Drivetrain -These conventions are described (in detail) in the sample_conventions.md file in this folder. +Subsystem for driving -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: +### Commands -Basic: This is a minimally functional OpMode used to illustrate the skeleton/structure -of a particular style of OpMode. These are bare bones examples. +- UserDrive + - Drives with controls from gamepad + - Stops moving when done + - Controls + - Left Stick + - Y: Forward + - X: Strafe + - Right Stick: X: Turn -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. +## Shooter -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. +Subsystem that runs launcher -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. +### Commands -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 - -Once you are familiar with the range of samples available, you can choose one to be the -basis for your own robot. In all cases, the desired sample(s) needs to be copied into -your TeamCode module to be used. - -This is done inside Android Studio directly, using the following steps: - -1) Locate the desired sample class in the Project/Android tree. - -2) Right click on the sample class and select "Copy" - -3) Expand the TeamCode/java folder - -4) Right click on the org.firstinspires.ftc.teamcode folder and select "Paste" - -5) You will be prompted for a class name for the copy. - Choose something meaningful based on the purpose of this class. - Start with a capital letter, and remember that there may be more similar classes later. - -Once your copy has been created, you should prepare it for use on your robot. -This is done by adjusting the OpMode's name, and enabling it to be displayed on the -Driver Station's OpMode list. - -Each OpMode sample class begins with several lines of code like the ones shown below: - -``` - @TeleOp(name="Template: Linear OpMode", group="Linear Opmode") - @Disabled -``` - -The name that will appear on the driver station's "opmode list" is defined by the code: -``name="Template: Linear OpMode"`` -You can change what appears between the quotes to better describe your opmode. -The "group=" portion of the code can be used to help organize your list of OpModes. - -As shown, the current OpMode will NOT appear on the driver station's OpMode list because of the -``@Disabled`` annotation which has been included. -This line can simply be deleted , or commented out, to make the OpMode visible. - -## ADVANCED Multi-Team App management: Cloning the TeamCode Module - -In some situations, you have multiple teams in your club and you want them to all share -a common code organization, with each being able to *see* the others code but each having -their own team module with their own code that they maintain themselves. - -In this situation, you might wish to clone the TeamCode module, once for each of these teams. -Each of the clones would then appear along side each other in the Android Studio module list, -together with the FtcRobotController module (and the original TeamCode module). - -Selective Team phones can then be programmed by selecting the desired Module from the pulldown list -prior to clicking to the green Run arrow. - -Warning: This is not for the inexperienced Software developer. -You will need to be comfortable with File manipulations and managing Android Studio Modules. -These changes are performed OUTSIDE of Android Studios, so close Android Studios before you do this. - -Also.. Make a full project backup before you start this :) - -To clone TeamCode, do the following: - -Note: Some names start with "Team" and others start with "team". This is intentional. - -1) Using your operating system file management tools, copy the whole "TeamCode" - folder to a sibling folder with a corresponding new name, eg: "Team0417". - -2) In the new Team0417 folder, delete the TeamCode.iml file. - -3) the new Team0417 folder, rename the "src/main/java/org/firstinspires/ftc/teamcode" folder - to a matching name with a lowercase 'team' eg: "team0417". - -4) In the new Team0417/src/main folder, edit the "AndroidManifest.xml" file, change the line that - contains - package="org.firstinspires.ftc.teamcode" - to be - package="org.firstinspires.ftc.team0417" - -5) Add: include ':Team0417' to the "/settings.gradle" file. - -6) Open up Android Studios and clean out any old files by using the menu to "Build/Clean Project"" \ No newline at end of file +- RunShooter + - Runs shooter motors in raw mode with the specified power \ No newline at end of file From 2afae90665d1a92caee87816e7ebe698eaa391bc Mon Sep 17 00:00:00 2001 From: Nick Garnsworthy Date: Thu, 23 Oct 2025 08:02:21 -0500 Subject: [PATCH 6/9] Add backup op mode --- .../ftc/teamcode/OpModes/BackupOpMode.java | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 TeamCode/src/main/java/org/firstinspires/ftc/teamcode/OpModes/BackupOpMode.java diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/OpModes/BackupOpMode.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/OpModes/BackupOpMode.java new file mode 100644 index 000000000000..b5135770f6d8 --- /dev/null +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/OpModes/BackupOpMode.java @@ -0,0 +1,32 @@ +package org.firstinspires.ftc.teamcode.OpModes; + +import com.arcrobotics.ftclib.command.CommandOpMode; +import com.arcrobotics.ftclib.gamepad.GamepadEx; +import com.arcrobotics.ftclib.gamepad.GamepadKeys; +import com.qualcomm.robotcore.eventloop.opmode.TeleOp; + +import org.firstinspires.ftc.teamcode.commands.RunShooter; +import org.firstinspires.ftc.teamcode.commands.UserDrive; +import org.firstinspires.ftc.teamcode.subsystems.Drivetrain; +import org.firstinspires.ftc.teamcode.subsystems.Shooter; + +@TeleOp(name = "BackupOpMode", group = "NormalOpModes") +public class BackupOpMode extends CommandOpMode { + private Shooter shooter; + private Drivetrain drivetrain; + + private GamepadEx driverOp; + private GamepadEx coOp; + + @Override + public void initialize() { + driverOp = new GamepadEx(gamepad1); + coOp = new GamepadEx(gamepad2); + + drivetrain = new Drivetrain(hardwareMap, "frontLeftDrive", "frontRightDrive", "backLeftDrive", "backRightDrive"); + drivetrain.setDefaultCommand(new UserDrive(drivetrain, driverOp)); + + shooter = new Shooter(hardwareMap, "shooterMotor"); + coOp.getGamepadButton(GamepadKeys.Button.A).whileHeld(new RunShooter(shooter, 1)); + } +} \ No newline at end of file From 52377ba2f7dfbb8de26ce2b5444034764b0ee6c5 Mon Sep 17 00:00:00 2001 From: Nick Garnsworthy Date: Thu, 23 Oct 2025 08:34:13 -0500 Subject: [PATCH 7/9] Move contents to contents class --- .../org/firstinspires/ftc/teamcode/Constants.java | 15 +++++++++++++++ .../ftc/teamcode/OpModes/BackupOpMode.java | 14 +++++++++++--- .../ftc/teamcode/OpModes/PrimaryOpMode.java | 14 +++++++++++--- 3 files changed, 37 insertions(+), 6 deletions(-) create mode 100644 TeamCode/src/main/java/org/firstinspires/ftc/teamcode/Constants.java diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/Constants.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/Constants.java new file mode 100644 index 000000000000..894210a19d6a --- /dev/null +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/Constants.java @@ -0,0 +1,15 @@ +package org.firstinspires.ftc.teamcode; + +public final class Constants { + public static class Drivetrain { + public static final String flMotorName = "frontLeftDrive"; + public static final String frMotorName = "frontRightDrive"; + public static final String blMotorName = "backLeftDrive"; + public static final String brMotorName = "backRightDrive"; + } + + public static class Shooter { + public static final String shooterMotorName = "shooterMotor"; + public static final double defaultSpeed = 1; + } +} diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/OpModes/BackupOpMode.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/OpModes/BackupOpMode.java index b5135770f6d8..d18dac1143ee 100644 --- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/OpModes/BackupOpMode.java +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/OpModes/BackupOpMode.java @@ -5,6 +5,7 @@ import com.arcrobotics.ftclib.gamepad.GamepadKeys; import com.qualcomm.robotcore.eventloop.opmode.TeleOp; +import org.firstinspires.ftc.teamcode.Constants; import org.firstinspires.ftc.teamcode.commands.RunShooter; import org.firstinspires.ftc.teamcode.commands.UserDrive; import org.firstinspires.ftc.teamcode.subsystems.Drivetrain; @@ -23,10 +24,17 @@ public void initialize() { driverOp = new GamepadEx(gamepad1); coOp = new GamepadEx(gamepad2); - drivetrain = new Drivetrain(hardwareMap, "frontLeftDrive", "frontRightDrive", "backLeftDrive", "backRightDrive"); + drivetrain = new Drivetrain( + hardwareMap, + Constants.Drivetrain.flMotorName, + Constants.Drivetrain.frMotorName, + Constants.Drivetrain.blMotorName, + Constants.Drivetrain.brMotorName + ); drivetrain.setDefaultCommand(new UserDrive(drivetrain, driverOp)); - shooter = new Shooter(hardwareMap, "shooterMotor"); - coOp.getGamepadButton(GamepadKeys.Button.A).whileHeld(new RunShooter(shooter, 1)); + shooter = new Shooter(hardwareMap, Constants.Shooter.shooterMotorName); + coOp.getGamepadButton(GamepadKeys.Button.A).whileHeld( + new RunShooter(shooter, Constants.Shooter.defaultSpeed)); } } \ No newline at end of file diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/OpModes/PrimaryOpMode.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/OpModes/PrimaryOpMode.java index 6d54b704e043..4cd67290dd9b 100644 --- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/OpModes/PrimaryOpMode.java +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/OpModes/PrimaryOpMode.java @@ -5,6 +5,7 @@ import com.arcrobotics.ftclib.gamepad.GamepadKeys; import com.qualcomm.robotcore.eventloop.opmode.TeleOp; +import org.firstinspires.ftc.teamcode.Constants; import org.firstinspires.ftc.teamcode.commands.RunShooter; import org.firstinspires.ftc.teamcode.commands.UserDrive; import org.firstinspires.ftc.teamcode.subsystems.Drivetrain; @@ -23,10 +24,17 @@ public void initialize() { driverOp = new GamepadEx(gamepad1); coOp = new GamepadEx(gamepad2); - drivetrain = new Drivetrain(hardwareMap, "frontLeftDrive", "frontRightDrive", "backLeftDrive", "backRightDrive"); + drivetrain = new Drivetrain( + hardwareMap, + Constants.Drivetrain.flMotorName, + Constants.Drivetrain.frMotorName, + Constants.Drivetrain.blMotorName, + Constants.Drivetrain.brMotorName + ); drivetrain.setDefaultCommand(new UserDrive(drivetrain, driverOp)); - shooter = new Shooter(hardwareMap, "shooterMotor"); - coOp.getGamepadButton(GamepadKeys.Button.A).whileHeld(new RunShooter(shooter, 1)); + shooter = new Shooter(hardwareMap, Constants.Shooter.shooterMotorName); + coOp.getGamepadButton(GamepadKeys.Button.A).whileHeld( + new RunShooter(shooter, Constants.Shooter.defaultSpeed)); } } From a939bea672651139d4e9b8c93706f5f1a274e0da Mon Sep 17 00:00:00 2001 From: Nicholas Garnsworthy Date: Fri, 24 Oct 2025 11:33:09 -0500 Subject: [PATCH 8/9] Apply suggestion from @Copilot Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .../org/firstinspires/ftc/teamcode/OpModes/PrimaryOpMode.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/OpModes/PrimaryOpMode.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/OpModes/PrimaryOpMode.java index 4cd67290dd9b..c68e02661cbe 100644 --- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/OpModes/PrimaryOpMode.java +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/OpModes/PrimaryOpMode.java @@ -32,8 +32,9 @@ public void initialize() { Constants.Drivetrain.brMotorName ); drivetrain.setDefaultCommand(new UserDrive(drivetrain, driverOp)); - + register(drivetrain); shooter = new Shooter(hardwareMap, Constants.Shooter.shooterMotorName); + register(shooter); coOp.getGamepadButton(GamepadKeys.Button.A).whileHeld( new RunShooter(shooter, Constants.Shooter.defaultSpeed)); } From 608c83d6db8688727f126ef929a2b3c4fa7635d3 Mon Sep 17 00:00:00 2001 From: Nicholas Garnsworthy Date: Fri, 24 Oct 2025 11:33:17 -0500 Subject: [PATCH 9/9] Apply suggestion from @Copilot Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .../org/firstinspires/ftc/teamcode/OpModes/BackupOpMode.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/OpModes/BackupOpMode.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/OpModes/BackupOpMode.java index d18dac1143ee..e2fe16e6671c 100644 --- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/OpModes/BackupOpMode.java +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/OpModes/BackupOpMode.java @@ -32,8 +32,10 @@ public void initialize() { Constants.Drivetrain.brMotorName ); drivetrain.setDefaultCommand(new UserDrive(drivetrain, driverOp)); + register(drivetrain); shooter = new Shooter(hardwareMap, Constants.Shooter.shooterMotorName); + register(shooter); coOp.getGamepadButton(GamepadKeys.Button.A).whileHeld( new RunShooter(shooter, Constants.Shooter.defaultSpeed)); }