From a8fa544ce01edd80ba1a67dd4d5ce8ee74661243 Mon Sep 17 00:00:00 2001 From: willitcode <91231142+willitcode@users.noreply.github.com> Date: Tue, 23 Jan 2024 09:34:15 -0600 Subject: [PATCH 1/2] I ate dependency injection --- src/main/java/frc/robot/RobotContainer.java | 6 +++--- src/main/java/frc/robot/commands/DriveFieldOriented.java | 4 ++-- src/main/java/frc/robot/commands/DriveRobotOriented.java | 4 ++-- src/main/java/frc/robot/commands/EnterXMode.java | 5 +++-- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index 6b1d93b1..67d72828 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -40,9 +40,9 @@ public class RobotContainer { */ /* For now, we don't make commands public static, as there isn't really a reason to. */ - private final DriveRobotOriented driveRobotOriented = new DriveRobotOriented(drive); - private final DriveFieldOriented driveFieldOriented = new DriveFieldOriented(drive); - private final EnterXMode enterXMode = new EnterXMode(drive); + private final DriveRobotOriented driveRobotOriented = new DriveRobotOriented(); + private final DriveFieldOriented driveFieldOriented = new DriveFieldOriented(); + private final EnterXMode enterXMode = new EnterXMode(); /* * *********************** diff --git a/src/main/java/frc/robot/commands/DriveFieldOriented.java b/src/main/java/frc/robot/commands/DriveFieldOriented.java index d496024c..5610e757 100644 --- a/src/main/java/frc/robot/commands/DriveFieldOriented.java +++ b/src/main/java/frc/robot/commands/DriveFieldOriented.java @@ -18,8 +18,8 @@ public class DriveFieldOriented extends Command { private final Drive drive; /** Creates a new DriveFieldOriented. */ - public DriveFieldOriented(Drive drive) { - this.drive = drive; + public DriveFieldOriented() { + this.drive = RobotContainer.drive; addRequirements(drive); } diff --git a/src/main/java/frc/robot/commands/DriveRobotOriented.java b/src/main/java/frc/robot/commands/DriveRobotOriented.java index 2e0e89b4..700c9d36 100644 --- a/src/main/java/frc/robot/commands/DriveRobotOriented.java +++ b/src/main/java/frc/robot/commands/DriveRobotOriented.java @@ -18,8 +18,8 @@ public class DriveRobotOriented extends Command { private final Drive drive; /** Creates a new DriveRobotOriented. */ - public DriveRobotOriented(Drive drive) { - this.drive = drive; + public DriveRobotOriented() { + this.drive = RobotContainer.drive; addRequirements(drive); } diff --git a/src/main/java/frc/robot/commands/EnterXMode.java b/src/main/java/frc/robot/commands/EnterXMode.java index 4d035f04..1ca7d9ab 100644 --- a/src/main/java/frc/robot/commands/EnterXMode.java +++ b/src/main/java/frc/robot/commands/EnterXMode.java @@ -11,6 +11,7 @@ package frc.robot.commands; import edu.wpi.first.wpilibj2.command.Command; +import frc.robot.RobotContainer; import frc.robot.subsystems.Drive; public class EnterXMode extends Command { @@ -18,8 +19,8 @@ public class EnterXMode extends Command { private Drive drive; /** Creates a new EnterXMode. */ - public EnterXMode(Drive drive) { - this.drive = drive; + public EnterXMode() { + this.drive = RobotContainer.drive; addRequirements(drive); // Use addRequirements() here to declare subsystem dependencies. } From d72986c2c181144adf6c0a077ad44082dbe662f0 Mon Sep 17 00:00:00 2001 From: willitcode <91231142+willitcode@users.noreply.github.com> Date: Tue, 23 Jan 2024 10:10:49 -0600 Subject: [PATCH 2/2] add a newline after license header yes this is out of scope for this pr but it was bothering me --- build.gradle | 2 +- src/main/java/frc/robot/Constants.java | 1 + src/main/java/frc/robot/Main.java | 1 + src/main/java/frc/robot/Robot.java | 1 + src/main/java/frc/robot/RobotContainer.java | 1 + 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 + src/main/java/frc/robot/subsystems/Drive.java | 1 + 9 files changed, 9 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 675284f1..7a31b87d 100644 --- a/build.gradle +++ b/build.gradle @@ -109,7 +109,7 @@ spotless { } java { - licenseHeader '// Copyright (c) FIRST and other WPILib contributors.\n// Open Source Software; you can modify and/or share it under the terms of\n// the WPILib BSD license file in the root directory of this project.\n\n/*\n * Asimov\'s Laws:\n * The First Law: A robot may not injure a human being or, through inaction, allow a human being to come to harm.\n * The Second Law: A robot must obey the orders given it by human beings except where such orders would conflict with the First Law.\n * The Third Law: A robot must protect its own existence as long as such protection does not conflict with the First or Second Law.\n */' + licenseHeader '// Copyright (c) FIRST and other WPILib contributors.\n// Open Source Software; you can modify and/or share it under the terms of\n// the WPILib BSD license file in the root directory of this project.\n\n/*\n * Asimov\'s Laws:\n * The First Law: A robot may not injure a human being or, through inaction, allow a human being to come to harm.\n * The Second Law: A robot must obey the orders given it by human beings except where such orders would conflict with the First Law.\n * The Third Law: A robot must protect its own existence as long as such protection does not conflict with the First or Second Law.\n */\n\n' removeUnusedImports() formatAnnotations() googleJavaFormat().reflowLongStrings() diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java index 05183a7f..2337681c 100644 --- a/src/main/java/frc/robot/Constants.java +++ b/src/main/java/frc/robot/Constants.java @@ -8,6 +8,7 @@ * The Second Law: A robot must obey the orders given it by human beings except where such orders would conflict with the First Law. * The Third Law: A robot must protect its own existence as long as such protection does not conflict with the First or Second Law. */ + package frc.robot; /** diff --git a/src/main/java/frc/robot/Main.java b/src/main/java/frc/robot/Main.java index 5b5338fc..eab963e7 100644 --- a/src/main/java/frc/robot/Main.java +++ b/src/main/java/frc/robot/Main.java @@ -8,6 +8,7 @@ * The Second Law: A robot must obey the orders given it by human beings except where such orders would conflict with the First Law. * The Third Law: A robot must protect its own existence as long as such protection does not conflict with the First or Second Law. */ + package frc.robot; import edu.wpi.first.wpilibj.RobotBase; diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index 66225b83..302be34a 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -8,6 +8,7 @@ * The Second Law: A robot must obey the orders given it by human beings except where such orders would conflict with the First Law. * The Third Law: A robot must protect its own existence as long as such protection does not conflict with the First or Second Law. */ + package frc.robot; import edu.wpi.first.wpilibj.TimedRobot; diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index 67d72828..a8c689dc 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -8,6 +8,7 @@ * The Second Law: A robot must obey the orders given it by human beings except where such orders would conflict with the First Law. * The Third Law: A robot must protect its own existence as long as such protection does not conflict with the First or Second Law. */ + package frc.robot; import edu.wpi.first.math.MathUtil; diff --git a/src/main/java/frc/robot/commands/DriveFieldOriented.java b/src/main/java/frc/robot/commands/DriveFieldOriented.java index 5610e757..ce198e0d 100644 --- a/src/main/java/frc/robot/commands/DriveFieldOriented.java +++ b/src/main/java/frc/robot/commands/DriveFieldOriented.java @@ -8,6 +8,7 @@ * The Second Law: A robot must obey the orders given it by human beings except where such orders would conflict with the First Law. * The Third Law: A robot must protect its own existence as long as such protection does not conflict with the First or Second Law. */ + package frc.robot.commands; import edu.wpi.first.wpilibj2.command.Command; diff --git a/src/main/java/frc/robot/commands/DriveRobotOriented.java b/src/main/java/frc/robot/commands/DriveRobotOriented.java index 700c9d36..82e758e7 100644 --- a/src/main/java/frc/robot/commands/DriveRobotOriented.java +++ b/src/main/java/frc/robot/commands/DriveRobotOriented.java @@ -8,6 +8,7 @@ * The Second Law: A robot must obey the orders given it by human beings except where such orders would conflict with the First Law. * The Third Law: A robot must protect its own existence as long as such protection does not conflict with the First or Second Law. */ + package frc.robot.commands; import edu.wpi.first.wpilibj2.command.Command; diff --git a/src/main/java/frc/robot/commands/EnterXMode.java b/src/main/java/frc/robot/commands/EnterXMode.java index 1ca7d9ab..571af348 100644 --- a/src/main/java/frc/robot/commands/EnterXMode.java +++ b/src/main/java/frc/robot/commands/EnterXMode.java @@ -8,6 +8,7 @@ * The Second Law: A robot must obey the orders given it by human beings except where such orders would conflict with the First Law. * The Third Law: A robot must protect its own existence as long as such protection does not conflict with the First or Second Law. */ + package frc.robot.commands; import edu.wpi.first.wpilibj2.command.Command; diff --git a/src/main/java/frc/robot/subsystems/Drive.java b/src/main/java/frc/robot/subsystems/Drive.java index 0d88c0dd..f1914cb5 100644 --- a/src/main/java/frc/robot/subsystems/Drive.java +++ b/src/main/java/frc/robot/subsystems/Drive.java @@ -8,6 +8,7 @@ * The Second Law: A robot must obey the orders given it by human beings except where such orders would conflict with the First Law. * The Third Law: A robot must protect its own existence as long as such protection does not conflict with the First or Second Law. */ + package frc.robot.subsystems; import edu.wpi.first.math.geometry.Translation2d;