3
3
import jax .numpy as jnp
4
4
from jsrm .math_utils import blk_diag
5
5
import numpy as onp
6
- from typing import Dict , Optional , Tuple , Union
6
+ from typing import Callable , Dict , Optional , Tuple , Union
7
7
8
8
from .planar_pcs import factory as planar_pcs_factory
9
9
@@ -37,13 +37,17 @@ def factory(
37
37
actuation_basis = actuation_basis .at [2 * i + 1 , j + 1 ].set (1.0 )
38
38
39
39
def actuation_mapping_fn (
40
+ forward_kinematics_fn : Callable ,
41
+ jacobian_fn : Callable ,
40
42
params : Dict [str , Array ],
41
43
B_xi : Array ,
42
44
q : Array ,
43
45
) -> Array :
44
46
"""
45
47
Returns the actuation matrix that maps the actuation space to the configuration space.
46
48
Args:
49
+ forward_kinematics_fn: function to compute the forward kinematics
50
+ jacobian_fn: function to compute the Jacobian
47
51
params: dictionary with robot parameters
48
52
B_xi: strain basis matrix
49
53
q: configuration of the robot
@@ -57,8 +61,32 @@ def actuation_mapping_fn(
57
61
# number of strains
58
62
n_xi = xi .shape [0 ]
59
63
60
- for i in range (num_segments ):
61
- pass
64
+ # all segment bases and tips
65
+ sms = jnp .concat ([jnp .zeros ((1 ,)), jnp .cumsum (params ["l" ])], axis = 0 )
66
+ print ("sms =\n " , sms )
67
+
68
+ # compute the poses of all segment tips
69
+ chi_sms = vmap (forward_kinematics_fn , in_axes = (None , None , 0 ))(params , q , sms )
70
+
71
+ # compute the Jacobian for all segment tips
72
+ J_sms = vmap (jacobian_fn , in_axes = (None , None , 0 ))(params , q , sms )
73
+
74
+ def compute_actuation_matrix_for_segment (
75
+ chi_sm : Array , J_sm : Array , xi : Array
76
+ ) -> Array :
77
+ """
78
+ Compute the actuation matrix for a single segment.
79
+ Args:
80
+ chi_sm: tip position of the segment
81
+ J_sm: Jacobian of the segment
82
+ xi: strains of the segment
83
+ Returns:
84
+ A_sm: actuation matrix of shape (n_xi, 2)
85
+ """
86
+ # compute the actuation matrix for a single segment
87
+ A_sm = jnp .zeros ((n_xi , 2 ))
88
+ return A_sm
89
+
62
90
63
91
A = jnp .zeros ((n_xi , 2 * num_segments ))
64
92
0 commit comments