2222GEAR_RATIO = 9 * (83 / 18 )
2323FREQUENCY = 200
2424
25-
26- LOADCELL_CALIBRATION_MATRIX_M3554E = np .array ([
27- (- 943.401 , 4.143 , 8.825 , - 16.57 , 952.216 , 10.892 ),
28- (539.853 , 14.985 , - 1111.656 , - 0.812 , 546.9 , - 18.949 ),
29- (13.155 , 533.082 , - 4.582 , 534.843 , 10.827 , 536.327 ),
30- (0.138 , - 10.419 , 0.202 , 0.14 , 0.063 , 10.518 ),
31- (- 0.075 , 6.213 , - 0.239 , - 12.094 , 0.181 , 6.156 ),
32- (- 19.912 , 0.082 , - 20.347 , 0.022 , - 19.486 , 0.013 ),
25+ LOADCELL_MATRIX = np .array ([
26+ (- 9.817417 , - 1895.974287 , 14.899174 , - 4.333117 , - 40.684438 , 1900.65478 ),
27+ (- 32.435533 , 1129.587599 , - 5.693634 , - 2206.916117 , 14.346322 , 1086.297672 ),
28+ (- 963.721193 , - 4.911412 , - 965.891326 , - 1.404768 , - 981.000498 , 8.693936 ),
29+ (19.854122 , - 0.21849 , 0.25324 , 0.734436 , - 20.471398 , - 0.232788 ),
30+ (- 11.530613 , - 0.964467 , 22.849398 , - 0.011803 , - 11.785854 , 1.015088 ),
31+ (- 0.296284 , - 26.299567 , - 0.138142 , - 26.753995 , 0.385682 , - 25.052914 ),
3332])
3433
3534# ------------- TUNABLE FSM PARAMETERS ---------------- #
36- BODY_WEIGHT = 10 * 9.8
35+ BODY_WEIGHT = 20 * 9.8
3736
3837# STATE 1: EARLY STANCE
3938ANKLE_K_ESTANCE = 19.874
@@ -189,18 +188,27 @@ def create_simple_walking_fsm(osl: OpenSourceLeg) -> StateMachine:
189188 gear_ratio = GEAR_RATIO ,
190189 frequency = FREQUENCY ,
191190 debug_level = 0 ,
191+ torque_constant = 0.145 ,
192192 dephy_log = False ,
193193 ),
194194 }
195195
196196 sensors = {
197197 "loadcell" : NBLoadcellDAQ (
198- LOADCELL_CALIBRATION_MATRIX_M3554E ,
198+ LOADCELL_MATRIX ,
199199 tag = "loadcell" ,
200200 excitation_voltage = 5.0 ,
201201 amp_gain = [34 ] * 3 + [151 ] * 3 ,
202202 spi_bus = 1 ,
203203 ),
204+ # "joint_encoder_ankle": AS5048B(
205+ # tag="joint_encoder_ankle",
206+ # bus="/dev/i2c-2",
207+ # A1_adr_pin=False,
208+ # A2_adr_pin=False,
209+ # zero_position=0,
210+ # enable_diagnostics=False,
211+ # ),
204212 }
205213
206214 clock = SoftRealtimeLoop (dt = 1 / FREQUENCY )
@@ -217,6 +225,22 @@ def create_simple_walking_fsm(osl: OpenSourceLeg) -> StateMachine:
217225
218226 osl_fsm = create_simple_walking_fsm (osl )
219227
228+ # Zeroing the joint encoders
229+ def knee_homing_complete ():
230+ osl .joint_encoder_knee .update ()
231+ osl .joint_encoder_knee .zero_position = osl .joint_encoder_knee .counts
232+ print ("Knee homing complete!" )
233+
234+ def ankle_homing_complete ():
235+ osl .joint_encoder_ankle .update ()
236+ # The hard stop for ankle is at 30 deg from the zero position
237+ osl .joint_encoder_ankle .zero_position = osl .joint_encoder_ankle .counts - osl .joint_encoder_ankle .deg_to_counts (
238+ 30
239+ )
240+ print ("Ankle homing complete!" )
241+
242+ callbacks = {"knee" : knee_homing_complete , "ankle" : ankle_homing_complete }
243+
220244 with fsm_logger , osl , osl_fsm :
221245 osl .update ()
222246 osl .home ()
@@ -225,7 +249,8 @@ def create_simple_walking_fsm(osl: OpenSourceLeg) -> StateMachine:
225249
226250 # ankle
227251 osl .ankle .set_control_mode (mode = CONTROL_MODES .IMPEDANCE )
228- osl .ankle .set_impedance_gains ()
252+ osl .ankle .set_impedance_cc_pidf_gains ()
253+ osl .ankle .set_output_impedance ()
229254
230255 for t in clock :
231256 osl .update ()
0 commit comments