26
26
)
27
27
28
28
29
- def factory_fn (params : Dict [str , Array ], verbose : bool = False ) -> Tuple [Callable , Callable ]:
29
+ def factory_fn (
30
+ params : Dict [str , Array ], verbose : bool = False
31
+ ) -> Tuple [Callable , Callable ]:
30
32
"""
31
33
Factory function for the planar HSA.
32
34
Args:
@@ -45,7 +47,9 @@ def factory_fn(params: Dict[str, Array], verbose: bool = False) -> Tuple[Callabl
45
47
sys_helpers ,
46
48
) = planar_hsa .factory (sym_exp_filepath , strain_selector )
47
49
dynamical_matrices_fn = partial (dynamical_matrices_fn , params )
48
- forward_kinematics_end_effector_fn = jit (partial (forward_kinematics_end_effector_fn , params ))
50
+ forward_kinematics_end_effector_fn = jit (
51
+ partial (forward_kinematics_end_effector_fn , params )
52
+ )
49
53
jacobian_end_effector_fn = jit (partial (jacobian_end_effector_fn , params ))
50
54
51
55
def residual_fn (q : Array , phi : Array ) -> Array :
@@ -64,7 +68,9 @@ def residual_fn(q: Array, phi: Array) -> Array:
64
68
print ("Compiling jac_residual_fn..." )
65
69
print (jac_residual_fn (jnp .zeros ((3 ,)), jnp .zeros ((2 ,))))
66
70
67
- def phi2q_static_model_fn (phi : Array , q0 : Array = jnp .zeros ((3 , ))) -> Tuple [Array , Dict [str , Array ]]:
71
+ def phi2q_static_model_fn (
72
+ phi : Array , q0 : Array = jnp .zeros ((3 ,))
73
+ ) -> Tuple [Array , Dict [str , Array ]]:
68
74
"""
69
75
A static model mapping the motor angles to the planar HSA configuration using scipy.optimize.minimize.
70
76
Arguments:
@@ -82,7 +88,12 @@ def phi2q_static_model_fn(phi: Array, q0: Array = jnp.zeros((3, ))) -> Tuple[Arr
82
88
options = {"disp" : True } if verbose else None ,
83
89
)
84
90
if verbose :
85
- print ("Optimization converged after" , sol .nit , "iterations with residual" , sol .fun )
91
+ print (
92
+ "Optimization converged after" ,
93
+ sol .nit ,
94
+ "iterations with residual" ,
95
+ sol .fun ,
96
+ )
86
97
87
98
# configuration that minimizes the residual
88
99
q = jnp .array (sol .x )
@@ -95,7 +106,9 @@ def phi2q_static_model_fn(phi: Array, q0: Array = jnp.zeros((3, ))) -> Tuple[Arr
95
106
96
107
return q , aux
97
108
98
- def phi2chi_static_model_fn (phi : Array , q0 : Array = jnp .zeros ((3 , ))) -> Tuple [Array , Dict [str , Array ]]:
109
+ def phi2chi_static_model_fn (
110
+ phi : Array , q0 : Array = jnp .zeros ((3 ,))
111
+ ) -> Tuple [Array , Dict [str , Array ]]:
99
112
"""
100
113
A static model mapping the motor angles to the planar end-effector pose.
101
114
Arguments:
@@ -110,7 +123,9 @@ def phi2chi_static_model_fn(phi: Array, q0: Array = jnp.zeros((3, ))) -> Tuple[A
110
123
aux ["chi" ] = chi
111
124
return chi , aux
112
125
113
- def jac_phi2chi_static_model_fn (phi : Array , q0 : Array = jnp .zeros ((3 , ))) -> Tuple [Array , Dict [str , Array ]]:
126
+ def jac_phi2chi_static_model_fn (
127
+ phi : Array , q0 : Array = jnp .zeros ((3 ,))
128
+ ) -> Tuple [Array , Dict [str , Array ]]:
114
129
"""
115
130
Compute the Jacobian between the actuation space and the task-space.
116
131
Arguments:
@@ -157,17 +172,12 @@ def jac_phi2chi_static_model_fn(phi: Array, q0: Array = jnp.zeros((3, ))) -> Tup
157
172
phi = jnp .array ([1.0 , 1.0 ])
158
173
case _:
159
174
rng , subkey = random .split (rng )
160
- phi = random .uniform (
161
- subkey ,
162
- phi_max .shape ,
163
- minval = 0.0 ,
164
- maxval = phi_max
165
- )
175
+ phi = random .uniform (subkey , phi_max .shape , minval = 0.0 , maxval = phi_max )
166
176
167
177
print ("i" , i )
168
178
169
179
chi , aux = phi2chi_static_model_fn (phi , q0 = q0 )
170
180
print ("phi" , phi , "q" , aux ["q" ], "chi" , chi )
171
181
172
182
J_phi2chi , aux = jac_phi2chi_static_model_fn (phi , q0 = q0 )
173
- print ("J_phi2chi:\n " , J_phi2chi )
183
+ print ("J_phi2chi:\n " , J_phi2chi )
0 commit comments