Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 33 additions & 30 deletions src/main/java/frc/robot/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,39 @@ public static final class RobotConstants {
public static final Mass TOTAL_MASS = Kilogram.of(107);
public static final MomentOfInertia MOMENT_OF_INERTIA =
KilogramSquareMeters.of(6.883);


public static final class CANIDs {
public static final class Drive {
public static final int IMU = 0;

public static final class FL {
public static final int DRIVE = 10;
public static final int STEER = 11;
public static final int ENCODER = 12;
}

public static final class FR {
public static final int DRIVE = 7;
public static final int STEER = 8;
public static final int ENCODER = 9;
}

public static final class BL {
public static final int DRIVE = 4;
public static final int STEER = 5;
public static final int ENCODER = 6;
}

public static final class BR {
public static final int DRIVE = 1;
public static final int STEER = 2;
public static final int ENCODER = 3;
}
}

public static final int PDH = 13;
}
}

public static final class DriveConstants {
Expand Down Expand Up @@ -216,36 +249,6 @@ public static final class Angle {
}
}
}

public static class CANIDs {
public static final int IMU = 0;

public static class Modules {
public static final class FL {
public static final int DRIVE = 10;
public static final int STEER = 11;
public static final int CANCODER = 12;
}

public static final class FR {
public static final int DRIVE = 7;
public static final int STEER = 8;
public static final int CANCODER = 9;
}

public static final class BL {
public static final int DRIVE = 4;
public static final int STEER = 5;
public static final int CANCODER = 6;
}

public static final class BR {
public static final int DRIVE = 1;
public static final int STEER = 2;
public static final int CANCODER = 3;
}
}
}
}

