2121
2222
2323class WristComponent :
24- ENCODER_ZERO_OFFSET = 4.011863
25- MAXIMUM_DEPRESSION = math .radians (- 112.0 )
26- MAXIMUM_ELEVATION = math .radians (0 )
27- NEUTRAL_ANGLE = math .radians (- 90.0 )
24+ ENCODER_ZERO_OFFSET = 3.46463832679
25+ COM_DIFFERENCE = 0.54722467321
26+ MAXIMUM_DEPRESSION = math .radians (- 112.0 ) + COM_DIFFERENCE
27+ MAXIMUM_ELEVATION = math .radians (0 ) + COM_DIFFERENCE
28+ NEUTRAL_ANGLE = math .radians (- 90.0 ) + COM_DIFFERENCE
2829
2930 WRIST_MAX_VEL = math .radians (180.0 )
3031 WRIST_MAX_ACC = math .radians (360.0 )
@@ -37,6 +38,10 @@ def __init__(self, mech_root: wpilib.MechanismRoot2d):
3738 "wrist" , length = 0.5 , angle = 0 , color = wpilib .Color8Bit (wpilib .Color .kYellow )
3839 )
3940
41+ self .wrist_COM_ligament = mech_root .appendLigament (
42+ "wrist_COM" , length = 0.5 , angle = 0 , color = wpilib .Color8Bit (wpilib .Color .kBlue )
43+ )
44+
4045 self .wrist_encoder = DutyCycleEncoder (DioChannel .WRIST_ENCODER , math .tau , 0 )
4146 configure_through_bore_encoder (self .wrist_encoder )
4247 self .wrist_encoder .setInverted (False )
@@ -117,6 +122,10 @@ def inclination(self) -> float:
117122 def inclination_deg (self ) -> float :
118123 return math .degrees (self .inclination ())
119124
125+ @feedback
126+ def test_inclination (self ) -> float :
127+ return math .degrees (self .inclination () - self .COM_DIFFERENCE )
128+
120129 @feedback
121130 def shoot_angle_deg (self ) -> float :
122131 return self .inclination_deg () + 90
@@ -169,5 +178,9 @@ def execute(self) -> None:
169178 self .pid .calculate (self .inclination (), tracked_state .position ) + ff
170179 )
171180
172- self .wrist_ligament .setAngle (self .inclination_deg ())
181+ self .wrist_ligament .setAngle (
182+ self .inclination_deg () - math .degrees (WristComponent .COM_DIFFERENCE )
183+ )
184+
185+ self .wrist_COM_ligament .setAngle (self .inclination_deg ())
173186 # self.wrist_ligament.setAngle(math.degrees(desired_state.position))
0 commit comments