2026-01-27 18:16:23 -08:00
package frc4388.robot.subsystems.intake ;
2026-04-01 17:58:15 -06:00
import com.ctre.phoenix6.configs.CurrentLimitsConfigs ;
import com.ctre.phoenix6.configs.MotorOutputConfigs ;
import com.ctre.phoenix6.configs.TalonFXConfiguration ;
import com.ctre.phoenix6.signals.NeutralModeValue ;
2026-03-28 09:59:30 -06:00
import com.revrobotics.spark.FeedbackSensor ;
import com.revrobotics.spark.config.SparkMaxConfig ;
2026-04-04 10:27:44 -06:00
import edu.wpi.first.units.measure.AngularVelocity ;
2026-03-28 09:59:30 -06:00
import com.revrobotics.spark.config.LimitSwitchConfig.Behavior ;
import com.revrobotics.spark.config.LimitSwitchConfig.Type ;
2026-03-30 18:57:14 -06:00
import com.revrobotics.spark.config.SparkBaseConfig.IdleMode ;
2026-03-25 11:15:46 -06:00
2026-02-09 17:18:54 -08:00
import frc4388.utility.configurable.ConfigurableDouble ;
2026-01-27 18:16:23 -08:00
import frc4388.utility.status.CanDevice ;
public class IntakeConstants {
// Motor conversions
2026-02-14 10:55:51 -08:00
public static final double ARM_MOTOR_GEAR_RATIO = 125 ;
2026-02-10 17:33:39 -08:00
public static final double ROLLER_MOTOR_GEAR_RATIO = 3 ;
2026-03-30 18:57:14 -06:00
public static final ConfigurableDouble ARM_ENCODER_OFFSET = new ConfigurableDouble ( " Arm Encoder Offset " , 0 ) ;
2026-01-27 18:16:23 -08:00
2026-04-07 20:37:26 -06:00
public static final int ARM_LIMIT_SWITCH_CHANNEL = 7 ;
2026-03-28 13:30:33 -06:00
public static final ConfigurableDouble INTAKE_BOUNCE_HALF_PERIOD = new ConfigurableDouble ( " Bounce Half Period " , 5 . ) ;
2026-03-30 19:52:57 -06:00
public static final ConfigurableDouble INTAKE_BOUNCE_OUTPUT = new ConfigurableDouble ( " Bounce Output " , 0 . 1 ) ;
public static final ConfigurableDouble INTAKE_BOUNCE_MAX_OUTPUT = new ConfigurableDouble ( " Bounce Max Output " , 0 . 2 ) ;
2026-04-03 22:08:13 -06:00
public static final ConfigurableDouble INTAKE_BOUNCE_CURRENT_LIMIT = new ConfigurableDouble ( " Intake Bounce Current Limit " , 30 ) ;
2026-03-30 19:52:57 -06:00
public static final ConfigurableDouble INTAKE_BOUNCE_VELOCITY_LIMIT = new ConfigurableDouble ( " Intake Bounce Velocity Limit " , 4 ) ;
2026-03-25 11:15:46 -06:00
2026-03-31 18:53:16 -06:00
//squeeze constants
2026-04-03 22:08:13 -06:00
// public static final ConfigurableDouble INTAKE_SQUEEZE_CURRENT_LOWER_THRESHOLD = new ConfigurableDouble("Intake Squeeze Current LOWER THRESHOLD", 20);
// public static final ConfigurableDouble INTAKE_SQUEEZE_CURRENT_UPPER_THRESHOLD = new ConfigurableDouble("Intake Squeeze Current UPPER THRESHOLD", 25);
public static final ConfigurableDouble ARM_SQUEEZE_PERCENT_OUTPUT = new ConfigurableDouble ( " Arm squeeze % output " , - 0 . 2 ) ;
public static final ConfigurableDouble ARM_REDUCED_SQUEEZE_PERCENT_OUTPUT = new ConfigurableDouble ( " Arm reduce squeeze % output " , 0 . 02 ) ;
2026-04-09 19:11:53 -06:00
public static final ConfigurableDouble FIX_ARM_PERCENT_OUTPUT = new ConfigurableDouble ( " Arm encoder fix % output " , - 0 . 1 ) ;
2026-02-14 15:00:40 -07:00
2026-01-29 16:59:53 -07:00
//IDs
2026-02-09 16:03:48 -08:00
public static final CanDevice ARM_ID = new CanDevice ( " ARM " , 20 ) ;
public static final CanDevice ROLLER_ID = new CanDevice ( " INTAKE_ROLLER " , 21 ) ;
2026-03-28 13:30:33 -06:00
public static final int ARM_ENCODER_ID = 0 ;
2026-01-29 16:59:53 -07:00
2026-01-27 18:16:23 -08:00
// Limits
// 0 is the forward angle on the robot.
// negative is left, positive is right
2026-02-07 14:51:05 -07:00
//when testing the negative output of 10% made the robot put the intake up
2026-02-09 17:18:54 -08:00
// public static final Angle ARM_LIMIT_LOWER = Degrees.of(90);
// public static final Angle ARM_LIMIT_UPPER = Degrees.of(-90);
2026-03-28 15:56:54 -06:00
public static final ConfigurableDouble ARM_LIMIT_RETRACTED = new ConfigurableDouble ( " Arm angle retracted " , 0 . ) ;
2026-04-07 20:37:26 -06:00
public static final ConfigurableDouble ARM_LIMIT_EXTENDED = new ConfigurableDouble ( " Arm angle extended " , 1 . 8 ) ; //new soft limt
2026-04-09 18:19:58 -06:00
public static final ConfigurableDouble ARM_EXTEND_PERCENT_OUTPUT = new ConfigurableDouble ( " Arm extend % output " , 0 . 5 ) ;
2026-03-30 19:52:57 -06:00
public static final ConfigurableDouble ARM_RETRACT_PERCENT_OUTPUT = new ConfigurableDouble ( " Arm retract % output " , - 0 . 2 ) ;
2026-03-30 16:15:43 -06:00
2026-04-09 11:51:17 -06:00
public static final ConfigurableDouble ARM_AUTO_OUTPUT = new ConfigurableDouble ( " Arm auto output " , - 0 . 07 ) ;
2026-03-30 18:57:14 -06:00
public static final ConfigurableDouble ARM_REVERSE_ROLLER_RANGE = new ConfigurableDouble ( " Arm reverse roller range " , 1 . 17 ) ;
2026-03-28 15:56:54 -06:00
2026-04-04 10:27:44 -06:00
public static final ConfigurableDouble ROLLER_PERCENT_OUTPUT = new ConfigurableDouble ( " Roller Percent Output " , . 50 ) ;
2026-04-09 18:19:58 -06:00
public static final ConfigurableDouble ROLLER_LABUBU_GROWL_PERCENT_OUTPUT = new ConfigurableDouble ( " Roller Labubu Growl Percent Output " , . 7 ) ;
2026-04-04 13:02:50 -06:00
public static final ConfigurableDouble ROLLER_EJECT_PERCENT_OUTPUT = new ConfigurableDouble ( " Roller eject Percent Output " , - . 20 ) ;
public static final ConfigurableDouble ROLLER_IDLE_PERCENT_OUTPUT = new ConfigurableDouble ( " Roller IDLE Percent Output " , . 20 ) ;
2026-03-28 15:56:54 -06:00
public static final ConfigurableDouble ROLLER_RETRACT_PERCENT_OUTPUT = new ConfigurableDouble ( " Roller Retract Output " , . 40 ) ;
2026-04-04 10:27:44 -06:00
public static final ConfigurableDouble ROLLER_MULTIPLIER_CONST = new ConfigurableDouble ( " Roller Multiplier Constant " , 0 . 4 ) ;
2026-03-28 15:56:54 -06:00
2026-02-09 17:18:54 -08:00
// public static final ConfigurableDouble ROLL = new ConfigurableDouble("Arm angle extended", 0.25);
// public static final AngularVelocity ROLLER_MAX_VELOCITY = RotationsPerSecond.of(4.0);
// public static final AngularVelocity ROLLER_STOP = RotationsPerSecond.of(0.0);
2026-01-29 18:07:19 -07:00
2026-01-27 18:16:23 -08:00
2026-03-28 09:59:30 -06:00
// public static final Slot0Configs ARM_PID = new Slot0Configs()
// .withKP(0.08)
// .withKI(0.0)
// .withKD(0.05);
2026-01-27 18:16:23 -08:00
2026-02-17 18:53:26 -08:00
2026-01-27 18:16:23 -08:00
2026-03-28 09:59:30 -06:00
// public static ConfigurableDouble arm_kP = new ConfigurableDouble("ARM KP", 0.08);
// public static ConfigurableDouble arm_kI = new ConfigurableDouble("ARM KI", 0);
// public static ConfigurableDouble arm_kD = new ConfigurableDouble("ARM KD", 0.05);
2026-02-09 18:38:55 -08:00
2026-04-04 10:27:44 -06:00
public static double getTargetRollerSpeed ( double chassisSpeed ) {
return ROLLER_PERCENT_OUTPUT . get ( ) * ( 1 + ROLLER_MULTIPLIER_CONST . get ( ) * chassisSpeed ) ;
}
2026-02-09 18:38:55 -08:00
2026-01-27 18:16:23 -08:00
// 0 is paralell to the ground, 90 is directly up
// public static final Angle PITCH_LIMIT_UPPER = Degrees.of(90);
// public static final Angle PITCH_LIMIT_LOWER = Degrees.of(0);
// Motor configs
2026-03-28 09:59:30 -06:00
public static final SparkMaxConfig ARM_MOTOR_CONFIG = new SparkMaxConfig ( ) ;
2026-04-01 17:58:15 -06:00
public static final CanDevice ROLLER_MOTOR_ID = new CanDevice ( " INTAKE_ROLLER " , 21 ) ;
2026-03-28 09:59:30 -06:00
static {
ARM_MOTOR_CONFIG . limitSwitch
. limitSwitchPositionSensor ( FeedbackSensor . kPrimaryEncoder )
2026-03-28 15:56:54 -06:00
. forwardLimitSwitchType ( Type . kNormallyOpen )
. forwardLimitSwitchTriggerBehavior ( Behavior . kKeepMovingMotor )
2026-04-07 20:37:26 -06:00
. reverseLimitSwitchType ( Type . kNormallyOpen )
// .reverseLimitSwitchPosition(0)
. reverseLimitSwitchTriggerBehavior ( Behavior . kKeepMovingMotor ) ;
2026-03-30 18:57:14 -06:00
ARM_MOTOR_CONFIG . idleMode ( IdleMode . kBrake ) ;
2026-04-01 17:58:15 -06:00
// ROLLER_MOTOR_CONFIG.idleMode(IdleMode.kCoast);
2026-03-28 09:59:30 -06:00
}
// public static final TalonFXConfiguration ARM_MOTOR_CONFIG = new TalonFXConfiguration()
// .withCurrentLimits(
// new CurrentLimitsConfigs()
// .withStatorCurrentLimit(15) // TODO: tune???
// .withStatorCurrentLimitEnable(true)
// ).withMotorOutput(
// new MotorOutputConfigs()
// .withNeutralMode(NeutralModeValue.Brake) // Must be break because this has to be accurate
2026-04-02 18:27:51 -06:00
// .withDutyCycleNeutralDeadband(0.04) // This sets the minimum output of motor so if its less than 4% it wont move
2026-03-28 09:59:30 -06:00
// );
2026-04-01 17:58:15 -06:00
public static final TalonFXConfiguration ROLLER_MOTOR_CONFIG = new TalonFXConfiguration ( )
. withCurrentLimits (
new CurrentLimitsConfigs ( )
. withStatorCurrentLimit ( 40 ) // TODO: tune???
. withStatorCurrentLimitEnable ( true )
) . withMotorOutput (
new MotorOutputConfigs ( )
. withNeutralMode ( NeutralModeValue . Coast ) // Must be coast because this is spinny spinny
2026-04-02 18:27:51 -06:00
. withDutyCycleNeutralDeadband ( 0 . 04 ) // This sets the minimum output of motor so if its less than 4% it wont move
2026-04-01 17:58:15 -06:00
) ;
2026-01-27 18:16:23 -08:00
}