From ad09bfaa2350a3f3e2b56995e31f52a21aa7e837 Mon Sep 17 00:00:00 2001 From: Frank Date: Sun, 2 Feb 2025 01:17:18 +0800 Subject: [PATCH 01/10] fix: PowerDistribution change "isClimbeOverCurrent" to "isClimberOverCurrent" --- .../java/frc/robot/subsystems/PowerDistributionSubsystem.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/frc/robot/subsystems/PowerDistributionSubsystem.java b/src/main/java/frc/robot/subsystems/PowerDistributionSubsystem.java index 0ca0b6af..267a53a8 100644 --- a/src/main/java/frc/robot/subsystems/PowerDistributionSubsystem.java +++ b/src/main/java/frc/robot/subsystems/PowerDistributionSubsystem.java @@ -82,7 +82,7 @@ public boolean isAlgaeRotateOverCurrent() { return isOverCurrent; } - public boolean isClimbeOverCurrent() { + public boolean isClimberOverCurrent() { boolean isOverCurrent = climberCurrent() > PowerDistributionConstant.kClimberMotorMaxCurrent; SmartDashboard.putBoolean("isClimberOverCurrent", isOverCurrent); From caf467a892c6ae6902920ea1c1d842500b66ab0e Mon Sep 17 00:00:00 2001 From: Frank Date: Sun, 2 Feb 2025 15:52:26 +0800 Subject: [PATCH 02/10] fix: PowerDistributionSubsystem delete the "PowerDistributionSubsystem" --- .../PowerDistributionSubsystem.java | 99 ------------------- 1 file changed, 99 deletions(-) delete mode 100644 src/main/java/frc/robot/subsystems/PowerDistributionSubsystem.java diff --git a/src/main/java/frc/robot/subsystems/PowerDistributionSubsystem.java b/src/main/java/frc/robot/subsystems/PowerDistributionSubsystem.java deleted file mode 100644 index 267a53a8..00000000 --- a/src/main/java/frc/robot/subsystems/PowerDistributionSubsystem.java +++ /dev/null @@ -1,99 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -package frc.robot.subsystems; - -import edu.wpi.first.wpilibj.PowerDistribution; -import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; -import edu.wpi.first.wpilibj2.command.SubsystemBase; -import frc.robot.Constants.PowerDistributionConstant; - -public class PowerDistributionSubsystem extends SubsystemBase { - private PowerDistribution powerDistribution; - - public PowerDistributionSubsystem() { - powerDistribution = new PowerDistribution(); - SmartDashboard.putNumber("coralShooterCurrent", 0); - SmartDashboard.putNumber("algaeIntakeCurrent", 0); - SmartDashboard.putNumber("algaeRotateCurrent", 0); - SmartDashboard.putNumber("climberCurrent", 0); - SmartDashboard.putNumber("rampCurrent", 0); - SmartDashboard.putBoolean("isCoralShooterOverCurrent", false); - SmartDashboard.putBoolean("isAlgaeIntakeOverCurrent", false); - SmartDashboard.putBoolean("isAlgaeRotateOverCurrent", false); - SmartDashboard.putBoolean("isClimberOverCurrent", false); - SmartDashboard.putBoolean("isRampOverCurrent", false); - } - - public double coralShooterCurrent() { - double current = powerDistribution - .getCurrent(PowerDistributionConstant.kCoralShooterMotorCurrentchannel); - SmartDashboard.putNumber("coralShooterCurrent", current); - return current; - } - - public double algaeIntakeCurrent() { - double current = powerDistribution - .getCurrent(PowerDistributionConstant.kAlgaeIntakeMotorCurrentchannel); - SmartDashboard.putNumber("algaeIntakeCurrent", current); - return current; - } - - public double algaeRotateCurrent() { - double current = powerDistribution - .getCurrent(PowerDistributionConstant.kAlgaeRotateMotorCurrentchannel); - SmartDashboard.putNumber("algaeRotateCurrent", current); - return current; - } - - public double climberCurrent() { - double current = powerDistribution - .getCurrent(PowerDistributionConstant.kClimberMotorCurrentchannel); - SmartDashboard.putNumber("climberCurrent", current); - return current; - } - - public double rampCurrent() { - double current = powerDistribution - .getCurrent(PowerDistributionConstant.kRampMotorCurrentchannel); - SmartDashboard.putNumber("rampCurrent", current); - return current; - } - - public boolean isCoralShooterOverCurrent() { - boolean isOverCurrent = - coralShooterCurrent() > PowerDistributionConstant.kCoralShooterMotorMaxCurrent; - SmartDashboard.putBoolean("isCoralShooterOverCurrent", isOverCurrent); - return isOverCurrent; - } - - public boolean isAlgaeIntakeOverCurrent() { - boolean isOverCurrent = - algaeIntakeCurrent() > PowerDistributionConstant.kAlgaeIntakeMotorMaxCurrent; - SmartDashboard.putBoolean("isAlgaeIntakeOverCurrent", isOverCurrent); - return isOverCurrent; - } - - public boolean isAlgaeRotateOverCurrent() { - boolean isOverCurrent = - algaeRotateCurrent() > PowerDistributionConstant.kAlgaeRotateMotorMaxCurrent; - SmartDashboard.putBoolean("isAlgaeRotateOverCurrent", isOverCurrent); - return isOverCurrent; - } - - public boolean isClimberOverCurrent() { - boolean isOverCurrent = - climberCurrent() > PowerDistributionConstant.kClimberMotorMaxCurrent; - SmartDashboard.putBoolean("isClimberOverCurrent", isOverCurrent); - return isOverCurrent; - } - - public boolean isRampOverCurrent() { - boolean isOverCurrent = - rampCurrent() > PowerDistributionConstant.kRampMotorMaxCurrent; - SmartDashboard.putBoolean("isRampOverCurrent", isOverCurrent); - return isOverCurrent; - } - -} From b4735dd3e478c6c72491e751ddb11521c9e54c1b Mon Sep 17 00:00:00 2001 From: Frank Date: Sun, 2 Feb 2025 15:53:10 +0800 Subject: [PATCH 03/10] feat: powerDistribution add "powerDistribution" to lib --- .../java/frc/robot/lib/powerDistribution.java | 98 +++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 src/main/java/frc/robot/lib/powerDistribution.java diff --git a/src/main/java/frc/robot/lib/powerDistribution.java b/src/main/java/frc/robot/lib/powerDistribution.java new file mode 100644 index 00000000..8f768cc4 --- /dev/null +++ b/src/main/java/frc/robot/lib/powerDistribution.java @@ -0,0 +1,98 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +package frc.robot.lib; + +import edu.wpi.first.wpilibj.PowerDistribution; +import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; +import frc.robot.Constants.PowerDistributionConstant; + +public class powerDistribution { + private PowerDistribution powerDistribution; + + public powerDistribution() { + powerDistribution = new PowerDistribution(); + SmartDashboard.putNumber("coralShooterCurrent", 0); + SmartDashboard.putNumber("algaeIntakeCurrent", 0); + SmartDashboard.putNumber("algaeRotateCurrent", 0); + SmartDashboard.putNumber("climberCurrent", 0); + SmartDashboard.putNumber("rampCurrent", 0); + SmartDashboard.putBoolean("isCoralShooterOverCurrent", false); + SmartDashboard.putBoolean("isAlgaeIntakeOverCurrent", false); + SmartDashboard.putBoolean("isAlgaeRotateOverCurrent", false); + SmartDashboard.putBoolean("isClimberOverCurrent", false); + SmartDashboard.putBoolean("isRampOverCurrent", false); + } + + public double coralShooterCurrent() { + double current = powerDistribution + .getCurrent(PowerDistributionConstant.kCoralShooterMotorCurrentchannel); + SmartDashboard.putNumber("coralShooterCurrent", current); + return current; + } + + public double algaeIntakeCurrent() { + double current = powerDistribution + .getCurrent(PowerDistributionConstant.kAlgaeIntakeMotorCurrentchannel); + SmartDashboard.putNumber("algaeIntakeCurrent", current); + return current; + } + + public double algaeRotateCurrent() { + double current = powerDistribution + .getCurrent(PowerDistributionConstant.kAlgaeRotateMotorCurrentchannel); + SmartDashboard.putNumber("algaeRotateCurrent", current); + return current; + } + + public double climberCurrent() { + double current = powerDistribution + .getCurrent(PowerDistributionConstant.kClimberMotorCurrentchannel); + SmartDashboard.putNumber("climberCurrent", current); + return current; + } + + public double rampCurrent() { + double current = powerDistribution + .getCurrent(PowerDistributionConstant.kRampMotorCurrentchannel); + SmartDashboard.putNumber("rampCurrent", current); + return current; + } + + public boolean isCoralShooterOverCurrent() { + boolean isOverCurrent = + coralShooterCurrent() > PowerDistributionConstant.kCoralShooterMotorMaxCurrent; + SmartDashboard.putBoolean("isCoralShooterOverCurrent", isOverCurrent); + return isOverCurrent; + } + + public boolean isAlgaeIntakeOverCurrent() { + boolean isOverCurrent = + algaeIntakeCurrent() > PowerDistributionConstant.kAlgaeIntakeMotorMaxCurrent; + SmartDashboard.putBoolean("isAlgaeIntakeOverCurrent", isOverCurrent); + return isOverCurrent; + } + + public boolean isAlgaeRotateOverCurrent() { + boolean isOverCurrent = + algaeRotateCurrent() > PowerDistributionConstant.kAlgaeRotateMotorMaxCurrent; + SmartDashboard.putBoolean("isAlgaeRotateOverCurrent", isOverCurrent); + return isOverCurrent; + } + + public boolean isClimberOverCurrent() { + boolean isOverCurrent = + climberCurrent() > PowerDistributionConstant.kClimberMotorMaxCurrent; + SmartDashboard.putBoolean("isClimberOverCurrent", isOverCurrent); + return isOverCurrent; + } + + public boolean isRampOverCurrent() { + boolean isOverCurrent = + rampCurrent() > PowerDistributionConstant.kRampMotorMaxCurrent; + SmartDashboard.putBoolean("isRampOverCurrent", isOverCurrent); + return isOverCurrent; + } + +} From 4edcefe343e3d9810ba2ed4297e975205047b6ab Mon Sep 17 00:00:00 2001 From: Frank Date: Sun, 2 Feb 2025 15:57:06 +0800 Subject: [PATCH 04/10] fix: Constants change "Currentchannel" to "CCurrentChannel" --- src/main/java/frc/robot/Constants.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java index 134c3e60..1fb35ec7 100644 --- a/src/main/java/frc/robot/Constants.java +++ b/src/main/java/frc/robot/Constants.java @@ -25,11 +25,11 @@ public static final class AlgaeIntakeConstant { public static final class PowerDistributionConstant { // Motor channel - public static final int kCoralShooterMotorCurrentchannel = 7; - public static final int kAlgaeIntakeMotorCurrentchannel = 7; - public static final int kAlgaeRotateMotorCurrentchannel = 7; - public static final int kClimberMotorCurrentchannel = 7; - public static final int kRampMotorCurrentchannel = 7; + public static final int kCoralShooterMotorCurrentChannel = 7; + public static final int kAlgaeIntakeMotorCurrentChannel = 7; + public static final int kAlgaeRotateMotorCurrentChannel = 7; + public static final int kClimberMotorCurrentChannel = 7; + public static final int kRampMotorCurrentChannel = 7; // Motor Max Current public static final double kCoralShooterMotorMaxCurrent = 40; public static final double kAlgaeIntakeMotorMaxCurrent = 40; From 4263fba3db64511926d17eaea21a29693dce693f Mon Sep 17 00:00:00 2001 From: Frank Date: Tue, 4 Feb 2025 14:46:04 +0800 Subject: [PATCH 05/10] fix: PowerDistribution change "Currentchannel" to "CurrentChannel" --- src/main/java/frc/robot/lib/powerDistribution.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/frc/robot/lib/powerDistribution.java b/src/main/java/frc/robot/lib/powerDistribution.java index 8f768cc4..04ef31d3 100644 --- a/src/main/java/frc/robot/lib/powerDistribution.java +++ b/src/main/java/frc/robot/lib/powerDistribution.java @@ -27,35 +27,35 @@ public powerDistribution() { public double coralShooterCurrent() { double current = powerDistribution - .getCurrent(PowerDistributionConstant.kCoralShooterMotorCurrentchannel); + .getCurrent(PowerDistributionConstant.kCoralShooterMotorCurrentChannel); SmartDashboard.putNumber("coralShooterCurrent", current); return current; } public double algaeIntakeCurrent() { double current = powerDistribution - .getCurrent(PowerDistributionConstant.kAlgaeIntakeMotorCurrentchannel); + .getCurrent(PowerDistributionConstant.kAlgaeIntakeMotorCurrentChannel); SmartDashboard.putNumber("algaeIntakeCurrent", current); return current; } public double algaeRotateCurrent() { double current = powerDistribution - .getCurrent(PowerDistributionConstant.kAlgaeRotateMotorCurrentchannel); + .getCurrent(PowerDistributionConstant.kAlgaeRotateMotorCurrentChannel); SmartDashboard.putNumber("algaeRotateCurrent", current); return current; } public double climberCurrent() { double current = powerDistribution - .getCurrent(PowerDistributionConstant.kClimberMotorCurrentchannel); + .getCurrent(PowerDistributionConstant.kClimberMotorCurrentChannel); SmartDashboard.putNumber("climberCurrent", current); return current; } public double rampCurrent() { double current = powerDistribution - .getCurrent(PowerDistributionConstant.kRampMotorCurrentchannel); + .getCurrent(PowerDistributionConstant.kRampMotorCurrentChannel); SmartDashboard.putNumber("rampCurrent", current); return current; } From 8c7280fd80bb155f892f2e7e66db8953a701b02d Mon Sep 17 00:00:00 2001 From: Frank Date: Tue, 4 Feb 2025 15:01:55 +0800 Subject: [PATCH 06/10] fix: Constants add another motor at the coral shooter power distribution spot --- src/main/java/frc/robot/Constants.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java index 1fb35ec7..5cc7237a 100644 --- a/src/main/java/frc/robot/Constants.java +++ b/src/main/java/frc/robot/Constants.java @@ -25,7 +25,8 @@ public static final class AlgaeIntakeConstant { public static final class PowerDistributionConstant { // Motor channel - public static final int kCoralShooterMotorCurrentChannel = 7; + public static final int kCoralShooterRightMotorCurrentChannel = 7; + public static final int kCoralShooterLeftMotorCurrentChannel = 7; public static final int kAlgaeIntakeMotorCurrentChannel = 7; public static final int kAlgaeRotateMotorCurrentChannel = 7; public static final int kClimberMotorCurrentChannel = 7; From 59dbe2d9bc49f4426fde354d513ebe58bea56b41 Mon Sep 17 00:00:00 2001 From: Frank Date: Tue, 4 Feb 2025 15:02:58 +0800 Subject: [PATCH 07/10] feat: powerDistribution add another motor at the coral shooter power distribution spot --- .../java/frc/robot/lib/powerDistribution.java | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/main/java/frc/robot/lib/powerDistribution.java b/src/main/java/frc/robot/lib/powerDistribution.java index 04ef31d3..d792b17b 100644 --- a/src/main/java/frc/robot/lib/powerDistribution.java +++ b/src/main/java/frc/robot/lib/powerDistribution.java @@ -25,9 +25,16 @@ public powerDistribution() { SmartDashboard.putBoolean("isRampOverCurrent", false); } - public double coralShooterCurrent() { + public double coralShooterRightCurrent() { double current = powerDistribution - .getCurrent(PowerDistributionConstant.kCoralShooterMotorCurrentChannel); + .getCurrent(PowerDistributionConstant.kCoralShooterRightMotorCurrentChannel); + SmartDashboard.putNumber("coralShooterCurrent", current); + return current; + } + + public double coralShooterLeftCurrent() { + double current = powerDistribution + .getCurrent(PowerDistributionConstant.kCoralShooterLeftMotorCurrentChannel); SmartDashboard.putNumber("coralShooterCurrent", current); return current; } @@ -61,10 +68,13 @@ public double rampCurrent() { } public boolean isCoralShooterOverCurrent() { - boolean isOverCurrent = - coralShooterCurrent() > PowerDistributionConstant.kCoralShooterMotorMaxCurrent; - SmartDashboard.putBoolean("isCoralShooterOverCurrent", isOverCurrent); - return isOverCurrent; + boolean isRightMotorOverCurrent = + coralShooterRightCurrent() > PowerDistributionConstant.kCoralShooterMotorMaxCurrent; + boolean isLeftMotorOverCurrent = + coralShooterLeftCurrent() > PowerDistributionConstant.kCoralShooterMotorMaxCurrent; + SmartDashboard.putBoolean("isCoralShooterOverCurrent", + isLeftMotorOverCurrent || isRightMotorOverCurrent); + return isLeftMotorOverCurrent || isRightMotorOverCurrent; } public boolean isAlgaeIntakeOverCurrent() { From 21d1a98dda939d83e534d6d8e95b8dfb11ad4322 Mon Sep 17 00:00:00 2001 From: Frank Date: Tue, 4 Feb 2025 15:47:58 +0800 Subject: [PATCH 08/10] fix: powerDistribution add another motor data at dashboard --- src/main/java/frc/robot/lib/powerDistribution.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/frc/robot/lib/powerDistribution.java b/src/main/java/frc/robot/lib/powerDistribution.java index d792b17b..08c04471 100644 --- a/src/main/java/frc/robot/lib/powerDistribution.java +++ b/src/main/java/frc/robot/lib/powerDistribution.java @@ -13,7 +13,8 @@ public class powerDistribution { public powerDistribution() { powerDistribution = new PowerDistribution(); - SmartDashboard.putNumber("coralShooterCurrent", 0); + SmartDashboard.putNumber("coralShooterRightCurrent", 0); + SmartDashboard.putNumber("coralShooterLeftCurrent", 0); SmartDashboard.putNumber("algaeIntakeCurrent", 0); SmartDashboard.putNumber("algaeRotateCurrent", 0); SmartDashboard.putNumber("climberCurrent", 0); @@ -28,14 +29,14 @@ public powerDistribution() { public double coralShooterRightCurrent() { double current = powerDistribution .getCurrent(PowerDistributionConstant.kCoralShooterRightMotorCurrentChannel); - SmartDashboard.putNumber("coralShooterCurrent", current); + SmartDashboard.putNumber("coralShooterRightCurrent", current); return current; } public double coralShooterLeftCurrent() { double current = powerDistribution .getCurrent(PowerDistributionConstant.kCoralShooterLeftMotorCurrentChannel); - SmartDashboard.putNumber("coralShooterCurrent", current); + SmartDashboard.putNumber("coralShooterLeftCurrent", current); return current; } From 75c7f51e77a715ce6ef9326bd7915f222e4c36af Mon Sep 17 00:00:00 2001 From: Frank Date: Tue, 4 Feb 2025 16:37:47 +0800 Subject: [PATCH 09/10] fix: powerDistribution delete this file --- .../java/frc/robot/lib/powerDistribution.java | 109 ------------------ 1 file changed, 109 deletions(-) delete mode 100644 src/main/java/frc/robot/lib/powerDistribution.java diff --git a/src/main/java/frc/robot/lib/powerDistribution.java b/src/main/java/frc/robot/lib/powerDistribution.java deleted file mode 100644 index 08c04471..00000000 --- a/src/main/java/frc/robot/lib/powerDistribution.java +++ /dev/null @@ -1,109 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -package frc.robot.lib; - -import edu.wpi.first.wpilibj.PowerDistribution; -import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; -import frc.robot.Constants.PowerDistributionConstant; - -public class powerDistribution { - private PowerDistribution powerDistribution; - - public powerDistribution() { - powerDistribution = new PowerDistribution(); - SmartDashboard.putNumber("coralShooterRightCurrent", 0); - SmartDashboard.putNumber("coralShooterLeftCurrent", 0); - SmartDashboard.putNumber("algaeIntakeCurrent", 0); - SmartDashboard.putNumber("algaeRotateCurrent", 0); - SmartDashboard.putNumber("climberCurrent", 0); - SmartDashboard.putNumber("rampCurrent", 0); - SmartDashboard.putBoolean("isCoralShooterOverCurrent", false); - SmartDashboard.putBoolean("isAlgaeIntakeOverCurrent", false); - SmartDashboard.putBoolean("isAlgaeRotateOverCurrent", false); - SmartDashboard.putBoolean("isClimberOverCurrent", false); - SmartDashboard.putBoolean("isRampOverCurrent", false); - } - - public double coralShooterRightCurrent() { - double current = powerDistribution - .getCurrent(PowerDistributionConstant.kCoralShooterRightMotorCurrentChannel); - SmartDashboard.putNumber("coralShooterRightCurrent", current); - return current; - } - - public double coralShooterLeftCurrent() { - double current = powerDistribution - .getCurrent(PowerDistributionConstant.kCoralShooterLeftMotorCurrentChannel); - SmartDashboard.putNumber("coralShooterLeftCurrent", current); - return current; - } - - public double algaeIntakeCurrent() { - double current = powerDistribution - .getCurrent(PowerDistributionConstant.kAlgaeIntakeMotorCurrentChannel); - SmartDashboard.putNumber("algaeIntakeCurrent", current); - return current; - } - - public double algaeRotateCurrent() { - double current = powerDistribution - .getCurrent(PowerDistributionConstant.kAlgaeRotateMotorCurrentChannel); - SmartDashboard.putNumber("algaeRotateCurrent", current); - return current; - } - - public double climberCurrent() { - double current = powerDistribution - .getCurrent(PowerDistributionConstant.kClimberMotorCurrentChannel); - SmartDashboard.putNumber("climberCurrent", current); - return current; - } - - public double rampCurrent() { - double current = powerDistribution - .getCurrent(PowerDistributionConstant.kRampMotorCurrentChannel); - SmartDashboard.putNumber("rampCurrent", current); - return current; - } - - public boolean isCoralShooterOverCurrent() { - boolean isRightMotorOverCurrent = - coralShooterRightCurrent() > PowerDistributionConstant.kCoralShooterMotorMaxCurrent; - boolean isLeftMotorOverCurrent = - coralShooterLeftCurrent() > PowerDistributionConstant.kCoralShooterMotorMaxCurrent; - SmartDashboard.putBoolean("isCoralShooterOverCurrent", - isLeftMotorOverCurrent || isRightMotorOverCurrent); - return isLeftMotorOverCurrent || isRightMotorOverCurrent; - } - - public boolean isAlgaeIntakeOverCurrent() { - boolean isOverCurrent = - algaeIntakeCurrent() > PowerDistributionConstant.kAlgaeIntakeMotorMaxCurrent; - SmartDashboard.putBoolean("isAlgaeIntakeOverCurrent", isOverCurrent); - return isOverCurrent; - } - - public boolean isAlgaeRotateOverCurrent() { - boolean isOverCurrent = - algaeRotateCurrent() > PowerDistributionConstant.kAlgaeRotateMotorMaxCurrent; - SmartDashboard.putBoolean("isAlgaeRotateOverCurrent", isOverCurrent); - return isOverCurrent; - } - - public boolean isClimberOverCurrent() { - boolean isOverCurrent = - climberCurrent() > PowerDistributionConstant.kClimberMotorMaxCurrent; - SmartDashboard.putBoolean("isClimberOverCurrent", isOverCurrent); - return isOverCurrent; - } - - public boolean isRampOverCurrent() { - boolean isOverCurrent = - rampCurrent() > PowerDistributionConstant.kRampMotorMaxCurrent; - SmartDashboard.putBoolean("isRampOverCurrent", isOverCurrent); - return isOverCurrent; - } - -} From 8d0ef3913ef4c806bf4c3c231ba53dc08e7553e3 Mon Sep 17 00:00:00 2001 From: Frank Date: Tue, 4 Feb 2025 16:38:51 +0800 Subject: [PATCH 10/10] fix: PowerDistribution add this file --- .../java/frc/robot/lib/PowerDistribution.java | 104 ++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 src/main/java/frc/robot/lib/PowerDistribution.java diff --git a/src/main/java/frc/robot/lib/PowerDistribution.java b/src/main/java/frc/robot/lib/PowerDistribution.java new file mode 100644 index 00000000..c390c4f5 --- /dev/null +++ b/src/main/java/frc/robot/lib/PowerDistribution.java @@ -0,0 +1,104 @@ +package frc.robot.lib; + +import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; +import frc.robot.Constants.PowerDistributionConstant; + +public class PowerDistribution { + private edu.wpi.first.wpilibj.PowerDistribution powerDistribution; + + public PowerDistribution() { + powerDistribution = new edu.wpi.first.wpilibj.PowerDistribution(); + SmartDashboard.putNumber("coralShooterRightCurrent", 0); + SmartDashboard.putNumber("coralShooterLeftCurrent", 0); + SmartDashboard.putNumber("algaeIntakeCurrent", 0); + SmartDashboard.putNumber("algaeRotateCurrent", 0); + SmartDashboard.putNumber("climberCurrent", 0); + SmartDashboard.putNumber("rampCurrent", 0); + SmartDashboard.putBoolean("isCoralShooterOverCurrent", false); + SmartDashboard.putBoolean("isAlgaeIntakeOverCurrent", false); + SmartDashboard.putBoolean("isAlgaeRotateOverCurrent", false); + SmartDashboard.putBoolean("isClimberOverCurrent", false); + SmartDashboard.putBoolean("isRampOverCurrent", false); + } + + public double coralShooterRightCurrent() { + double current = powerDistribution + .getCurrent(PowerDistributionConstant.kCoralShooterRightMotorCurrentChannel); + SmartDashboard.putNumber("coralShooterRightCurrent", current); + return current; + } + + public double coralShooterLeftCurrent() { + double current = powerDistribution + .getCurrent(PowerDistributionConstant.kCoralShooterLeftMotorCurrentChannel); + SmartDashboard.putNumber("coralShooterLeftCurrent", current); + return current; + } + + public double algaeIntakeCurrent() { + double current = powerDistribution + .getCurrent(PowerDistributionConstant.kAlgaeIntakeMotorCurrentChannel); + SmartDashboard.putNumber("algaeIntakeCurrent", current); + return current; + } + + public double algaeRotateCurrent() { + double current = powerDistribution + .getCurrent(PowerDistributionConstant.kAlgaeRotateMotorCurrentChannel); + SmartDashboard.putNumber("algaeRotateCurrent", current); + return current; + } + + public double climberCurrent() { + double current = powerDistribution + .getCurrent(PowerDistributionConstant.kClimberMotorCurrentChannel); + SmartDashboard.putNumber("climberCurrent", current); + return current; + } + + public double rampCurrent() { + double current = powerDistribution + .getCurrent(PowerDistributionConstant.kRampMotorCurrentChannel); + SmartDashboard.putNumber("rampCurrent", current); + return current; + } + + public boolean isCoralShooterOverCurrent() { + boolean isRightMotorOverCurrent = + coralShooterRightCurrent() > PowerDistributionConstant.kCoralShooterMotorMaxCurrent; + boolean isLeftMotorOverCurrent = + coralShooterLeftCurrent() > PowerDistributionConstant.kCoralShooterMotorMaxCurrent; + SmartDashboard.putBoolean("isCoralShooterOverCurrent", + isLeftMotorOverCurrent || isRightMotorOverCurrent); + return isLeftMotorOverCurrent || isRightMotorOverCurrent; + } + + public boolean isAlgaeIntakeOverCurrent() { + boolean isOverCurrent = + algaeIntakeCurrent() > PowerDistributionConstant.kAlgaeIntakeMotorMaxCurrent; + SmartDashboard.putBoolean("isAlgaeIntakeOverCurrent", isOverCurrent); + return isOverCurrent; + } + + public boolean isAlgaeRotateOverCurrent() { + boolean isOverCurrent = + algaeRotateCurrent() > PowerDistributionConstant.kAlgaeRotateMotorMaxCurrent; + SmartDashboard.putBoolean("isAlgaeRotateOverCurrent", isOverCurrent); + return isOverCurrent; + } + + public boolean isClimberOverCurrent() { + boolean isOverCurrent = + climberCurrent() > PowerDistributionConstant.kClimberMotorMaxCurrent; + SmartDashboard.putBoolean("isClimberOverCurrent", isOverCurrent); + return isOverCurrent; + } + + public boolean isRampOverCurrent() { + boolean isOverCurrent = + rampCurrent() > PowerDistributionConstant.kRampMotorMaxCurrent; + SmartDashboard.putBoolean("isRampOverCurrent", isOverCurrent); + return isOverCurrent; + } + +} \ No newline at end of file