Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changed current limiting setup #44

Merged
merged 1 commit into from
Mar 11, 2024
Merged
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
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
Loading