22
33import com .ctre .phoenix6 .BaseStatusSignal ;
44import com .ctre .phoenix6 .StatusSignal ;
5+ import com .ctre .phoenix6 .configs .HardwareLimitSwitchConfigs ;
6+ import com .ctre .phoenix6 .configs .Slot0Configs ;
7+ import com .ctre .phoenix6 .controls .PositionVoltage ;
58import com .ctre .phoenix6 .controls .TorqueCurrentFOC ;
69import com .ctre .phoenix6 .controls .VoltageOut ;
710import com .ctre .phoenix6 .hardware .CANrange ;
@@ -22,6 +25,7 @@ public class ClawIOReal implements ClawIO {
2225 protected TalonFX rollerTalonFX ;
2326 private CANrange firstCoralCANRange ;
2427 private CANrange secondCoralCANRange ;
28+ private CANrange scoringCANRange ;
2529
2630 private TorqueCurrentFOC roller_c_request =
2731 new TorqueCurrentFOC (EndEffectorConstants .CLAW_HOLD_ALGAE_AMPS );
@@ -46,12 +50,26 @@ public ClawIOReal() {
4650 new CANrange (EndEffectorConstants .FIRST_CORAL_CANRANGE_ID , Constants .MISC_CANIVORE );
4751 secondCoralCANRange =
4852 new CANrange (EndEffectorConstants .SECOND_CORAL_CANRANGE_ID , Constants .MISC_CANIVORE );
53+ scoringCANRange = new CANrange (34 , Constants .MISC_CANIVORE );
4954 PhoenixUtil .tryUntilOk (
5055 5 , () -> firstCoralCANRange .getConfigurator ().apply (EndEffectorConstants .CANRANGE_CONFIG ));
5156 PhoenixUtil .tryUntilOk (
5257 5 , () -> secondCoralCANRange .getConfigurator ().apply (EndEffectorConstants .CANRANGE_CONFIG ));
5358 PhoenixUtil .tryUntilOk (
54- 5 , () -> rollerTalonFX .getConfigurator ().apply (EndEffectorConstants .ROLLER_TALON_CONFIG ));
59+ 5 , () -> scoringCANRange .getConfigurator ().apply (EndEffectorConstants .CANRANGE_CONFIG ));
60+ PhoenixUtil .tryUntilOk (
61+ 5 ,
62+ () ->
63+ rollerTalonFX
64+ .getConfigurator ()
65+ .apply (
66+ EndEffectorConstants .ROLLER_TALON_CONFIG
67+ .withHardwareLimitSwitch (
68+ new HardwareLimitSwitchConfigs ()
69+ .withReverseLimitAutosetPositionEnable (true )
70+ .withReverseLimitAutosetPositionValue (-100 )
71+ .withReverseLimitRemoteCANrange (scoringCANRange ))
72+ .withSlot0 (new Slot0Configs ().withKP (100 ))));
5573
5674 rollerVelocityRPS = rollerTalonFX .getRotorVelocity ();
5775 rollerAppliedVolts = rollerTalonFX .getMotorVoltage ();
@@ -120,6 +138,16 @@ public void setRollerVoltage(double voltage) {
120138 rollerTalonFX .setControl (roller_m_request .withOutput (voltage ));
121139 }
122140
141+ @ Override
142+ public void setRollerPosition (double position ) {
143+ rollerTalonFX .setPosition (0 );
144+ }
145+
146+ @ Override
147+ public void setRollerTargetPosition (double position ) {
148+ rollerTalonFX .setControl (new PositionVoltage (position ));
149+ }
150+
123151 @ Override
124152 public boolean checkRollerStalled () {
125153 return debouncerAlgae .calculate (
0 commit comments