@@ -19,6 +19,7 @@ def factory(
19
19
strain_selector : Array = None ,
20
20
xi_eq : Optional [Array ] = None ,
21
21
stiffness_fn : Optional [Callable ] = None ,
22
+ actuation_mapping_fn : Optional [Callable ] = None ,
22
23
global_eps : float = 1e-6 ,
23
24
) -> Tuple [
24
25
Array ,
@@ -38,6 +39,8 @@ def factory(
38
39
xi_eq: array of shape (3 * num_segments) with the rest strains of the rod
39
40
stiffness_fn: function to compute the stiffness matrix of the system. Should have the signature
40
41
stiffness_fn(params: Dict[str, Array], B_xi, formulate_in_strain_space: bool) -> Array
42
+ actuation_mapping_fn: function to compute the actuation matrix that maps the actuation space to the
43
+ configuration space.
41
44
global_eps: small number to avoid singularities (e.g., division by zero)
42
45
Returns:
43
46
B_xi: strain basis matrix of shape (3 * num_segments, n_q)
@@ -233,6 +236,26 @@ def stiffness_fn(
233
236
234
237
return K
235
238
239
+ if actuation_mapping_fn is None :
240
+ def actuation_mapping_fn (
241
+ params : Dict [str , Array ],
242
+ B_xi : Array ,
243
+ q : Array ,
244
+ ) -> Array :
245
+ """
246
+ Returns the actuation matrix that maps the actuation space to the configuration space.
247
+ Assumes the fully actuated and identity actuation matrix.
248
+ Args:
249
+ params: dictionary with robot parameters
250
+ B_xi: strain basis matrix
251
+ q: configuration of the robot
252
+ Returns:
253
+ A: actuation matrix of shape (n_xi, n_xi) where n_xi is the number of strains.
254
+ """
255
+ A = jnp .identity (n_xi ) @ B_xi
256
+
257
+ return A
258
+
236
259
@jit
237
260
def forward_kinematics_fn (
238
261
params : Dict [str , Array ], q : Array , s : Array , eps : float = global_eps
@@ -331,6 +354,8 @@ def dynamical_matrices_fn(
331
354
332
355
# compute the stiffness matrix
333
356
K = stiffness_fn (params , B_xi , formulate_in_strain_space = True )
357
+ # compute the actuation matrix
358
+ A = actuation_mapping_fn (params , B_xi , q )
334
359
335
360
# dissipative matrix from the parameters
336
361
D = params .get ("D" , jnp .zeros ((n_xi , n_xi )))
@@ -347,7 +372,7 @@ def dynamical_matrices_fn(
347
372
D = B_xi .T @ D @ B_xi
348
373
349
374
# apply the strain basis to the actuation matrix
350
- alpha = B_xi .T @ jnp . identity ( n_xi ) @ B_xi
375
+ alpha = B_xi .T @ A
351
376
352
377
return B , C , G , K , D , alpha
353
378
@@ -500,6 +525,7 @@ def operational_space_dynamical_matrices_fn(
500
525
"apply_eps_to_bend_strains" : apply_eps_to_bend_strains ,
501
526
"classify_segment" : classify_segment ,
502
527
"stiffness_fn" : stiffness_fn ,
528
+ "actuation_mapping_fn" : actuation_mapping_fn ,
503
529
"jacobian_fn" : jacobian_fn ,
504
530
"kinetic_energy_fn" : kinetic_energy_fn ,
505
531
"potential_energy_fn" : potential_energy_fn ,
0 commit comments