@@ -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,14 @@ 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+
137146 @feedback
138147 def current_input (self ) -> float :
139148 return self .motor .getAppliedOutput ()
@@ -178,15 +187,18 @@ def at_limit(self) -> bool:
178187 return self .motor .getReverseLimitSwitch ().get ()
179188
180189 def execute (self ) -> None :
181- tracked_state = self .wrist_profile .calculate (
190+ self . tracked_state = self .wrist_profile .calculate (
182191 wpilib .Timer .getFPGATimestamp () - self .last_setpoint_update_time ,
183192 self .initial_state ,
184193 self .desired_state ,
185194 )
186- 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+ )
187199
188200 self .motor .setVoltage (
189- self .pid .calculate (self .inclination (), tracked_state .position ) + ff
201+ self .pid .calculate (self .inclination (), self . tracked_state .position ) + ff
190202 )
191203
192204 self .wrist_ligament .setAngle (self .shooter_FOR_inclination_deg ())
0 commit comments