forked from FIRST-Tech-Challenge/FtcRobotController
-
Notifications
You must be signed in to change notification settings - Fork 0
14 move drivetrain into subsystem #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
f7fea78
Created the UserDrive command and the Drivetrain subsystem.
ngarnsworthy bdf07c2
Run formatting command
ngarnsworthy 74f7f2e
Fix the lack of a requirement for UserDrive command
ngarnsworthy 3495d62
I can't copy code over very well
ngarnsworthy abcd4f3
Add documentation
ngarnsworthy 2afae90
Add backup op mode
ngarnsworthy 52377ba
Move contents to contents class
ngarnsworthy fffb274
Merge branch 'master' into 14-move-drivetrain-into-subsystem
naterbots a939bea
Apply suggestion from @Copilot
ngarnsworthy 608c83d
Apply suggestion from @Copilot
ngarnsworthy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
TeamCode/src/main/java/org/firstinspires/ftc/teamcode/Constants.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| 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; | ||
| } | ||
| } |
42 changes: 42 additions & 0 deletions
42
TeamCode/src/main/java/org/firstinspires/ftc/teamcode/OpModes/BackupOpMode.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| 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.Constants; | ||
| 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, | ||
| Constants.Drivetrain.flMotorName, | ||
| Constants.Drivetrain.frMotorName, | ||
| Constants.Drivetrain.blMotorName, | ||
| 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)); | ||
| } | ||
| } | ||
ngarnsworthy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
41 changes: 41 additions & 0 deletions
41
TeamCode/src/main/java/org/firstinspires/ftc/teamcode/OpModes/PrimaryOpMode.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| 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.Constants; | ||
| 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 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, | ||
| Constants.Drivetrain.flMotorName, | ||
| Constants.Drivetrain.frMotorName, | ||
| Constants.Drivetrain.blMotorName, | ||
| 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)); | ||
| } | ||
| } |
6 changes: 4 additions & 2 deletions
6
...pires/ftc/teamcode/BrodysFIRSTOpMode.java → ...e/OpModes/learning/BrodysFIRSTOpMode.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 0 additions & 47 deletions
47
TeamCode/src/main/java/org/firstinspires/ftc/teamcode/PrimaryOpMode.java
This file was deleted.
Oops, something went wrong.
ngarnsworthy marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
TeamCode/src/main/java/org/firstinspires/ftc/teamcode/commands/UserDrive.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| 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; | ||
ngarnsworthy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| addRequirements(drivetrain); | ||
| } | ||
|
|
||
| @Override | ||
| public void execute() { | ||
| drivetrain.move( | ||
| gamepad.getLeftX(), | ||
| gamepad.getLeftY(), | ||
| gamepad.getRightX() | ||
ngarnsworthy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ); | ||
| } | ||
|
|
||
| @Override | ||
| public void end(boolean interrupted) { | ||
| drivetrain.stop(); | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.