Skip to content

Commit

Permalink
Merge pull request #29 from Team6083/PowerDistribution
Browse files Browse the repository at this point in the history
Power distribution 改動
  • Loading branch information
sKJvbawebvawoeJbv authored Feb 4, 2025
2 parents 0a93ce4 + 8d0ef39 commit b4ac5f9
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 30 deletions.
11 changes: 6 additions & 5 deletions src/main/java/frc/robot/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,12 @@ public static final class RampConstant {

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 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;
public static final int kRampMotorCurrentChannel = 7;
// Motor Max Current
public static final double kCoralShooterMotorMaxCurrent = 40;
public static final double kAlgaeIntakeMotorMaxCurrent = 40;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
// 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;

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 class PowerDistribution {
private edu.wpi.first.wpilibj.PowerDistribution powerDistribution;

public PowerDistributionSubsystem() {
powerDistribution = new PowerDistribution();
SmartDashboard.putNumber("coralShooterCurrent", 0);
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);
Expand All @@ -26,46 +21,56 @@ public PowerDistributionSubsystem() {
SmartDashboard.putBoolean("isRampOverCurrent", false);
}

public double coralShooterCurrent() {
public double coralShooterRightCurrent() {
double current = powerDistribution
.getCurrent(PowerDistributionConstant.kCoralShooterMotorCurrentchannel);
SmartDashboard.putNumber("coralShooterCurrent", current);
.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);
.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;
}

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() {
Expand All @@ -82,7 +87,7 @@ public boolean isAlgaeRotateOverCurrent() {
return isOverCurrent;
}

public boolean isClimbeOverCurrent() {
public boolean isClimberOverCurrent() {
boolean isOverCurrent =
climberCurrent() > PowerDistributionConstant.kClimberMotorMaxCurrent;
SmartDashboard.putBoolean("isClimberOverCurrent", isOverCurrent);
Expand All @@ -96,4 +101,4 @@ public boolean isRampOverCurrent() {
return isOverCurrent;
}

}
}

0 comments on commit b4ac5f9

Please sign in to comment.