@@ -37,7 +37,7 @@ def factory(
37
37
strain are active / non-zero
38
38
xi_eq: array of shape (3 * num_segments) with the rest strains of the rod
39
39
stiffness_fn: function to compute the stiffness matrix of the system. Should have the signature
40
- stiffness_fn(params: Dict[str, Array], formulate_in_strain_space: bool) -> Array
40
+ stiffness_fn(params: Dict[str, Array], B_xi, formulate_in_strain_space: bool) -> Array
41
41
global_eps: small number to avoid singularities (e.g., division by zero)
42
42
Returns:
43
43
B_xi: strain basis matrix of shape (3 * num_segments, n_q)
@@ -204,12 +204,13 @@ def classify_segment(params: Dict[str, Array], s: Array) -> Tuple[Array, Array]:
204
204
205
205
if stiffness_fn is None :
206
206
def stiffness_fn (
207
- params : Dict [str , Array ], formulate_in_strain_space : bool = False
207
+ params : Dict [str , Array ], B_xi : Array , formulate_in_strain_space : bool = False
208
208
) -> Array :
209
209
"""
210
210
Compute the stiffness matrix of the system.
211
211
Args:
212
212
params: Dictionary of robot parameters
213
+ B_xi: Strain basis matrix
213
214
formulate_in_strain_space: whether to formulate the elastic matrix in the strain space
214
215
Returns:
215
216
K: elastic matrix of shape (n_q, n_q) if formulate_in_strain_space is False or (n_xi, n_xi) otherwise
@@ -329,7 +330,7 @@ def dynamical_matrices_fn(
329
330
xi_epsed = apply_eps_to_bend_strains (xi , eps )
330
331
331
332
# compute the stiffness matrix
332
- K = stiffness_fn (params , formulate_in_strain_space = True )
333
+ K = stiffness_fn (params , B_xi , formulate_in_strain_space = True )
333
334
334
335
# dissipative matrix from the parameters
335
336
D = params .get ("D" , jnp .zeros ((n_xi , n_xi )))
@@ -385,7 +386,7 @@ def potential_energy_fn(
385
386
xi_epsed = apply_eps_to_bend_strains (xi , eps )
386
387
387
388
# compute the stiffness matrix
388
- K = stiffness_fn (params , formulate_in_strain_space = True )
389
+ K = stiffness_fn (params , B_xi , formulate_in_strain_space = True )
389
390
# elastic energy
390
391
U_K = (xi - xi_eq ).T @ K @ (xi - xi_eq ) # evaluate K(xi) = K @ xi
391
392
0 commit comments