public static final class LimelightConstants {
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import frc.robot.subsystems.drive.SwerveSubsystem;
import frc.robot.util.AllianceFlipUtil;
import frc.robot.util.Elastic;
import frc.robot.subsystems.util.PDHSubsystem;

/**
* This class is where the bulk of the robot should be declared. Since
Expand Down Expand Up @@ -74,6 +75,9 @@ public class RobotContainer {
public static final SwerveSubsystem swerveDriveSubsystem =
new SwerveSubsystem();

@Logged
public static final PDHSubsystem pdhSubsystem = new PDHSubsystem();

@Logged
public static final DriveCommand normalDrive = new DriveCommand(
swerveDriveSubsystem,
Expand Down
20 changes: 0 additions & 20 deletions src/main/java/frc/robot/commands/util/VoltageStatusCommand.java

This file was deleted.

26 changes: 13 additions & 13 deletions src/main/java/frc/robot/subsystems/drive/SwerveSubsystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -200,18 +200,18 @@ public SwerveSubsystem() {
SwerveModuleConfiguration modules[] = {
new SwerveModuleConfiguration(
new TalonFXSwerve(
DriveConstants.CANIDs.Modules.FL.DRIVE,
RobotConstants.CANIDs.Drive.FL.DRIVE,
true,
DCMotor.getKrakenX60Foc(1)
),
new TalonFXSwerve(
DriveConstants.CANIDs.Modules.FL.STEER,
RobotConstants.CANIDs.Drive.FL.STEER,
false,
DCMotor.getKrakenX44Foc(1)
),
conversionFactors,
new CANCoderSwerve(
DriveConstants.CANIDs.Modules.FL.CANCODER
RobotConstants.CANIDs.Drive.FL.ENCODER
),
DriveConstants.Modules.Offsets.FL.ANGLE.in(Degrees),
DriveConstants.Modules.Offsets.FL.X.in(Meters),
Expand All @@ -227,18 +227,18 @@ public SwerveSubsystem() {
),
new SwerveModuleConfiguration(
new TalonFXSwerve(
DriveConstants.CANIDs.Modules.FR.DRIVE,
RobotConstants.CANIDs.Drive.FR.DRIVE,
true,
DCMotor.getKrakenX60Foc(1)
),
new TalonFXSwerve(
DriveConstants.CANIDs.Modules.FR.STEER,
RobotConstants.CANIDs.Drive.FR.STEER,
false,
DCMotor.getKrakenX44Foc(1)
),
conversionFactors,
new CANCoderSwerve(
DriveConstants.CANIDs.Modules.FR.CANCODER
RobotConstants.CANIDs.Drive.FR.ENCODER
),
DriveConstants.Modules.Offsets.FR.ANGLE.in(Degrees),
DriveConstants.Modules.Offsets.FR.X.in(Meters),
Expand All @@ -252,18 +252,18 @@ public SwerveSubsystem() {
),
new SwerveModuleConfiguration(
new TalonFXSwerve(
DriveConstants.CANIDs.Modules.BL.DRIVE,
RobotConstants.CANIDs.Drive.BL.DRIVE,
true,
DCMotor.getKrakenX60Foc(1)
),
new TalonFXSwerve(
DriveConstants.CANIDs.Modules.BL.STEER,
RobotConstants.CANIDs.Drive.BL.STEER,
false,
DCMotor.getKrakenX44Foc(1)
),
conversionFactors,
new CANCoderSwerve(
DriveConstants.CANIDs.Modules.BL.CANCODER
RobotConstants.CANIDs.Drive.BL.ENCODER
),
DriveConstants.Modules.Offsets.BL.ANGLE.in(Degrees),
DriveConstants.Modules.Offsets.BL.X.in(Meters),
Expand All @@ -277,18 +277,18 @@ public SwerveSubsystem() {
),
new SwerveModuleConfiguration(
new TalonFXSwerve(
DriveConstants.CANIDs.Modules.BR.DRIVE,
RobotConstants.CANIDs.Drive.BR.DRIVE,
true,
DCMotor.getKrakenX60Foc(1)
),
new TalonFXSwerve(
DriveConstants.CANIDs.Modules.BR.STEER,
RobotConstants.CANIDs.Drive.BR.STEER,
false,
DCMotor.getKrakenX44Foc(1)
),
conversionFactors,
new CANCoderSwerve(
DriveConstants.CANIDs.Modules.BR.CANCODER
RobotConstants.CANIDs.Drive.BR.ENCODER
),
DriveConstants.Modules.Offsets.BR.ANGLE.in(Degrees),
DriveConstants.Modules.Offsets.BR.X.in(Meters),
Expand All @@ -305,7 +305,7 @@ public SwerveSubsystem() {
SwerveDriveConfiguration driveConfiguration =
new SwerveDriveConfiguration(
modules,
new Pigeon2Swerve(DriveConstants.CANIDs.IMU),
new Pigeon2Swerve(RobotConstants.CANIDs.Drive.IMU),
DriveConstants.IMU.INVERTED,
physicalCharacteristics
);
Expand Down
51 changes: 51 additions & 0 deletions src/main/java/frc/robot/subsystems/util/PDHSubsystem.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package frc.robot.subsystems.util;

import edu.wpi.first.wpilibj.PowerDistribution;
import edu.wpi.first.wpilibj.PowerDistribution.ModuleType;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import edu.wpi.first.wpilibj2.command.SubsystemBase;

import frc.robot.Constants.RobotConstants;

public class PDHSubsystem extends SubsystemBase {

private static final PowerDistribution PDH = new PowerDistribution(
RobotConstants.CANIDs.PDH,
ModuleType.kRev
);

@Override
public void periodic() {
// wattage and joule draw is not supported on the rev pdh
SmartDashboard.putNumber(
"PDH/totalCurrentDraw",
PDH.getTotalCurrent()
);

// [documentation](https://github.wpilib.org/allwpilib/docs/release/java/edu/wpi/first/wpilibj/PowerDistribution.html#getAllCurrents())
// only specifies that this works for the PDP, does not mention rev PDH
// but i don't see why not
SmartDashboard.putNumberArray(
"PDH/channelCurrents",
PDH.getAllCurrents()
);

SmartDashboard.putNumber(
"PDH/batteryVoltage",
PDH.getVoltage()
);

SmartDashboard.putBoolean(
"PDH/switchableChannelEnabled",
getSwitchableChannel()
);
}

public boolean getSwitchableChannel() {
return PDH.getSwitchableChannel();
}

public void setSwitchableChannel(boolean value) {
PDH.setSwitchableChannel(value);
}
}