From 38a93ce898ff759161df758fb33c026e52a2bd20 Mon Sep 17 00:00:00 2001 From: Aarush Jain Date: Tue, 3 Mar 2026 23:50:43 -0500 Subject: [PATCH 1/8] updating hood constants --- .../subsystems/hood/HoodConstants.java | 32 +++++++++++-------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/team900/frc2026/subsystems/hood/HoodConstants.java b/src/main/java/com/team900/frc2026/subsystems/hood/HoodConstants.java index 23df07cf..ccb580de 100644 --- a/src/main/java/com/team900/frc2026/subsystems/hood/HoodConstants.java +++ b/src/main/java/com/team900/frc2026/subsystems/hood/HoodConstants.java @@ -1,32 +1,36 @@ package com.team900.frc2026.subsystems.hood; +import com.ctre.phoenix6.configs.TalonFXConfiguration; import com.team900.frc2026.Constants; import com.team900.lib.drivers.CANDeviceId; import com.team900.lib.subsystems.ServoMotorSubsystemWithCanCoderConfig; import edu.wpi.first.math.util.Units; public class HoodConstants { - // TODO: in static just do khoodconfig. and then try to fill out as many of the fields with the - // info you have + public static ServoMotorSubsystemWithCanCoderConfig kHoodConfig = new ServoMotorSubsystemWithCanCoderConfig(); - // this should all lowkey go into the khoodconfig bc none of the below constants are actually - // used - public static final CANDeviceId kHoodTalonCanID = - new CANDeviceId(30, Constants.kCanBusCanivoreMech); - public static final double kHoodGearRatio = 0; - // TODO: what should this even be what - public static final double kHoodRotorMaxPosition = 0; - public static final double kHoodRotorMinPosition = 0; + public static final double kHoodGearRatio = 15.625; public static final double kHoodToleranceRadians = 0.1; + // TODO: Update these values with tunerX public static final double kHoodMinPositionRadians = 0.0; - public static final double kHoodMaxPositionRadians = - Units.rotationsToRadians(kHoodRotorMaxPosition * kHoodGearRatio); + public static final double kHoodMaxPositionRadians = Units.degreesToRadians(45.0); public static final double kHoodZeroedAngleDegrees = 15; - public static final double kHoodEpsilon = Units.degreesToRadians(1.0); public static final double kHoodShootingEpsilon = Units.degreesToRadians(5.0); - public static final double kHoodStowTrenchPositionRadians = 15.0; + + static { + kHoodConfig.name = "Hood"; + // TODO: Get hood talon motor CAN ID and update, cancoder is correct + kHoodConfig.talonCANID = new CANDeviceId(29, Constants.kCanBusCanivoreMech); + kHoodConfig.canCoderConfig.CANID = new CANDeviceId(30, Constants.kCanBusCanivoreMech); + kHoodConfig.fxConfig = new TalonFXConfiguration(); + kHoodConfig.fxConfig.OpenLoopRamps = Constants.makeDefaultOpenLoopRampConfig(); + kHoodConfig.unitToRotorRatio = 2.0 * Math.PI / kHoodGearRatio; + kHoodConfig.cancoderToUnitsRatio = 2.0 * Math.PI; + kHoodConfig.kMinPositionUnits = kHoodMinPositionRadians; + kHoodConfig.kMaxPositionUnits = kHoodMaxPositionRadians; + } } From b10d2005ad5c485285dcf71b98641b19c9dd6e72 Mon Sep 17 00:00:00 2001 From: Vidhatu Patel <62958219+Kemchobro@users.noreply.github.com> Date: Tue, 3 Mar 2026 23:26:48 -0500 Subject: [PATCH 2/8] added hood sim constants and ratios --- .../subsystems/drive/DriveConstants.java | 2 +- .../subsystems/handoff/HandoffConstants.java | 3 + .../subsystems/hood/HoodConstants.java | 94 ++++++++++++++++--- .../subsystems/shooter/ShooterConstants.java | 3 +- .../spindexer/SpindexerConstants.java | 2 +- 5 files changed, 87 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/team900/frc2026/subsystems/drive/DriveConstants.java b/src/main/java/com/team900/frc2026/subsystems/drive/DriveConstants.java index df62517e..d2ca46b1 100644 --- a/src/main/java/com/team900/frc2026/subsystems/drive/DriveConstants.java +++ b/src/main/java/com/team900/frc2026/subsystems/drive/DriveConstants.java @@ -48,7 +48,7 @@ public class DriveConstants { // PathPlanner config constants public static final double ROBOT_MASS_KG = Units.lbsToKilograms(140); public static final double ROBOT_MOI = 5.645; - public static final double WHEEL_COF = 0.8; + public static final double WHEEL_COF = 1; public static final double MAX_STEER_VEL_RAD_PER_SEC = 2 * Math.PI; public static final RobotConfig PP_CONFIG = new RobotConfig( diff --git a/src/main/java/com/team900/frc2026/subsystems/handoff/HandoffConstants.java b/src/main/java/com/team900/frc2026/subsystems/handoff/HandoffConstants.java index 19baff53..793e5220 100644 --- a/src/main/java/com/team900/frc2026/subsystems/handoff/HandoffConstants.java +++ b/src/main/java/com/team900/frc2026/subsystems/handoff/HandoffConstants.java @@ -22,6 +22,7 @@ public class HandoffConstants { kHandoffConfig.fxConfig = new TalonFXConfiguration(); kHandoffConfig.fxConfig.OpenLoopRamps = Constants.makeDefaultOpenLoopRampConfig(); + // TODO: experimentally find the current limits which we need kHandoffConfig.fxConfig.CurrentLimits.StatorCurrentLimit = 80; kHandoffConfig.fxConfig.CurrentLimits.StatorCurrentLimitEnable = true; kHandoffConfig.fxConfig.CurrentLimits.SupplyCurrentLimit = 70; @@ -30,6 +31,8 @@ public class HandoffConstants { kHandoffConfig.fxConfig.CurrentLimits.SupplyCurrentLowerTime = 1; kHandoffConfig.fxConfig.MotorOutput.Inverted = InvertedValue.Clockwise_Positive; kHandoffConfig.fxConfig.MotorOutput.NeutralMode = NeutralModeValue.Brake; + // using arbitralily small value for not since handoff position and velocity isn't important + kHandoffConfig.momentOfInertia = 0.00042474; } public static final double kHandoffGearRatio = 1; diff --git a/src/main/java/com/team900/frc2026/subsystems/hood/HoodConstants.java b/src/main/java/com/team900/frc2026/subsystems/hood/HoodConstants.java index 23df07cf..f79e2e4b 100644 --- a/src/main/java/com/team900/frc2026/subsystems/hood/HoodConstants.java +++ b/src/main/java/com/team900/frc2026/subsystems/hood/HoodConstants.java @@ -1,32 +1,98 @@ package com.team900.frc2026.subsystems.hood; +import com.ctre.phoenix6.signals.FeedbackSensorSourceValue; +import com.ctre.phoenix6.signals.GravityTypeValue; +import com.ctre.phoenix6.signals.InvertedValue; +import com.ctre.phoenix6.signals.NeutralModeValue; +import com.ctre.phoenix6.signals.SensorDirectionValue; +import com.ctre.phoenix6.signals.StaticFeedforwardSignValue; import com.team900.frc2026.Constants; +import com.team900.frc2026.Constants.Gains; import com.team900.lib.drivers.CANDeviceId; +import com.team900.lib.subsystems.CanCoderConfig; import com.team900.lib.subsystems.ServoMotorSubsystemWithCanCoderConfig; import edu.wpi.first.math.util.Units; public class HoodConstants { - // TODO: in static just do khoodconfig. and then try to fill out as many of the fields with the - // info you have - public static ServoMotorSubsystemWithCanCoderConfig kHoodConfig = - new ServoMotorSubsystemWithCanCoderConfig(); - // this should all lowkey go into the khoodconfig bc none of the below constants are actually - // used - public static final CANDeviceId kHoodTalonCanID = - new CANDeviceId(30, Constants.kCanBusCanivoreMech); - public static final double kHoodGearRatio = 0; - // TODO: what should this even be what - public static final double kHoodRotorMaxPosition = 0; + public static final Gains COMP_GAINS = new Gains(0, 0, 0, 0, 0, 0, 0); + public static final double kHoodGearRatio = 15.625 * 170. / 10.; + + public static final double kHoodRotorMaxPosition = + Units.radiansToRotations(kHoodGearRatio / kHoodGearRatio); public static final double kHoodRotorMinPosition = 0; public static final double kHoodToleranceRadians = 0.1; - public static final double kHoodMinPositionRadians = 0.0; - public static final double kHoodMaxPositionRadians = - Units.rotationsToRadians(kHoodRotorMaxPosition * kHoodGearRatio); + public static final double kHoodMinPositionRadians = Math.PI / 12; + public static final double kHoodMaxPositionRadians = Math.PI / 4; public static final double kHoodZeroedAngleDegrees = 15; public static final double kHoodEpsilon = Units.degreesToRadians(1.0); public static final double kHoodShootingEpsilon = Units.degreesToRadians(5.0); public static final double kHoodStowTrenchPositionRadians = 15.0; + + public static ServoMotorSubsystemWithCanCoderConfig kHoodConfig = + new ServoMotorSubsystemWithCanCoderConfig(); + public static CanCoderConfig kHoodCanCoderConfig = new CanCoderConfig(); + + static { + // subsystem configs + kHoodConfig.name = "Hood"; + + kHoodConfig.cancoderToUnitsRatio = 170. / 10.; + kHoodConfig.isFusedCancoder = true; + kHoodConfig.kMaxPositionUnits = Math.PI / 4; + kHoodConfig.kMinPositionUnits = Math.PI / 12; + kHoodConfig.momentOfInertia = 0.0255356814; + kHoodConfig.talonCANID = new CANDeviceId(30, Constants.kCanBusCanivoreMech); + kHoodConfig.unitToRotorRatio = 15.625 * 170. / 10.; + + // configs for sim + kHoodConfig.ratioForSim = kHoodGearRatio; + kHoodConfig.cancoderUnitsForSim = 1; + + // cancoder config TODO: add the freaking cancoder debicve id + kHoodCanCoderConfig.CANID = new CANDeviceId(0, Constants.kCanBusCanivoreMech); + kHoodCanCoderConfig.config.MagnetSensor.AbsoluteSensorDiscontinuityPoint = 1; + kHoodCanCoderConfig.config.MagnetSensor.MagnetOffset = 0; + kHoodCanCoderConfig.config.MagnetSensor.SensorDirection = + SensorDirectionValue.Clockwise_Positive; + + // fxConfig + kHoodConfig.fxConfig.CurrentLimits.StatorCurrentLimit = 150; + kHoodConfig.fxConfig.CurrentLimits.StatorCurrentLimitEnable = true; + kHoodConfig.fxConfig.CurrentLimits.SupplyCurrentLimit = 80; + kHoodConfig.fxConfig.CurrentLimits.SupplyCurrentLimitEnable = true; + kHoodConfig.fxConfig.CurrentLimits.SupplyCurrentLowerLimit = 40; + kHoodConfig.fxConfig.CurrentLimits.SupplyCurrentLowerTime = 1; + + kHoodConfig.fxConfig.Feedback.FeedbackRemoteSensorID = + kHoodCanCoderConfig.CANID.getDeviceNumber(); + kHoodConfig.fxConfig.Feedback.FeedbackRotorOffset = 0; + kHoodConfig.fxConfig.Feedback.FeedbackSensorSource = + FeedbackSensorSourceValue.FusedCANcoder; + kHoodConfig.fxConfig.Feedback.RotorToSensorRatio = kHoodConfig.getCanCodertoRotorRatio(); + kHoodConfig.fxConfig.Feedback.SensorToMechanismRatio = 170. / 10.; + + kHoodConfig.fxConfig.MotorOutput.ControlTimesyncFreqHz = 500; + kHoodConfig.fxConfig.MotorOutput.Inverted = InvertedValue.CounterClockwise_Positive; + kHoodConfig.fxConfig.MotorOutput.NeutralMode = NeutralModeValue.Coast; + + kHoodConfig.fxConfig.Slot0.GravityType = GravityTypeValue.Arm_Cosine; + kHoodConfig.fxConfig.Slot0.StaticFeedforwardSign = + StaticFeedforwardSignValue.UseVelocitySign; + kHoodConfig.fxConfig.Slot0.kA = COMP_GAINS.ffkA(); + kHoodConfig.fxConfig.Slot0.kD = COMP_GAINS.kD(); + kHoodConfig.fxConfig.Slot0.kG = COMP_GAINS.ffkG(); + kHoodConfig.fxConfig.Slot0.kI = COMP_GAINS.kI(); + kHoodConfig.fxConfig.Slot0.kP = COMP_GAINS.kP(); + kHoodConfig.fxConfig.Slot0.kS = COMP_GAINS.ffkS(); + kHoodConfig.fxConfig.Slot0.kV = COMP_GAINS.ffkV(); + + kHoodConfig.fxConfig.SoftwareLimitSwitch.ForwardSoftLimitThreshold = + kHoodRotorMaxPosition - 3; + kHoodConfig.fxConfig.SoftwareLimitSwitch.ForwardSoftLimitEnable = true; + kHoodConfig.fxConfig.SoftwareLimitSwitch.ReverseSoftLimitThreshold = kHoodRotorMinPosition; + kHoodConfig.fxConfig.SoftwareLimitSwitch.ReverseSoftLimitEnable = true; + } } diff --git a/src/main/java/com/team900/frc2026/subsystems/shooter/ShooterConstants.java b/src/main/java/com/team900/frc2026/subsystems/shooter/ShooterConstants.java index 5e4fd7b1..7e19c1f8 100644 --- a/src/main/java/com/team900/frc2026/subsystems/shooter/ShooterConstants.java +++ b/src/main/java/com/team900/frc2026/subsystems/shooter/ShooterConstants.java @@ -18,7 +18,8 @@ public class ShooterConstants { kShooterConfig.fxConfig = new TalonFXConfiguration(); kShooterConfig.fxConfig.OpenLoopRamps = Constants.makeDefaultOpenLoopRampConfig(); kShooterConfig.followers = new FollowerConfig[] {new FollowerConfig()}; - kShooterConfig.followers[0].config.talonCANID = new CANDeviceId(56, Constants.kCanBusCanivoreMech); + kShooterConfig.followers[0].config.talonCANID = + new CANDeviceId(56, Constants.kCanBusCanivoreMech); kShooterConfig.followers[0].config.fxConfig = new TalonFXConfiguration(); } diff --git a/src/main/java/com/team900/frc2026/subsystems/spindexer/SpindexerConstants.java b/src/main/java/com/team900/frc2026/subsystems/spindexer/SpindexerConstants.java index ea417f5f..b6d0882c 100644 --- a/src/main/java/com/team900/frc2026/subsystems/spindexer/SpindexerConstants.java +++ b/src/main/java/com/team900/frc2026/subsystems/spindexer/SpindexerConstants.java @@ -14,7 +14,7 @@ public class SpindexerConstants { static { kSpindexerConfig.name = "Spindexer"; kSpindexerConfig.talonCANID = new CANDeviceId(50, Constants.kCanBusCanivoreMech); - // 12t:24t 16t:80t overall: 10:1 + // 12t:24t 16t:80t overall: 10:1 kSpindexerConfig.unitToRotorRatio = 10.0; kSpindexerConfig.fxConfig = new TalonFXConfiguration(); From cab31ea0234b3c8a479ac958ca1ecc1d58eebd05 Mon Sep 17 00:00:00 2001 From: Vidhatu Patel <62958219+Kemchobro@users.noreply.github.com> Date: Tue, 3 Mar 2026 23:28:08 -0500 Subject: [PATCH 3/8] forgot about unit conversion --- .../java/com/team900/frc2026/subsystems/hood/HoodConstants.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/team900/frc2026/subsystems/hood/HoodConstants.java b/src/main/java/com/team900/frc2026/subsystems/hood/HoodConstants.java index f79e2e4b..ecf69512 100644 --- a/src/main/java/com/team900/frc2026/subsystems/hood/HoodConstants.java +++ b/src/main/java/com/team900/frc2026/subsystems/hood/HoodConstants.java @@ -28,7 +28,7 @@ public class HoodConstants { public static final double kHoodEpsilon = Units.degreesToRadians(1.0); public static final double kHoodShootingEpsilon = Units.degreesToRadians(5.0); - + //TODO: find this experimetnatlly public static final double kHoodStowTrenchPositionRadians = 15.0; public static ServoMotorSubsystemWithCanCoderConfig kHoodConfig = From 1abf8ccc86521e336a082eb1afd44d7d65395922 Mon Sep 17 00:00:00 2001 From: Aarush Jain Date: Wed, 4 Mar 2026 00:04:20 -0500 Subject: [PATCH 4/8] can id fix --- .../team900/frc2026/subsystems/hood/HoodConstants.java | 8 ++++---- .../frc2026/subsystems/turret/TurretConstants.java | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/team900/frc2026/subsystems/hood/HoodConstants.java b/src/main/java/com/team900/frc2026/subsystems/hood/HoodConstants.java index 23aa3447..b3f5ed35 100644 --- a/src/main/java/com/team900/frc2026/subsystems/hood/HoodConstants.java +++ b/src/main/java/com/team900/frc2026/subsystems/hood/HoodConstants.java @@ -35,7 +35,7 @@ public class HoodConstants { public static CanCoderConfig kHoodCanCoderConfig = new CanCoderConfig(); static { - // subsystem configs + // subsystem configs, TODO: add the freaking talon debicve id kHoodConfig.name = "Hood"; kHoodConfig.cancoderToUnitsRatio = 170. / 10.; @@ -43,15 +43,15 @@ public class HoodConstants { kHoodConfig.kMaxPositionUnits = Math.PI / 4; kHoodConfig.kMinPositionUnits = Math.PI / 12; kHoodConfig.momentOfInertia = 0.0255356814; - kHoodConfig.talonCANID = new CANDeviceId(30, Constants.kCanBusCanivoreMech); + kHoodConfig.talonCANID = new CANDeviceId(0, Constants.kCanBusCanivoreMech); kHoodConfig.unitToRotorRatio = 15.625 * 170. / 10.; // configs for sim kHoodConfig.ratioForSim = kHoodGearRatio; kHoodConfig.cancoderUnitsForSim = 1; - // cancoder config TODO: add the freaking cancoder debicve id - kHoodCanCoderConfig.CANID = new CANDeviceId(0, Constants.kCanBusCanivoreMech); + // cancoder config + kHoodCanCoderConfig.CANID = new CANDeviceId(30, Constants.kCanBusCanivoreMech); kHoodCanCoderConfig.config.MagnetSensor.AbsoluteSensorDiscontinuityPoint = 1; kHoodCanCoderConfig.config.MagnetSensor.MagnetOffset = 0; kHoodCanCoderConfig.config.MagnetSensor.SensorDirection = diff --git a/src/main/java/com/team900/frc2026/subsystems/turret/TurretConstants.java b/src/main/java/com/team900/frc2026/subsystems/turret/TurretConstants.java index 123b154e..4e4a0473 100644 --- a/src/main/java/com/team900/frc2026/subsystems/turret/TurretConstants.java +++ b/src/main/java/com/team900/frc2026/subsystems/turret/TurretConstants.java @@ -44,7 +44,7 @@ public class TurretConstants { public static final double toleranceRad = 0.1; /* * - * config.Slot0.kS = 0.18; + * config.Slot0.kS = 0.18; config.Slot0.kP = 6.0; config.Slot0.kD = 0.1; config.Slot0.kV = 0.120; From 8391bb1c6b148e74354f79cc12f1a8b8fa576592 Mon Sep 17 00:00:00 2001 From: Aarush Jain Date: Wed, 4 Mar 2026 00:16:09 -0500 Subject: [PATCH 5/8] vidhatu's shooter code, somehow got deleted yesterday --- .../subsystems/shooter/ShooterConstants.java | 69 +++++++++++++++---- 1 file changed, 57 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/team900/frc2026/subsystems/shooter/ShooterConstants.java b/src/main/java/com/team900/frc2026/subsystems/shooter/ShooterConstants.java index 7e19c1f8..97e2a6d6 100644 --- a/src/main/java/com/team900/frc2026/subsystems/shooter/ShooterConstants.java +++ b/src/main/java/com/team900/frc2026/subsystems/shooter/ShooterConstants.java @@ -1,6 +1,9 @@ package com.team900.frc2026.subsystems.shooter; +import com.ctre.phoenix6.CANBus; import com.ctre.phoenix6.configs.TalonFXConfiguration; +import com.ctre.phoenix6.signals.InvertedValue; +import com.ctre.phoenix6.signals.NeutralModeValue; import com.team900.frc2026.Constants; import com.team900.lib.drivers.CANDeviceId; import com.team900.lib.subsystems.ServoMotorSubsystemWithFollowersConfig; @@ -8,20 +11,62 @@ public class ShooterConstants { - public static ServoMotorSubsystemWithFollowersConfig kShooterConfig = - new ServoMotorSubsystemWithFollowersConfig(); + + public static ServoMotorSubsystemWithFollowersConfig kShooterConfig = new ServoMotorSubsystemWithFollowersConfig(); + public static ServoMotorSubsystemWithFollowersConfig.FollowerConfig kShooterLeftConfig = new FollowerConfig(); static { - kShooterConfig.name = "Shooter"; - kShooterConfig.talonCANID = new CANDeviceId(55, Constants.kCanBusCanivoreMech); - kShooterConfig.unitToRotorRatio = 1.0; + kShooterConfig.name = "Shooter Right"; + kShooterConfig.talonCANID = new CANDeviceId(55, new CANBus("mech")); + kShooterConfig.unitToRotorRatio = 1; + + kShooterConfig.fxConfig = new TalonFXConfiguration(); kShooterConfig.fxConfig.OpenLoopRamps = Constants.makeDefaultOpenLoopRampConfig(); - kShooterConfig.followers = new FollowerConfig[] {new FollowerConfig()}; - kShooterConfig.followers[0].config.talonCANID = - new CANDeviceId(56, Constants.kCanBusCanivoreMech); - kShooterConfig.followers[0].config.fxConfig = new TalonFXConfiguration(); - } + kShooterConfig.fxConfig.CurrentLimits.StatorCurrentLimit = 150; + kShooterConfig.fxConfig.CurrentLimits.StatorCurrentLimitEnable = true; + kShooterConfig.fxConfig.CurrentLimits.SupplyCurrentLimit = 80; + kShooterConfig.fxConfig.CurrentLimits.SupplyCurrentLimitEnable = true; + kShooterConfig.fxConfig.CurrentLimits.SupplyCurrentLowerLimit = 40; + kShooterConfig.fxConfig.CurrentLimits.SupplyCurrentLowerTime = 1; + kShooterConfig.fxConfig.MotorOutput.Inverted = InvertedValue.Clockwise_Positive; + kShooterConfig.fxConfig.MotorOutput.NeutralMode = NeutralModeValue.Brake; + + kShooterConfig.fxConfig.TorqueCurrent.PeakForwardTorqueCurrent = 150; + kShooterConfig.fxConfig.TorqueCurrent.PeakReverseTorqueCurrent = 150; + + + + - public static final double kIdleRPM = 2000.0; -} + kShooterLeftConfig.config.name = "Shooter Left"; + kShooterLeftConfig.inverted = false; + kShooterLeftConfig.config.momentOfInertia = 1; + kShooterLeftConfig.config.talonCANID = new CANDeviceId(56, new CANBus("mech")); + kShooterLeftConfig.config.unitToRotorRatio = 1; + +kShooterLeftConfig.config.fxConfig = new TalonFXConfiguration(); + kShooterLeftConfig.config.fxConfig.OpenLoopRamps = Constants.makeDefaultOpenLoopRampConfig(); + kShooterLeftConfig.config.fxConfig.CurrentLimits.StatorCurrentLimit = 150; + kShooterLeftConfig.config.fxConfig.CurrentLimits.StatorCurrentLimitEnable = true; + kShooterLeftConfig.config.fxConfig.CurrentLimits.SupplyCurrentLimit = 80; + kShooterLeftConfig.config.fxConfig.CurrentLimits.SupplyCurrentLimitEnable = true; + kShooterLeftConfig.config.fxConfig.CurrentLimits.SupplyCurrentLowerLimit = 40; + kShooterLeftConfig.config.fxConfig.CurrentLimits.SupplyCurrentLowerTime = 1; + kShooterLeftConfig.config.fxConfig.MotorOutput.Inverted = InvertedValue.Clockwise_Positive; + kShooterLeftConfig.config.fxConfig.MotorOutput.NeutralMode = NeutralModeValue.Brake; + + kShooterLeftConfig.config.fxConfig.TorqueCurrent.PeakForwardTorqueCurrent = 150; + kShooterLeftConfig.config.fxConfig.TorqueCurrent.PeakReverseTorqueCurrent = 150; + + + + kShooterConfig.followers[0] = kShooterLeftConfig; + + + + } + public static final double kShooterGearRatio = 1; + public static final double kShooterDutyCycle = 0.5; + public static final double kShooterDutyCycleExhaust = -0.5; +} \ No newline at end of file From 84d277afe955411d7da036bb081d1caeca127824 Mon Sep 17 00:00:00 2001 From: Aarush Jain Date: Wed, 4 Mar 2026 00:32:23 -0500 Subject: [PATCH 6/8] figured out that code was deleted from a merge from somone yesterday --- .../frc2026/factories/ShooterFactory.java | 9 ++--- .../intake/IntakeRollerConstants.java | 34 ++++++++++++++----- .../subsystems/shooter/ShooterConstants.java | 3 ++ 3 files changed, 30 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/team900/frc2026/factories/ShooterFactory.java b/src/main/java/com/team900/frc2026/factories/ShooterFactory.java index 984b95bf..88208716 100644 --- a/src/main/java/com/team900/frc2026/factories/ShooterFactory.java +++ b/src/main/java/com/team900/frc2026/factories/ShooterFactory.java @@ -6,9 +6,8 @@ import com.team900.frc2026.RobotContainer; import com.team900.frc2026.subsystems.shooter.ShooterConstants; -import com.team900.lib.util.ShooterSetpoint; + import edu.wpi.first.wpilibj2.command.Command; -import java.util.function.Supplier; public class ShooterFactory { @@ -17,11 +16,7 @@ public class ShooterFactory { /* Commands for shooting */ public static Command idle() { - return container.getShooterSubsystem().setTorqueCurrentFOC(() -> ShooterConstants.kIdleRPM); - } - public static Command setShooterRPS(Supplier setpointSupplier) { - var shooter = container.getShooterSubsystem(); - return shooter.velocitySetpointCommand(setpointSupplier.get()::getShooterRPS); + return container.getShooterSubsystem().setTorqueCurrentFOC(ShooterConstants.IDLE_RPS); } } diff --git a/src/main/java/com/team900/frc2026/subsystems/intake/IntakeRollerConstants.java b/src/main/java/com/team900/frc2026/subsystems/intake/IntakeRollerConstants.java index 8b223e6d..90d8f263 100644 --- a/src/main/java/com/team900/frc2026/subsystems/intake/IntakeRollerConstants.java +++ b/src/main/java/com/team900/frc2026/subsystems/intake/IntakeRollerConstants.java @@ -1,24 +1,40 @@ package com.team900.frc2026.subsystems.intake; +import com.ctre.phoenix6.CANBus; import com.ctre.phoenix6.configs.TalonFXConfiguration; +import com.ctre.phoenix6.signals.InvertedValue; +import com.ctre.phoenix6.signals.NeutralModeValue; import com.team900.frc2026.Constants; import com.team900.lib.drivers.CANDeviceId; import com.team900.lib.subsystems.ServoMotorSubsystemConfig; public class IntakeRollerConstants { - public static ServoMotorSubsystemConfig kIntakeRollerConfig = new ServoMotorSubsystemConfig(); + public static ServoMotorSubsystemConfig kIntakeConfig = new ServoMotorSubsystemConfig(); static { - kIntakeRollerConfig.fxConfig = new TalonFXConfiguration(); - kIntakeRollerConfig.name = "Intake"; - kIntakeRollerConfig.talonCANID = new CANDeviceId(60, Constants.kCanBusCanivoreMech); - // Top Roller - 16t:24t 24t:15t 30t:18t overall: 0.5625:1 - // Middle Roller - 16t:24t 24t:15t 30t:18t 18t:18t overall: 0.5625:1 - // Bottom Roller - 16t:24t 24t:15t 30t:18t 36t:36t 15t:15t overall: 0.5625:1 - kIntakeRollerConfig.unitToRotorRatio = 16.0 / 24.0 * 24.0 / 15.0 * 30.0 / 18.0; - } + kIntakeConfig.name = "Intake"; + kIntakeConfig.talonCANID = new CANDeviceId(60, new CANBus("mech")); + // Top Roller - 16t:24t 24t:15t 30t:15t overall: 0.46875:1 + // Middle Roller - 16t:24t 24t:15t 30t:15t 24t:24t overall: 0.46875:1 + // Bottom Roller - 16t:24t 24t:15t 30t:15t 36t:36t 15t:15t overall: 0.46875:1 + kIntakeConfig.unitToRotorRatio = 16.0 / 24.0 * 24.0 / 15.0 * 30.0 / 15.0; + + + kIntakeConfig.fxConfig = new TalonFXConfiguration(); + kIntakeConfig.fxConfig.OpenLoopRamps = Constants.makeDefaultOpenLoopRampConfig(); + kIntakeConfig.fxConfig.CurrentLimits.StatorCurrentLimit = 80; + kIntakeConfig.fxConfig.CurrentLimits.StatorCurrentLimitEnable = true; + kIntakeConfig.fxConfig.CurrentLimits.SupplyCurrentLimit = 70; + kIntakeConfig.fxConfig.CurrentLimits.SupplyCurrentLimitEnable = true; + kIntakeConfig.fxConfig.CurrentLimits.SupplyCurrentLowerLimit = 40; + kIntakeConfig.fxConfig.CurrentLimits.SupplyCurrentLowerTime = 1; + kIntakeConfig.fxConfig.MotorOutput.Inverted = InvertedValue.Clockwise_Positive; + kIntakeConfig.fxConfig.MotorOutput.NeutralMode = NeutralModeValue.Brake; + + } + public static final double kIntakeGearRatio = 0.46875; public static final double kIntakeDutyCycle = 0.5; public static final double kIntakeDutyCycleExhaust = -0.5; } diff --git a/src/main/java/com/team900/frc2026/subsystems/shooter/ShooterConstants.java b/src/main/java/com/team900/frc2026/subsystems/shooter/ShooterConstants.java index 97e2a6d6..c8466a22 100644 --- a/src/main/java/com/team900/frc2026/subsystems/shooter/ShooterConstants.java +++ b/src/main/java/com/team900/frc2026/subsystems/shooter/ShooterConstants.java @@ -1,5 +1,7 @@ package com.team900.frc2026.subsystems.shooter; +import java.util.function.DoubleSupplier; + import com.ctre.phoenix6.CANBus; import com.ctre.phoenix6.configs.TalonFXConfiguration; import com.ctre.phoenix6.signals.InvertedValue; @@ -69,4 +71,5 @@ public class ShooterConstants { public static final double kShooterGearRatio = 1; public static final double kShooterDutyCycle = 0.5; public static final double kShooterDutyCycleExhaust = -0.5; + public static final DoubleSupplier IDLE_RPS = null; // TODO: find this experimentally } \ No newline at end of file From bcd83b1c443f8a4d2c95c4984920b547045962c1 Mon Sep 17 00:00:00 2001 From: Aarush Jain Date: Wed, 4 Mar 2026 00:34:04 -0500 Subject: [PATCH 7/8] name change for intake roller config --- .../intake/IntakeRollerConstants.java | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/team900/frc2026/subsystems/intake/IntakeRollerConstants.java b/src/main/java/com/team900/frc2026/subsystems/intake/IntakeRollerConstants.java index 90d8f263..adff84ee 100644 --- a/src/main/java/com/team900/frc2026/subsystems/intake/IntakeRollerConstants.java +++ b/src/main/java/com/team900/frc2026/subsystems/intake/IntakeRollerConstants.java @@ -10,27 +10,27 @@ public class IntakeRollerConstants { - public static ServoMotorSubsystemConfig kIntakeConfig = new ServoMotorSubsystemConfig(); + public static ServoMotorSubsystemConfig kIntakeRollerConfig = new ServoMotorSubsystemConfig(); static { - kIntakeConfig.name = "Intake"; - kIntakeConfig.talonCANID = new CANDeviceId(60, new CANBus("mech")); + kIntakeRollerConfig.name = "Intake"; + kIntakeRollerConfig.talonCANID = new CANDeviceId(60, new CANBus("mech")); // Top Roller - 16t:24t 24t:15t 30t:15t overall: 0.46875:1 // Middle Roller - 16t:24t 24t:15t 30t:15t 24t:24t overall: 0.46875:1 // Bottom Roller - 16t:24t 24t:15t 30t:15t 36t:36t 15t:15t overall: 0.46875:1 - kIntakeConfig.unitToRotorRatio = 16.0 / 24.0 * 24.0 / 15.0 * 30.0 / 15.0; - - - kIntakeConfig.fxConfig = new TalonFXConfiguration(); - kIntakeConfig.fxConfig.OpenLoopRamps = Constants.makeDefaultOpenLoopRampConfig(); - kIntakeConfig.fxConfig.CurrentLimits.StatorCurrentLimit = 80; - kIntakeConfig.fxConfig.CurrentLimits.StatorCurrentLimitEnable = true; - kIntakeConfig.fxConfig.CurrentLimits.SupplyCurrentLimit = 70; - kIntakeConfig.fxConfig.CurrentLimits.SupplyCurrentLimitEnable = true; - kIntakeConfig.fxConfig.CurrentLimits.SupplyCurrentLowerLimit = 40; - kIntakeConfig.fxConfig.CurrentLimits.SupplyCurrentLowerTime = 1; - kIntakeConfig.fxConfig.MotorOutput.Inverted = InvertedValue.Clockwise_Positive; - kIntakeConfig.fxConfig.MotorOutput.NeutralMode = NeutralModeValue.Brake; + kIntakeRollerConfig.unitToRotorRatio = 16.0 / 24.0 * 24.0 / 15.0 * 30.0 / 15.0; + + + kIntakeRollerConfig.fxConfig = new TalonFXConfiguration(); + kIntakeRollerConfig.fxConfig.OpenLoopRamps = Constants.makeDefaultOpenLoopRampConfig(); + kIntakeRollerConfig.fxConfig.CurrentLimits.StatorCurrentLimit = 80; + kIntakeRollerConfig.fxConfig.CurrentLimits.StatorCurrentLimitEnable = true; + kIntakeRollerConfig.fxConfig.CurrentLimits.SupplyCurrentLimit = 70; + kIntakeRollerConfig.fxConfig.CurrentLimits.SupplyCurrentLimitEnable = true; + kIntakeRollerConfig.fxConfig.CurrentLimits.SupplyCurrentLowerLimit = 40; + kIntakeRollerConfig.fxConfig.CurrentLimits.SupplyCurrentLowerTime = 1; + kIntakeRollerConfig.fxConfig.MotorOutput.Inverted = InvertedValue.Clockwise_Positive; + kIntakeRollerConfig.fxConfig.MotorOutput.NeutralMode = NeutralModeValue.Brake; } From 47ac9874977f6cfc27b43cae1e03e9c7e705d1ea Mon Sep 17 00:00:00 2001 From: Rex Chen Date: Thu, 12 Mar 2026 16:48:54 -0400 Subject: [PATCH 8/8] Aiming command changes someone plz look at it not trying to cook the robot --- .../frc2026/factories/HoodFactory.java | 57 ++++++++++++++++--- .../frc2026/factories/ShootingFactory.java | 42 ++++++++++++-- .../factories/SuperstructureFactory.java | 41 ++++++++++--- 3 files changed, 122 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/team900/frc2026/factories/HoodFactory.java b/src/main/java/com/team900/frc2026/factories/HoodFactory.java index 4cb45cdb..c25cd26b 100644 --- a/src/main/java/com/team900/frc2026/factories/HoodFactory.java +++ b/src/main/java/com/team900/frc2026/factories/HoodFactory.java @@ -1,31 +1,74 @@ package com.team900.frc2026.factories; import com.team900.frc2026.RobotContainer; +import com.team900.frc2026.RobotState; import com.team900.frc2026.subsystems.hood.HoodConstants; import com.team900.frc2026.subsystems.hood.HoodSubsystem; +import com.team900.lib.util.ShooterSetpoint; + import edu.wpi.first.wpilibj2.command.Command; +import edu.wpi.first.wpilibj2.command.Commands; +import edu.wpi.first.wpilibj2.command.InstantCommand; + import java.util.function.Supplier; public class HoodFactory { // Sets the hood to a fixed position in radians - public static Command setPosition(RobotContainer container, double radians) { + public static Command setPositionMotionMagicCommand(double radians, RobotContainer container) { + HoodSubsystem hood = container.getHoodSubsystem(); + return hood.motionMagicSetpointCommand(() -> radians).withName("Hood Set Position"); + } + + public static Command aimHoodToPose( + Supplier setPointSupplier, RobotContainer container) { HoodSubsystem hood = container.getHoodSubsystem(); - return hood.motionMagicSetpointCommand(() -> radians) - .withName("Hood Set Position"); + return Commands.run( + () -> + hood.setPositionRadians( + setPointSupplier.get().getHoodRadians(), + setPointSupplier.get().getHoodFF()), + hood) + .withName("Aim Hood to Pose (rad)"); } // Sets the hood to a fixed position and finishes when it arrives within the tolerance public static Command setPositionBlocking( - RobotContainer container, double radians, double tolerance) { - HoodSubsystem hood = container.getHoodSubsystem(); - return hood.motionMagicSetpointCommandBlocking(() -> radians, tolerance) + double radians, double tolerance, RobotContainer container) { + return container + .getHoodSubsystem() + .motionMagicSetpointCommandBlocking(() -> radians, tolerance) .withName("Hood Set Position Blocking"); } // Stows the hood public static Command stow(RobotContainer container) { - return setPosition(container, HoodConstants.kHoodStowTrenchPositionRadians) + return setPositionMotionMagicCommand( + HoodConstants.kHoodStowTrenchPositionRadians, container) .withName("Hood Stow"); } + + public static Command zero(RobotContainer container) { + return new InstantCommand(container.getHoodSubsystem()::disableSoftLimits) + .andThen( + container + .getHoodSubsystem() + .dutyCycleCommand(() -> -0.05) + .until(RobotState.getInstance()::getHoodHasZeroed) + .andThen(container.getHoodSubsystem()::enableSoftLimits)); + } + + public static Command pass(RobotContainer container, double tolerance) { + return container + .getHoodSubsystem() + .motionMagicSetpointCommandBlocking(() -> 0.6, tolerance) + .withName("Hood pass Position Blocking"); + } + + public static Command shoot(RobotContainer container, double tolerance) { + return container + .getHoodSubsystem() + .motionMagicSetpointCommandBlocking(() -> 0.3, tolerance) + .withName("Hood Shoot Position Blocking"); + } } diff --git a/src/main/java/com/team900/frc2026/factories/ShootingFactory.java b/src/main/java/com/team900/frc2026/factories/ShootingFactory.java index 0c95e882..afd69c24 100644 --- a/src/main/java/com/team900/frc2026/factories/ShootingFactory.java +++ b/src/main/java/com/team900/frc2026/factories/ShootingFactory.java @@ -4,14 +4,48 @@ package com.team900.frc2026.factories; +import com.team900.frc2026.RobotContainer; +import com.team900.frc2026.RobotState; +import com.team900.lib.util.ShooterSetpoint; +import edu.wpi.first.math.MathUtil; import edu.wpi.first.wpilibj2.command.Command; +import edu.wpi.first.wpilibj2.command.ParallelCommandGroup; +import java.util.function.Supplier; public class ShootingFactory { /* Commands for shooting */ - public static Command SpinBoth() { - - return null; + public static Command shoot( + Supplier setPointSupplier, RobotContainer container) { + return (new ParallelCommandGroup( + ShooterFactory.setShooterRPS(setPointSupplier, container), + SuperstructureFactory.aim(setPointSupplier, container)) + .until( + () -> + MathUtil.isNear( + setPointSupplier.get().getShooterRPS(), + container + .getShooterSubsystem() + .getCurrentVelocity(), + 1) + && MathUtil.isNear( + setPointSupplier.get().getHoodRadians(), + container + .getHoodSubsystem() + .getCurrentPosition(), + 1) + && MathUtil.isNear( + 0, + RobotState.getInstance() + .getLatestRotationRobotToHub() + .getDegrees(), + 3))) + .andThen( + new ParallelCommandGroup( + IntakeFactory.runIntake(container), + HandoffFactory.runHandoff(container), + SpindexerFactory.runSpindexer(container)) + .onlyWhile(container.getDriveCommand()::isNearTarget)); } -} +} \ No newline at end of file diff --git a/src/main/java/com/team900/frc2026/factories/SuperstructureFactory.java b/src/main/java/com/team900/frc2026/factories/SuperstructureFactory.java index b43b23a6..fd8c3747 100644 --- a/src/main/java/com/team900/frc2026/factories/SuperstructureFactory.java +++ b/src/main/java/com/team900/frc2026/factories/SuperstructureFactory.java @@ -1,18 +1,45 @@ package com.team900.frc2026.factories; +import java.util.function.Supplier; + import com.team900.frc2026.RobotContainer; +import com.team900.lib.util.ShooterSetpoint; + import edu.wpi.first.wpilibj2.command.Command; +import edu.wpi.first.wpilibj2.command.InstantCommand; +import edu.wpi.first.wpilibj2.command.ParallelCommandGroup; + +import java.util.function.Supplier; +import java.util.function.DoubleSupplier; public class SuperstructureFactory { - public static Command aimAndShootAll(RobotContainer container) { - return null; - /*Command to shoot all balls in robot (should auto aim) + public static Command aim( + Supplier setPointSupplier, + RobotContainer container, + DoubleSupplier turretRadiansFromCenter, + DoubleSupplier turretFF) { + // return null; + return new ParallelCommandGroup( + new InstantCommand(() -> container.getDriveCommand().setKAiming(true)), + HoodFactory.aimHoodToPose(setPointSupplier, container), + TurretFactory.aimTurretToPoseDegrees(container, turretRadiansFromCenter,turretFF)); + /*Command to aim at target * Aim turret - * Aim hood - * Maintain shooter and handoff speed - * Move spindexer to load to turret as needed - */ + * Aim hood */ + } + + public static Command stow(RobotContainer container) { + return new ParallelCommandGroup(HoodFactory.stow(container)); + } + + public static Command trench(RobotContainer container) { + return new ParallelCommandGroup( + HoodFactory.stow(container), IntakeFactory.deploySlapdown(container)); + } + + public static Command intakeDeploy(RobotContainer container) { + return IntakeFactory.deploySlapdown(container); } }