Skip to content

Commit

Permalink
Merge pull request #12 from frc937/initial-formatting
Browse files Browse the repository at this point in the history
Initial formatting
  • Loading branch information
willitcode authored Jan 23, 2024
2 parents 57db2d5 + 6a38911 commit 8ba062a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/main/java/frc/robot/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* constants are needed, to reduce verbosity.
*/
public final class Constants {
public static class OperatorConstants {
public static final int kDriverControllerPort = 0;
public static class Controllers {
public static final int DRIVER_CONTROLLER_PORT = 0;
}
}
34 changes: 21 additions & 13 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.Commands;
import edu.wpi.first.wpilibj2.command.button.CommandXboxController;
import frc.robot.Constants.OperatorConstants;
import frc.robot.commands.DriveFieldOriented;
import frc.robot.commands.DriveRobotOriented;
import frc.robot.commands.EnterXMode;
Expand All @@ -27,26 +26,35 @@ public class RobotContainer {
* * SUBSYSTEMS *
* **************
*/
private final Drive drive = new Drive();

/* We declare all subsystems as public static because we don't dependency inject because
* injecting a dependency through six or seven commands in a chain of command groups would be
* awful.
*/
public static Drive drive = new Drive();

/*
* ************
* * COMMANDS *
* ************
*/

/* 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);

/*
* *****************
* * OTHER OBJECTS *
* *****************
* ***********************
* * OTHER INSTANCE VARS *
* ***********************
*/

public static CommandXboxController m_driverController =
new CommandXboxController(OperatorConstants.kDriverControllerPort);
/* The CommandXboxController instance must be static to allow the getter methods for its axes
* to work.
*/
public static CommandXboxController driverController =
new CommandXboxController(Constants.Controllers.DRIVER_CONTROLLER_PORT);

public RobotContainer() {
configureBindings();
Expand All @@ -55,9 +63,9 @@ public RobotContainer() {
}

private void configureBindings() {
m_driverController.leftStick().toggleOnTrue(driveFieldOriented);
driverController.leftStick().toggleOnTrue(driveFieldOriented);

m_driverController.x().onTrue(enterXMode);
driverController.x().onTrue(enterXMode);
}

public Command getAutonomousCommand() {
Expand All @@ -70,31 +78,31 @@ public static double scaleAxis(double axis) {
}

public static double getControllerLeftXAxis() {
return m_driverController.getLeftX();
return driverController.getLeftX();
}

public static double getScaledControllerLeftXAxis() {
return scaleAxis(getControllerLeftXAxis());
}

public static double getControllerLeftYAxis() {
return m_driverController.getLeftY();
return driverController.getLeftY();
}

public static double getScaledControllerLeftYAxis() {
return scaleAxis(getControllerLeftYAxis());
}

public static double getControllerRightXAxis() {
return m_driverController.getRightX();
return driverController.getRightX();
}

public static double getScaledControllerRightXAxis() {
return scaleAxis(getControllerRightXAxis());
}

public static double getControllerRightYAxis() {
return m_driverController.getRightY();
return driverController.getRightY();
}

public static double getScaledControllerRightYAxis() {
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/frc/robot/subsystems/Drive.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@ public class Drive extends SubsystemBase {

/** Creates a new Drive. */
public Drive() {
/* Try-catch because otherwise the compiler tries to anticipate runtime errors and throws a
* compiletime error for a missing file even though it shouldn't
*/
try {
drive =
new SwerveParser(new File(Filesystem.getDeployDirectory(), "swerve"))
.createSwerveDrive(Units.feetToMeters(14.5));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
/* setting the motors to brake mode */
Expand Down

0 comments on commit 8ba062a

Please sign in to comment.