Skip to content

Commit

Permalink
changed current limiting setup
Browse files Browse the repository at this point in the history
  • Loading branch information
GearBoxFox committed Mar 11, 2024
1 parent 4eaa404 commit 4c20746
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,11 @@ public ModuleIOTalonFX(ModuleConstants moduleConstants) {

// run configs on drive motor
var driveConfig = new TalonFXConfiguration();
driveConfig.CurrentLimits.StatorCurrentLimit = 120.0;
driveConfig.CurrentLimits.StatorCurrentLimitEnable = true;
driveConfig.CurrentLimits.SupplyCurrentLimit = 40.0;
driveConfig.CurrentLimits.SupplyCurrentLimitEnable = true;
driveConfig.Voltage.SupplyVoltageTimeConstant = 0.02;
driveConfig.MotorOutput.Inverted =
moduleConstants.DRIVE_MOTOR_INVERTED() ? InvertedValue.Clockwise_Positive
: InvertedValue.CounterClockwise_Positive;
Expand All @@ -121,8 +124,10 @@ public ModuleIOTalonFX(ModuleConstants moduleConstants) {

// run configs on turning motor
var turnConfig = new TalonFXConfiguration();
turnConfig.CurrentLimits.StatorCurrentLimit = 30.0;
turnConfig.CurrentLimits.StatorCurrentLimit = 80.0;
turnConfig.CurrentLimits.StatorCurrentLimitEnable = true;
turnConfig.CurrentLimits.SupplyCurrentLimit = 40.0;
turnConfig.CurrentLimits.SupplyCurrentLimitEnable = true;
turnConfig.MotorOutput.Inverted =
moduleConstants.TURN_MOTOR_INVERTED() ? InvertedValue.Clockwise_Positive
: InvertedValue.CounterClockwise_Positive;
Expand All @@ -142,8 +147,7 @@ public ModuleIOTalonFX(ModuleConstants moduleConstants) {
.addI(m_moduleConstants.TURN_KI())
.addD(m_moduleConstants.TURN_KD());

m_posRequest = new PositionVoltage(0, 0, false, 0, 0, false, false, false);

m_posRequest = new PositionVoltage(0, 0, true, 0, 0, false, false, false);

// Fancy multithreaded odometry update stuff
// setup drive values
Expand Down Expand Up @@ -225,6 +229,8 @@ public void updateInputs(ModuleIOInputsAutoLogged inputs) {
inputs.setTurnAppliedVolts(m_turnAppliedVolts.getValueAsDouble());
inputs.setTurnCurrentAmps(new double[] {m_turnCurrent.getValueAsDouble()});

inputs.odometryTimestamps =
timestampQueue.stream().mapToDouble((Double value) -> value).toArray();
inputs.setOdometryDrivePositionsRad(m_drivePositionQueue.stream()
.mapToDouble(Units::rotationsToRadians)
.toArray());
Expand All @@ -239,7 +245,7 @@ public void updateInputs(ModuleIOInputsAutoLogged inputs) {
@Override
public void setDriveVelocityMPS(double mps) {
double rps = (mps / m_moduleConstants.WHEEL_CURCUMFERENCE_METERS()) * m_moduleConstants.DRIVE_GEAR_RATIO();
VelocityVoltage velRequest = new VelocityVoltage(rps).withSlot(0);
VelocityVoltage velRequest = new VelocityVoltage(rps).withSlot(0).withEnableFOC(true);
m_driveTalon.setControl(velRequest.withVelocity(rps));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public void updateInputs(ShooterIOInputsAutoLogged inputs) {
inputs.intakeTemperature = m_intakeTemperatureSignal.getValueAsDouble();
inputs.indexerTemperature = m_indexerTemperatureSignal.getValueAsDouble();

inputs.tofDistanceIn = m_tof.getRange();
inputs.tofDistanceIn = m_tof.getRange();

m_leftProperty.updateIfChanged();
m_rightProperty.updateIfChanged();
Expand Down

0 comments on commit 4c20746

Please sign in to comment.