Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
gavinskycastle committed Jan 18, 2025
1 parent 8144a55 commit 5c4b4e1
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 46 deletions.
11 changes: 3 additions & 8 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ public RobotContainer() {

// Configure the trigger bindings
configureBindings();
initSmartDashboard();
}

private void initializeSubSystems() {
Expand Down Expand Up @@ -168,13 +167,9 @@ private void initSysidChooser() {
* joysticks}.
*/
private void configureBindings() {
// // Schedule `ExampleCommand` when `exampleCondition` changes to `true`
// new Trigger(m_exampleSubsystem::exampleCondition)
// .onTrue(new ExampleCommand(m_exampleSubsystem));
//
// // Schedule `exampleMethodCommand` when the Xbox controller's B button is pressed,
// // cancelling on release.
// m_driverController.b().whileTrue(m_exampleSubsystem.exampleMethodCommand());
// Schedule `exampleMethodCommand` when the Xbox controller's B button is pressed,
// cancelling on release.
// m_driverController.b().whileTrue(m_exampleSubsystem.exampleMethodCommand());
m_driverController.leftBumper().whileTrue(new RunCoralOuttake(m_coralOuttake, 0.15)); // outtake
m_driverController
.rightBumper()
Expand Down
5 changes: 1 addition & 4 deletions src/main/java/frc/robot/commands/DriveForward.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,9 @@
import edu.wpi.first.wpilibj2.command.WaitCommand;
import frc.robot.subsystems.CommandSwerveDrivetrain;

// NOTE: Consider using this command inline, rather than writing a subclass. For more
// information, see:
// https://docs.wpilib.org/en/stable/docs/software/commandbased/convenience-features.html
public class DriveForward extends SequentialCommandGroup {
/** Creates a new DriveForward. */
public DriveForward(CommandSwerveDrivetrain swerveDrive) {
public DriveForward(CommandSwerveDrivetrain swerveDrive /* TODO: Add field sim */) {
try {
PathPlannerPath path = PathPlannerPath.fromPathFile("DriveForward");

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/frc/robot/constants/CORALOUTTAKE.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ public class CORALOUTTAKE {
public static final double kI = 0.0;
public static final double kD = 0.0;
public static final double gearRatio = 1.0;
public static final double Inertia = 0.001;
public static final DCMotor Gearbox = DCMotor.getKrakenX60(1);
public static final double inertia = 0.001;
public static final DCMotor gearbox = DCMotor.getKrakenX60(1);
}
2 changes: 2 additions & 0 deletions src/main/java/frc/robot/constants/SWERVE.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import edu.wpi.first.math.geometry.Translation2d;
import edu.wpi.first.math.util.Units;

// TODO: most of these values have been moved to delete or update
public class SWERVE {
public static double kTrackWidth = Units.inchesToMeters(21);
public static final double kWheelBase = Units.inchesToMeters(19);
Expand All @@ -24,6 +25,7 @@ public class SWERVE {
// public static final SwerveDriveKinematics kSwerveKinematics =
// new SwerveDriveKinematics(
// ModuleMap.orderedValues(kModuleTranslations, new Translation2d[0]));

public static final Translation2d kFrontLeftPosition =
new Translation2d(kWheelBase / 2.0, kTrackWidth / 2.0);
public static final Translation2d kFrontRightPosition =
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/frc/robot/constants/USB.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ public final class USB {
public static final int xBoxController = 2;

public static final int testController = 3;
}
}
1 change: 0 additions & 1 deletion src/main/java/frc/robot/subsystems/Controls.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import edu.wpi.first.wpilibj2.command.SubsystemBase;

public class Controls extends SubsystemBase {
private CommandSwerveDrivetrain m_swervedrive;
private static DriverStation.Alliance m_allianceColor = DriverStation.Alliance.Red;

/** Creates a new Controls. */
Expand Down
11 changes: 9 additions & 2 deletions src/main/java/frc/robot/subsystems/CoralOuttake.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import com.ctre.phoenix6.signals.NeutralModeValue;
import com.ctre.phoenix6.sim.TalonFXSimState;
import edu.wpi.first.math.MathUtil;
import edu.wpi.first.math.numbers.N1;
import edu.wpi.first.math.numbers.N2;
import edu.wpi.first.math.system.LinearSystem;
import edu.wpi.first.math.system.plant.LinearSystemId;
import edu.wpi.first.networktables.DoubleSubscriber;
Expand All @@ -29,10 +31,10 @@

public class CoralOuttake extends SubsystemBase {
private boolean m_isOuttaking = false;
private LinearSystem outtakePlant = LinearSystemId.createDCMotorSystem(1, 1);
private LinearSystem<N2, N1, N2> outtakePlant = LinearSystemId.createDCMotorSystem(1, 1);
private final TalonFX outtakeMotor = new TalonFX(CAN.coralOuttakeMotor);
private final DCMotorSim outtakeMotorSim =
new DCMotorSim(outtakePlant, CORALOUTTAKE.Gearbox); // TODO implement sim code
new DCMotorSim(outtakePlant, CORALOUTTAKE.gearbox); // TODO implement sim code
private double m_desiredPercentOutput;
private final DutyCycleOut m_dutyCycleRequest = new DutyCycleOut(0);
private double m_rpmSetpoint;
Expand Down Expand Up @@ -144,4 +146,9 @@ private void updateSmartDashboard() {
SmartDashboard.putNumber("CoralOuttake/DesiredPercentOutput", m_desiredPercentOutput);
SmartDashboard.putNumber("CoralOuttake/rpmSetpoint", m_rpmSetpoint);
}

@Override
public void periodic() {
updateSmartDashboard();
}
}
25 changes: 0 additions & 25 deletions src/main/java/frc/robot/subsystems/Elevator.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import com.ctre.phoenix6.configs.TalonFXConfiguration;
import com.ctre.phoenix6.hardware.TalonFX;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
import frc.robot.utils.CtreUtils;

Expand All @@ -28,30 +27,6 @@ public Elevator() {
CtreUtils.configureTalonFx(elevatormotors[1], configElevator);
}

/**
* Example command factory method.
*
* @return a command
*/
public Command exampleMethodCommand() {
// Inline construction of command goes here.
// Subsystem::RunOnce implicitly requires `this` subsystem.
return runOnce(
() -> {
/* one-time action goes here */
});
}

/**
* An example method querying a boolean state of the subsystem (for example, a digital sensor).
*
* @return value of some boolean subsystem state, such as a digital sensor.
*/
public boolean exampleCondition() {
// Query some boolean state, such as a digital sensor.
return false;
}

@Override
public void periodic() {
// This method will be called once per scheduler run
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/frc/robot/utils/CtreUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@
import com.ctre.phoenix6.configs.TalonFXConfiguration;
import com.ctre.phoenix6.hardware.CANcoder;
import com.ctre.phoenix6.hardware.TalonFX;
import com.ctre.phoenix6.signals.*;
import edu.wpi.first.wpilibj.Alert;
import edu.wpi.first.wpilibj.Alert.AlertType;
import edu.wpi.first.wpilibj.RobotBase;
import edu.wpi.first.wpilibj.Timer;
import frc.robot.constants.CAN;

// import frc.robot.constants.SWERVE;

// TODO: This class is also a mess
public final class CtreUtils {
/**
* Initialize Phoenix Server by creating a dummy device. We do this so that the CANCoders don't
Expand Down

0 comments on commit 5c4b4e1

Please sign in to comment.