From 900853343fc7ab93cc62496b0f5c45cb4607bc94 Mon Sep 17 00:00:00 2001 From: MarissaKoglesby <156854363+MarissaKoglesby@users.noreply.github.com> Date: Tue, 23 Jan 2024 16:22:15 -0600 Subject: [PATCH 1/5] Javadoc RobotContainer --- src/main/java/frc/robot/RobotContainer.java | 52 ++++++++++++++++++++- 1 file changed, 50 insertions(+), 2 deletions(-) diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index a8c689dc..072bedcf 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -20,6 +20,9 @@ import frc.robot.commands.EnterXMode; import frc.robot.subsystems.Drive; +/** + * Singleton class that contains all the robot's subsystems, commands, and button bindings. + */ public class RobotContainer { /* @@ -32,6 +35,9 @@ public class RobotContainer { * injecting a dependency through six or seven commands in a chain of command groups would be * awful. */ + /** + * Singleton instance of {@link Drive} + */ public static Drive drive = new Drive(); /* @@ -54,9 +60,15 @@ public class RobotContainer { /* The CommandXboxController instance must be static to allow the getter methods for its axes * to work. */ + /** + * Xbox controller for the driver. + */ public static CommandXboxController driverController = new CommandXboxController(Constants.Controllers.DRIVER_CONTROLLER_PORT); + /** + * Constructor for {@link RobotContainer} + */ public RobotContainer() { configureBindings(); @@ -69,43 +81,79 @@ private void configureBindings() { driverController.x().onTrue(enterXMode); } + /** + * Gets the current autonomous command. + * @return The current autonomous command. + */ public Command getAutonomousCommand() { return Commands.print("No autonomous command configured"); } - public static double scaleAxis(double axis) { + private static double scaleAxis(double axis) { double deadbanded = MathUtil.applyDeadband(axis, 0.1); return Math.pow(deadbanded, 3); } + /** + * Gets x-axis of left stick of driver controller. + * @return x-axis of left stick of driver controller. + */ public static double getControllerLeftXAxis() { return driverController.getLeftX(); } + /** + * Gets scaled x-axis of left stick of driver controller. + * @return scaled x-axis of left stick of driver controller. + */ public static double getScaledControllerLeftXAxis() { return scaleAxis(getControllerLeftXAxis()); } + /** + * Gets y-axis of left stick of driver controller. + * @return y-axis of left stick of driver controller. + */ public static double getControllerLeftYAxis() { return driverController.getLeftY(); } + /** + * Gets scaled y-axis of left stick of driver controller. + * @return scaled y-axis of left stick of driver controller. + */ public static double getScaledControllerLeftYAxis() { return scaleAxis(getControllerLeftYAxis()); } - + + /** + * Gets x-axis of right stick of driver controller. + * @return x-axis of right stick of driver controller. + */ public static double getControllerRightXAxis() { return driverController.getRightX(); } + /** + * Gets scaled x-axis of right stick of driver controller. + * @return scaled x-axis of right stick of driver controller. + */ public static double getScaledControllerRightXAxis() { return scaleAxis(getControllerRightXAxis()); } + /** + * Gets y-axis of right stick of driver controller. + * @return y-axis of right stick of driver controller. + */ public static double getControllerRightYAxis() { return driverController.getRightY(); } + /** + * Gets scaled y-axis of right stick of driver controller. + * @return scaled y-axis of right stick of driver controller. + */ public static double getScaledControllerRightYAxis() { return scaleAxis(getControllerRightYAxis()); } From f0febd057c4afa6c34a97a4d091804197da8c25c Mon Sep 17 00:00:00 2001 From: MarissaKoglesby <156854363+MarissaKoglesby@users.noreply.github.com> Date: Tue, 23 Jan 2024 16:32:50 -0600 Subject: [PATCH 2/5] Javadoc Constants --- src/main/java/frc/robot/Constants.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java index 2337681c..5928f3c2 100644 --- a/src/main/java/frc/robot/Constants.java +++ b/src/main/java/frc/robot/Constants.java @@ -20,7 +20,15 @@ * constants are needed, to reduce verbosity. */ public final class Constants { + + /** + * Constants that are relating to the controllers. + */ public static class Controllers { + + /** + * Driver station port number for the drive controller. + */ public static final int DRIVER_CONTROLLER_PORT = 0; } } From 7b7b1b6e10f313f36d884237abc101ce98d44c06 Mon Sep 17 00:00:00 2001 From: MarissaKoglesby <156854363+MarissaKoglesby@users.noreply.github.com> Date: Tue, 23 Jan 2024 16:54:43 -0600 Subject: [PATCH 3/5] Javadoc Drive and Spotless --- src/main/java/frc/robot/Constants.java | 8 ++---- src/main/java/frc/robot/RobotContainer.java | 27 ++++++++++--------- src/main/java/frc/robot/subsystems/Drive.java | 21 +++++++++++++++ 3 files changed, 37 insertions(+), 19 deletions(-) diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java index 5928f3c2..2dc63059 100644 --- a/src/main/java/frc/robot/Constants.java +++ b/src/main/java/frc/robot/Constants.java @@ -21,14 +21,10 @@ */ public final class Constants { - /** - * Constants that are relating to the controllers. - */ + /** Constants that are relating to the controllers. */ public static class Controllers { - /** - * Driver station port number for the drive controller. - */ + /** Driver station port number for the drive controller. */ public static final int DRIVER_CONTROLLER_PORT = 0; } } diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index 072bedcf..955b4fa0 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -20,9 +20,7 @@ import frc.robot.commands.EnterXMode; import frc.robot.subsystems.Drive; -/** - * Singleton class that contains all the robot's subsystems, commands, and button bindings. - */ +/** Singleton class that contains all the robot's subsystems, commands, and button bindings. */ public class RobotContainer { /* @@ -35,9 +33,7 @@ public class RobotContainer { * injecting a dependency through six or seven commands in a chain of command groups would be * awful. */ - /** - * Singleton instance of {@link Drive} - */ + /** Singleton instance of {@link Drive} */ public static Drive drive = new Drive(); /* @@ -60,15 +56,11 @@ public class RobotContainer { /* The CommandXboxController instance must be static to allow the getter methods for its axes * to work. */ - /** - * Xbox controller for the driver. - */ + /** Xbox controller for the driver. */ public static CommandXboxController driverController = new CommandXboxController(Constants.Controllers.DRIVER_CONTROLLER_PORT); - /** - * Constructor for {@link RobotContainer} - */ + /** Constructor for {@link RobotContainer} */ public RobotContainer() { configureBindings(); @@ -83,6 +75,7 @@ private void configureBindings() { /** * Gets the current autonomous command. + * * @return The current autonomous command. */ public Command getAutonomousCommand() { @@ -96,6 +89,7 @@ private static double scaleAxis(double axis) { /** * Gets x-axis of left stick of driver controller. + * * @return x-axis of left stick of driver controller. */ public static double getControllerLeftXAxis() { @@ -104,6 +98,7 @@ public static double getControllerLeftXAxis() { /** * Gets scaled x-axis of left stick of driver controller. + * * @return scaled x-axis of left stick of driver controller. */ public static double getScaledControllerLeftXAxis() { @@ -112,6 +107,7 @@ public static double getScaledControllerLeftXAxis() { /** * Gets y-axis of left stick of driver controller. + * * @return y-axis of left stick of driver controller. */ public static double getControllerLeftYAxis() { @@ -120,14 +116,16 @@ public static double getControllerLeftYAxis() { /** * Gets scaled y-axis of left stick of driver controller. + * * @return scaled y-axis of left stick of driver controller. */ public static double getScaledControllerLeftYAxis() { return scaleAxis(getControllerLeftYAxis()); } - + /** * Gets x-axis of right stick of driver controller. + * * @return x-axis of right stick of driver controller. */ public static double getControllerRightXAxis() { @@ -136,6 +134,7 @@ public static double getControllerRightXAxis() { /** * Gets scaled x-axis of right stick of driver controller. + * * @return scaled x-axis of right stick of driver controller. */ public static double getScaledControllerRightXAxis() { @@ -144,6 +143,7 @@ public static double getScaledControllerRightXAxis() { /** * Gets y-axis of right stick of driver controller. + * * @return y-axis of right stick of driver controller. */ public static double getControllerRightYAxis() { @@ -152,6 +152,7 @@ public static double getControllerRightYAxis() { /** * Gets scaled y-axis of right stick of driver controller. + * * @return scaled y-axis of right stick of driver controller. */ public static double getScaledControllerRightYAxis() { diff --git a/src/main/java/frc/robot/subsystems/Drive.java b/src/main/java/frc/robot/subsystems/Drive.java index f1914cb5..89564a91 100644 --- a/src/main/java/frc/robot/subsystems/Drive.java +++ b/src/main/java/frc/robot/subsystems/Drive.java @@ -21,6 +21,7 @@ import swervelib.SwerveDrive; import swervelib.parser.SwerveParser; +/** The subsystem that represents the drivetrain. */ public class Drive extends SubsystemBase { SwerveDrive drive; @@ -40,6 +41,14 @@ public Drive() { drive.setMotorIdleMode(true); } + /** + * Drives the robot in robot-oriented mode. + * + * @param x Robot velocity left to right in m/s. Left is positive. + * @param y Robot velocity forward and backward in m/s. Forward is positive. + * @param z Robot angular velocity around the z-axis in radians per second. Counter-clockwise is + * positive. + */ public void driveRobotOriented(double x, double y, double z) { x = x * getMaximumSpeed(); y = y * getMaximumSpeed(); @@ -49,6 +58,15 @@ public void driveRobotOriented(double x, double y, double z) { drive.drive(translation, z, false, false); } + /** + * Drives the robot in field-oriented mode. + * + * @param x Robot velocity left to right in m/s. Left is positive. Relative to the field. + * @param y Robot velocity forward and backward in m/s. Toward the opposing alliance wall is + * positive. + * @param z Robot angular velocity around the z-axis in radians per second. Counter-clockwise is + * positive. + */ public void driveFieldOriented(double x, double y, double z) { x = x * getMaximumSpeed(); y = y * getMaximumSpeed(); @@ -58,10 +76,12 @@ public void driveFieldOriented(double x, double y, double z) { drive.drive(translation, z, true, false); } + /** Stops all motors in the subsystem. */ public void stop() { drive.drive(new Translation2d(), 0, false, false, new Translation2d()); } + /** Points the wheels toward the inside and stops the wheels from moving in any direction. */ public void enterXMode() { drive.lockPose(); } @@ -74,6 +94,7 @@ private double getMaximumAngularSpeed() { return Math.PI / 2; // TODO: move this to constants } + /** Runs every scheduler run. */ @Override public void periodic() { // This method will be called once per scheduler run From 5025a343896b8c042098eb1ffe11d01eea62ef37 Mon Sep 17 00:00:00 2001 From: MarissaKoglesby <156854363+MarissaKoglesby@users.noreply.github.com> Date: Tue, 23 Jan 2024 17:04:07 -0600 Subject: [PATCH 4/5] Javadoc Commands --- src/main/java/frc/robot/commands/DriveFieldOriented.java | 1 + src/main/java/frc/robot/commands/DriveRobotOriented.java | 1 + src/main/java/frc/robot/commands/EnterXMode.java | 1 + 3 files changed, 3 insertions(+) diff --git a/src/main/java/frc/robot/commands/DriveFieldOriented.java b/src/main/java/frc/robot/commands/DriveFieldOriented.java index ce198e0d..440401c0 100644 --- a/src/main/java/frc/robot/commands/DriveFieldOriented.java +++ b/src/main/java/frc/robot/commands/DriveFieldOriented.java @@ -15,6 +15,7 @@ import frc.robot.RobotContainer; import frc.robot.subsystems.Drive; +/** Drives the robot in field-oriented mode. */ public class DriveFieldOriented extends Command { private final Drive drive; diff --git a/src/main/java/frc/robot/commands/DriveRobotOriented.java b/src/main/java/frc/robot/commands/DriveRobotOriented.java index 82e758e7..166495d3 100644 --- a/src/main/java/frc/robot/commands/DriveRobotOriented.java +++ b/src/main/java/frc/robot/commands/DriveRobotOriented.java @@ -15,6 +15,7 @@ import frc.robot.RobotContainer; import frc.robot.subsystems.Drive; +/** Drives the robot in robot-oriented mode. Default command for {@link Drive} subsystem. */ public class DriveRobotOriented extends Command { private final Drive drive; diff --git a/src/main/java/frc/robot/commands/EnterXMode.java b/src/main/java/frc/robot/commands/EnterXMode.java index 571af348..faa9ceeb 100644 --- a/src/main/java/frc/robot/commands/EnterXMode.java +++ b/src/main/java/frc/robot/commands/EnterXMode.java @@ -15,6 +15,7 @@ import frc.robot.RobotContainer; import frc.robot.subsystems.Drive; +/** Points the wheels toward the inside and stops the wheels from moving in any direction. */ public class EnterXMode extends Command { private Drive drive; From e644f22671a269292c787d4cd4f15b9c6f260d01 Mon Sep 17 00:00:00 2001 From: MarissaKoglesby <156854363+MarissaKoglesby@users.noreply.github.com> Date: Wed, 24 Jan 2024 17:59:16 -0600 Subject: [PATCH 5/5] Warning comments for Main and Robot --- src/main/java/frc/robot/Main.java | 1 + src/main/java/frc/robot/Robot.java | 1 + 2 files changed, 2 insertions(+) diff --git a/src/main/java/frc/robot/Main.java b/src/main/java/frc/robot/Main.java index eab963e7..6baf2d57 100644 --- a/src/main/java/frc/robot/Main.java +++ b/src/main/java/frc/robot/Main.java @@ -13,6 +13,7 @@ import edu.wpi.first.wpilibj.RobotBase; +/* Probably don't put code here, most likely put it in RobotContainer. */ public final class Main { private Main() {} diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index 302be34a..9bca3731 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -15,6 +15,7 @@ import edu.wpi.first.wpilibj2.command.Command; import edu.wpi.first.wpilibj2.command.CommandScheduler; +/* Don't put code here, most likely put it in RobotContainer. */ public class Robot extends TimedRobot { private Command m_autonomousCommand;