From aa09c5651d1a3ee99d543ee47c4a93fb588448e4 Mon Sep 17 00:00:00 2001 From: NotItAadit Date: Tue, 31 Mar 2026 20:48:09 -0400 Subject: [PATCH 1/5] transfer velocity --- src/main/java/frc/robot/RobotContainer.java | 6 +-- .../java/frc/robot/subsystems/Indexer.java | 39 +++++++++++++------ 2 files changed, 30 insertions(+), 15 deletions(-) diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index 40b8411d..fa9e9887 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -156,9 +156,9 @@ private void configureBindings() { new Trigger(copilot::getXButton).whileTrue(hood.retractCommand().withInterruptBehavior(InterruptionBehavior.kCancelIncoming)); new Trigger(copilot::getLeftBumperButton).whileTrue(indexer.indexCommand(-IndexerConstants.SPINDEXDER_POWER, - -IndexerConstants.TRANSFER_POWER)); + -IndexerConstants.TRANSFER_VELOCITY)); new Trigger(copilot::getRightBumperButton).whileTrue(indexer.indexCommand(IndexerConstants.SPINDEXDER_POWER, - IndexerConstants.TRANSFER_POWER)); + IndexerConstants.TRANSFER_VELOCITY)); new Trigger(copilot::getStartButton).onTrue(collector.stowPivotCommand()); @@ -190,7 +190,7 @@ private void configureBindings() { // new Trigger(() -> DriverStation.isEnabled()).onTrue(hood.zeroCommand()); - new Trigger(copilot::getAButton).whileTrue(indexer.autoIndex(IndexerConstants.SPINDEXDER_POWER, IndexerConstants.TRANSFER_POWER)).onFalse(new InstantCommand(() -> indexer.stop())); + new Trigger(copilot::getAButton).whileTrue(indexer.autoIndex(IndexerConstants.SPINDEXDER_POWER, IndexerConstants.TRANSFER_VELOCITY)).onFalse(new InstantCommand(() -> indexer.stop())); new Trigger(copilot::getYButton).whileTrue(indexer.indexCommand(-0.5).withTimeout(0.1).andThen(indexer.indexCommand(1))); } diff --git a/src/main/java/frc/robot/subsystems/Indexer.java b/src/main/java/frc/robot/subsystems/Indexer.java index ef96b2aa..cf947ceb 100644 --- a/src/main/java/frc/robot/subsystems/Indexer.java +++ b/src/main/java/frc/robot/subsystems/Indexer.java @@ -8,6 +8,7 @@ import com.ctre.phoenix6.configs.TalonFXConfiguration; import com.ctre.phoenix6.controls.DutyCycleOut; +import com.ctre.phoenix6.controls.VelocityVoltage; import com.ctre.phoenix6.sim.TalonFXSimState; import com.ctre.phoenix6.sim.TalonFXSimState.MotorType; @@ -58,10 +59,14 @@ public class IndexerConstants { public static final Current TRANSFER_MOTOR_STATOR_LIMIT = Amps.of(40); // temp public static final boolean TRANSFER_MOTOR_BRAKE_MODE = true; // temp - public static final double TRANSFER_POWER = 1; + public static final double TRANSFER_POWER = 0.65; + public static final double TRANSFER_VELOCITY = 70; public static final Current TRANSFER_SUPPLY_LIMIT = Amps.of(40); // temp public static final boolean TRANSFER_SUPPLY_LIMIT_ENABLE = true; // temp + public static final double TRANSFER_kP = 0.09; // temp + public static final double TRANSFER_kV_FEEDFORWARD = 0.092; // temp + // sim public static final AngularVelocity SIM_INDEX_THRESHOLD = RotationsPerSecond.of(1); // temp } @@ -72,6 +77,8 @@ public class IndexerConstants { private final DutyCycleOut spindexerDutyCycle; private final DutyCycleOut transferDutyCycle; + private VelocityVoltage transferVelocityVoltage; + private LinearSystemSim spindexerSim; private TalonFXSimState motorSim; @@ -88,12 +95,16 @@ public Indexer() { spindexerDutyCycle = new DutyCycleOut(0d); transferDutyCycle = new DutyCycleOut(0d); + VelocityVoltage transferVelocityVoltage = new VelocityVoltage(0); TalonFXConfiguration spindexerConfig = spindexerMotor.getConfig(); TalonFXConfiguration transferConfig = transferMotor.getConfig(); spindexerConfig.CurrentLimits.SupplyCurrentLimitEnable = IndexerConstants.SPINDEXER_SUPPLY_LIMIT_ENABLE; spindexerConfig.CurrentLimits.SupplyCurrentLimit = IndexerConstants.SPINDEXER_SUPPLY_LIMIT.in(Amps); + + transferConfig.Slot0.kP = IndexerConstants.TRANSFER_kP; + transferConfig.CurrentLimits.SupplyCurrentLimitEnable = IndexerConstants.TRANSFER_SUPPLY_LIMIT_ENABLE; transferConfig.CurrentLimits.SupplyCurrentLimit = IndexerConstants.TRANSFER_SUPPLY_LIMIT.in(Amps); @@ -178,6 +189,10 @@ public void setTransferPower(double power) { transferMotor.setControl(transferDutyCycle.withOutput(power)); } + public void setTransferVelocity(double velocity) { + transferMotor.setControl(transferVelocityVoltage.withVelocity(velocity).withFeedForward(IndexerConstants.TRANSFER_kV_FEEDFORWARD)); + } + /** * stops all movement to the transfer motor */ @@ -217,25 +232,25 @@ public Command indexCommand(double power) { return new StartEndCommand(() -> setPower(power), () -> stop(), this); } - public Command indexCommand(DoubleSupplier spindexerPower, DoubleSupplier transferPower) { - return new StartEndCommand(() -> setPower(spindexerPower.getAsDouble(), transferPower.getAsDouble()), this::stop); + public Command indexCommand(DoubleSupplier spindexerPower, DoubleSupplier transferVelocity) { + return new StartEndCommand(() -> setPower(spindexerPower.getAsDouble(), transferVelocity.getAsDouble()), this::stop); } - public Command autoIndex(DoubleSupplier spindexerPower, DoubleSupplier transferPower) { - return new InstantCommand(() -> setTransferPower(transferPower.getAsDouble())) + public Command autoIndex(DoubleSupplier spindexerPower, DoubleSupplier transferVelocity) { + return new InstantCommand(() -> setTransferVelocity(transferVelocity.getAsDouble())) .andThen(new WaitCommand(IndexerConstants.SPINDEXER_DELAY)) - .andThen(indexCommand(spindexerPower, transferPower)); + .andThen(indexCommand(spindexerPower, transferVelocity)); } - public Command autoIndex(double spindexerPower, double transferPower) { - return autoIndex(() -> spindexerPower, () -> transferPower); + public Command autoIndex(double spindexerPower, double transferVelocity) { + return autoIndex(() -> spindexerPower, () -> transferVelocity); } - public Command indexCommand(double spindexerPower, double transferPower) { - return indexCommand(() -> spindexerPower, () -> transferPower); + public Command indexCommand(double spindexerPower, double transferVelocity) { + return indexCommand(() -> spindexerPower, () -> transferVelocity); } - public Command transferCommand(DoubleSupplier transferPower) { - return new RunCommand(() -> setTransferPower(transferPower.getAsDouble())); + public Command transferCommand(DoubleSupplier transferVelocity) { + return new RunCommand(() -> setTransferVelocity(transferVelocity.getAsDouble())); } } From 221e2c45cbf45e8d6694de3748e94b285f732485 Mon Sep 17 00:00:00 2001 From: NotItAadit Date: Tue, 31 Mar 2026 20:55:33 -0400 Subject: [PATCH 2/5] no more motion magic its bad --- src/main/java/frc/robot/subsystems/Turret.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/frc/robot/subsystems/Turret.java b/src/main/java/frc/robot/subsystems/Turret.java index 448b736d..2e232ef2 100644 --- a/src/main/java/frc/robot/subsystems/Turret.java +++ b/src/main/java/frc/robot/subsystems/Turret.java @@ -8,7 +8,7 @@ import com.ctre.phoenix6.configs.TalonFXConfiguration; import com.ctre.phoenix6.controls.DutyCycleOut; -import com.ctre.phoenix6.controls.MotionMagicVoltage; +import com.ctre.phoenix6.controls.PositionVoltage; import com.ctre.phoenix6.sim.TalonFXSimState; import edu.wpi.first.math.geometry.Pose2d; @@ -95,7 +95,7 @@ public class TurretConstants { private Angle targetPosition = Rotations.zero(); - public final MotionMagicVoltage motionMagic = new MotionMagicVoltage(0); + public final PositionVoltage positionVoltage = new PositionVoltage(0); private final DutyCycleOut dutyCycle = new DutyCycleOut(0.0); private DCMotor gearbox; @@ -278,7 +278,7 @@ public void setAngle(Angle angle, AngularVelocity chassisOmegaRadPerSec, Angular double feedforwardVolts = -chassisOmegaRadPerSec.in(RotationsPerSecond) * TurretConstants.kV_FEEDFORWARD; // feedforward to counteract chassis rotation feedforwardVolts += -hubRadPerSec.in(RotationsPerSecond) * TurretConstants.kV_FEEDFORWARD; // add feedforward for hub velocity as well - motor.setControl(motionMagic + motor.setControl(positionVoltage .withPosition(optimizeTurretAngle(targetPosition)) .withFeedForward(feedforwardVolts)); } From 73dbf3ab805304e8baabb31c6a6df6ca83611fd7 Mon Sep 17 00:00:00 2001 From: NotItAadit Date: Wed, 1 Apr 2026 13:06:59 -0400 Subject: [PATCH 3/5] changed kv to be a config --- src/main/java/frc/robot/subsystems/Indexer.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/frc/robot/subsystems/Indexer.java b/src/main/java/frc/robot/subsystems/Indexer.java index d859c770..08bbf189 100644 --- a/src/main/java/frc/robot/subsystems/Indexer.java +++ b/src/main/java/frc/robot/subsystems/Indexer.java @@ -65,7 +65,7 @@ public class IndexerConstants { public static final boolean TRANSFER_SUPPLY_LIMIT_ENABLE = true; // temp public static final double TRANSFER_kP = 0.09; // temp - public static final double TRANSFER_kV_FEEDFORWARD = 0.092; // temp + public static final double TRANSFER_kV = 0.092; // temp // sim public static final AngularVelocity SIM_INDEX_THRESHOLD = RotationsPerSecond.of(1); // temp @@ -104,6 +104,7 @@ public Indexer() { spindexerConfig.CurrentLimits.SupplyCurrentLimit = IndexerConstants.SPINDEXER_SUPPLY_LIMIT.in(Amps); transferConfig.Slot0.kP = IndexerConstants.TRANSFER_kP; + transferConfig.Slot0.kV = IndexerConstants.TRANSFER_kV; transferConfig.CurrentLimits.SupplyCurrentLimitEnable = IndexerConstants.TRANSFER_SUPPLY_LIMIT_ENABLE; transferConfig.CurrentLimits.SupplyCurrentLimit = IndexerConstants.TRANSFER_SUPPLY_LIMIT.in(Amps); @@ -190,7 +191,7 @@ public void setTransferPower(double power) { } public void setTransferVelocity(double velocity) { - transferMotor.setControl(transferVelocityVoltage.withVelocity(velocity).withFeedForward(IndexerConstants.TRANSFER_kV_FEEDFORWARD)); + transferMotor.setControl(transferVelocityVoltage.withVelocity(velocity)); } /** From fb4f304b20c2e4d82cebd44e43968a2abe4479f4 Mon Sep 17 00:00:00 2001 From: NotItAadit Date: Mon, 6 Apr 2026 19:35:51 -0400 Subject: [PATCH 4/5] made setpower use settransfervelocity --- src/main/java/frc/robot/subsystems/Indexer.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/frc/robot/subsystems/Indexer.java b/src/main/java/frc/robot/subsystems/Indexer.java index 08bbf189..0b671cf3 100644 --- a/src/main/java/frc/robot/subsystems/Indexer.java +++ b/src/main/java/frc/robot/subsystems/Indexer.java @@ -207,12 +207,12 @@ public void stopTransfer() { */ public void setPower(double power) { setSpindexerPower(power); - setTransferPower(power); + setTransferVelocity(power); } public void setPower(double spindexerPower, double transferPower) { setSpindexerPower(spindexerPower); - setTransferPower(transferPower); + setTransferVelocity(transferPower); } /** From 657c4ffd02323fedc0a67c20c9f8bab019281fe7 Mon Sep 17 00:00:00 2001 From: Zan e1 Date: Wed, 8 Apr 2026 18:19:18 -0400 Subject: [PATCH 5/5] New gains --- src/main/java/frc/robot/subsystems/Indexer.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/frc/robot/subsystems/Indexer.java b/src/main/java/frc/robot/subsystems/Indexer.java index 0b671cf3..fd70c20f 100644 --- a/src/main/java/frc/robot/subsystems/Indexer.java +++ b/src/main/java/frc/robot/subsystems/Indexer.java @@ -64,8 +64,9 @@ public class IndexerConstants { public static final Current TRANSFER_SUPPLY_LIMIT = Amps.of(40); // temp public static final boolean TRANSFER_SUPPLY_LIMIT_ENABLE = true; // temp - public static final double TRANSFER_kP = 0.09; // temp - public static final double TRANSFER_kV = 0.092; // temp + public static final double TRANSFER_kP = 0.2; // temp + public static final double TRANSFER_kV = 0.124; // temp + public static final double TRANSFER_kS = 0.25; // sim public static final AngularVelocity SIM_INDEX_THRESHOLD = RotationsPerSecond.of(1); // temp