Skip to content

Commit

Permalink
chnaged some stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Tinbite-A committed Feb 9, 2025
1 parent 82b0d18 commit e6facb4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import com.ctre.phoenix6.controls.MotionMagicVoltage
import com.ctre.phoenix6.hardware.TalonFX
import edu.wpi.first.units.Units.*
import edu.wpi.first.util.sendable.SendableBuilder
import edu.wpi.first.wpilibj.PowerDistribution
import edu.wpi.first.wpilibj.RobotBase
import edu.wpi.first.wpilibj.smartdashboard.Mechanism2d
import edu.wpi.first.wpilibj.smartdashboard.MechanismLigament2d
Expand All @@ -19,7 +18,6 @@ import frc.team449.subsystems.superstructure.SuperstructureGoal
import frc.team449.subsystems.superstructure.wrist.WristConstants
import java.util.function.Supplier
import kotlin.math.abs
import frc.team449.subsystems.superstructure.PowerManager
import frc.team449.subsystems.superstructure.powerDistribution

open class Elevator(
Expand Down Expand Up @@ -128,7 +126,7 @@ open class Elevator(
config.CurrentLimits.StatorCurrentLimitEnable = true
config.CurrentLimits.SupplyCurrentLimitEnable = true
config.CurrentLimits.StatorCurrentLimit = ElevatorConstants.STATOR_LIM
config.CurrentLimits.SupplyCurrentLimit = powerDistribution.adjustPowerDistribution
config.CurrentLimits.SupplyCurrentLimit = powerDistribution.elevatorSUPPLY_LIM

/** If we gonna have FOC in the future
config.TorqueCurrent.PeakForwardTorqueCurrent = torqueCurrentLimit.`in`(Amps)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@ package frc.team449.subsystems.superstructure

import com.ctre.phoenix6.configs.TalonFXConfiguration
import edu.wpi.first.wpilibj.PowerDistribution
import frc.team449.Robot
import frc.team449.subsystems.superstructure.elevator.Elevator
import frc.team449.subsystems.superstructure.elevator.ElevatorConstants
import frc.team449.subsystems.superstructure.pivot.Pivot
import frc.team449.subsystems.superstructure.wrist.Wrist


class powerDistribution(
val robot: Robot,
private val pdh: PowerDistribution,
private val pivotMotor: Pivot,
private val elevatorMotor: Elevator,
Expand All @@ -22,8 +20,8 @@ class powerDistribution(
private val wristChannel = 2

//stator limit for motor
private val supplyCurrentLimit = 40.0
private val statorCurrentLimit = 80.0
private val SUPPLY_LIM = 40.0
private val STATOR_LIM = 80.0


// get how much is being drawn
Expand All @@ -36,34 +34,34 @@ class powerDistribution(
val elevatorCurrent = getMotorCurrentUsage(elevatorChannel)
val wristCurrent = getMotorCurrentUsage(wristChannel)


// Total current being drawn
val totalCurrent = pivotCurrent + elevatorCurrent + wristCurrent
val idealTotalCurrent = SUPPLY_LIM * 6 // fix this 6 motors but only 3 mechanisms

val idealTotalCurrent = supplyCurrentLimit * 6 // fix this 6 motors but only 3 mechanisms

val config = TalonFXConfiguration()
val config = TalonFXConfiguration()


fun elevatorset() {
if (pivotCurrent < 0 || wristCurrent < 0 || elevatorCurrent > 0.5) {
config.CurrentLimits.SupplyCurrentLimit = ElevatorConstants.SUPPLY_LIM * 1.5
}
}

if (wristCurrent > 0 || elevatorCurrent > 0) {
wristMotor.config.CurrentLimits.SupplyCurrentLimit = ElevatorConstants.SUPPLY_LIM * 1.5
fun elevatorSUPPLY_LIM(){
if (pivotCurrent < 0 || wristCurrent < 0 || elevatorCurrent > 0.5) {
config.CurrentLimits.SupplyCurrentLimit = SUPPLY_LIM * 1.5
} else{
config.CurrentLimits.SupplyCurrentLimit = SUPPLY_LIM
}
}

if (pivotCurrent > 0 || wristCurrent > 0) {
pivotMotor.config.CurrentLimits.SupplyCurrentLimit = ElevatorConstants.SUPPLY_LIM * 1.5
}






}

fun runPowerManagement() {
adjustPowerDistribution()
}

}

0 comments on commit e6facb4

Please sign in to comment.