@@ -27,8 +27,8 @@ class WristComponent:
2727 MAXIMUM_ELEVATION = math .radians (0 ) + COM_DIFFERENCE
2828 NEUTRAL_ANGLE = math .radians (- 90.0 )
2929
30- WRIST_MAX_VEL = math .radians (180 .0 )
31- WRIST_MAX_ACC = math .radians (360 .0 )
30+ WRIST_MAX_VEL = math .radians (720 .0 )
31+ WRIST_MAX_ACC = math .radians (1080 .0 )
3232 wrist_gear_ratio = 208.206
3333 TOLERANCE = math .radians (3.0 )
3434 VEL_TOLERANCE = math .radians (6.0 )
@@ -63,8 +63,8 @@ def __init__(self, mech_root: wpilib.MechanismRoot2d):
6363 # theoretical max pos 0.01 max velocity 0.05
6464 self .pid = PIDController (Kp = 19.508 , Ki = 0 , Kd = 0.048599 )
6565
66- # https://www.reca.lc/arm?armMass=%7B%22s%22%3A8 %2C%22u%22%3A%22kg%22%7D&comLength=%7B%22s%22%3A0.15 %2C%22u%22%3A%22m%22%7D¤tLimit=%7B%22s%22%3A40 %2C%22u%22%3A%22A%22%7D&efficiency=90&endAngle=%7B%22s%22%3A-10%2C%22u%22%3A%22deg%22%7D&iterationLimit=10000&motor=%7B%22quantity%22%3A1%2C%22name%22%3A%22NEO%22%7D&ratio=%7B%22magnitude%22%3A432 %2C%22ratioType%22%3A%22Reduction%22%7D&startAngle=%7B%22s%22%3A-110 %2C%22u%22%3A%22deg%22%7D
67- self .wrist_ff = ArmFeedforward (kS = 0.42619 , kG = 0.48 , kV = 4.10 , kA = 0.02 )
66+ # https://www.reca.lc/arm?armMass=%7B%22s%22%3A12 %2C%22u%22%3A%22kg%22%7D&comLength=%7B%22s%22%3A0.24044 %2C%22u%22%3A%22m%22%7D¤tLimit=%7B%22s%22%3A80 %2C%22u%22%3A%22A%22%7D&efficiency=90&endAngle=%7B%22s%22%3A-10%2C%22u%22%3A%22deg%22%7D&iterationLimit=10000&motor=%7B%22quantity%22%3A1%2C%22name%22%3A%22NEO%22%7D&ratio=%7B%22magnitude%22%3A208.206 %2C%22ratioType%22%3A%22Reduction%22%7D&startAngle=%7B%22s%22%3A-112 %2C%22u%22%3A%22deg%22%7D
67+ self .wrist_ff = ArmFeedforward (kS = 0.42619 , kG = 0.45 , kV = 4.06 , kA = 0.01 )
6868
6969 wrist_config .encoder .positionConversionFactor (
7070 math .tau * (1 / self .wrist_gear_ratio )
@@ -78,6 +78,7 @@ def __init__(self, mech_root: wpilib.MechanismRoot2d):
7878 self .motor_encoder = self .motor .getEncoder ()
7979
8080 self .desired_state = TrapezoidProfile .State (WristComponent .NEUTRAL_ANGLE , 0.0 )
81+ self .tracked_state = self .desired_state
8182
8283 self .last_setpoint_update_time = wpilib .Timer .getFPGATimestamp ()
8384 self .initial_state = TrapezoidProfile .State (
@@ -134,6 +135,18 @@ def shoot_angle_deg(self) -> float:
134135 def current_velocity (self ) -> float :
135136 return self .motor_encoder .getVelocity ()
136137
138+ @feedback
139+ def current_target_velocity (self ) -> float :
140+ return self .tracked_state .velocity
141+
142+ @feedback
143+ def current_target_position (self ) -> float :
144+ return self .tracked_state .position
145+
146+ @feedback
147+ def current_input (self ) -> float :
148+ return self .motor .getAppliedOutput ()
149+
137150 @feedback
138151 def at_setpoint (self ) -> bool :
139152 return (
@@ -174,15 +187,18 @@ def at_limit(self) -> bool:
174187 return self .motor .getReverseLimitSwitch ().get ()
175188
176189 def execute (self ) -> None :
177- tracked_state = self .wrist_profile .calculate (
190+ self . tracked_state = self .wrist_profile .calculate (
178191 wpilib .Timer .getFPGATimestamp () - self .last_setpoint_update_time ,
179192 self .initial_state ,
180193 self .desired_state ,
181194 )
182- ff = self .wrist_ff .calculate (tracked_state .position , tracked_state .velocity )
195+
196+ ff = self .wrist_ff .calculate (
197+ self .tracked_state .position , self .tracked_state .velocity
198+ )
183199
184200 self .motor .setVoltage (
185- self .pid .calculate (self .inclination (), tracked_state .position ) + ff
201+ self .pid .calculate (self .inclination (), self . tracked_state .position ) + ff
186202 )
187203
188204 self .wrist_ligament .setAngle (self .shooter_FOR_inclination_deg ())
0 commit comments