Skip to content

Commit 8a97d64

Browse files
committed
Start working on actuation_mapping_fn
1 parent 006c6b9 commit 8a97d64

File tree

1 file changed

+52
-2
lines changed

1 file changed

+52
-2
lines changed

src/jsrm/systems/pneumatic_planar_pcs.py

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,60 @@
88
from .planar_pcs import factory as planar_pcs_factory
99

1010
def factory(
11-
*args, **kwargs
11+
num_segments: int,
12+
*args,
13+
segment_actuation_selector: Optional[Array] = None,
14+
**kwargs
1215
):
16+
"""
17+
Factory function for the planar PCS.
18+
Args:
19+
segment_actuation_selector: actuation selector for the segments as boolean array of shape (num_segments,)
20+
True entries signify that the segment is actuated, False entries signify that the segment is passive
21+
Returns:
22+
"""
23+
if segment_actuation_selector is None:
24+
segment_actuation_selector = jnp.ones(num_segments, dtype=bool)
25+
26+
# number of input pressures
27+
actuation_dim = segment_actuation_selector.sum() * 2
28+
29+
# matrix that maps the (possibly) underactuated actuation space to a full actuation space
30+
actuation_basis = jnp.eye(num_segments)[segment_actuation_selector]
31+
32+
def actuation_mapping_fn(
33+
params: Dict[str, Array],
34+
B_xi: Array,
35+
q: Array,
36+
) -> Array:
37+
"""
38+
Returns the actuation matrix that maps the actuation space to the configuration space.
39+
Args:
40+
params: dictionary with robot parameters
41+
B_xi: strain basis matrix
42+
q: configuration of the robot
43+
Returns:
44+
A: actuation matrix of shape (n_xi, n_act) where n_xi is the number of strains and
45+
n_act is the number of actuators
46+
"""
47+
# map the configurations to strains
48+
xi = B_xi @ q
49+
50+
# number of strains
51+
n_xi = xi.shape[0]
52+
53+
for i in range(num_segments):
54+
pass
55+
56+
A = jnp.zeros((n_xi, 2 * num_segments))
57+
58+
# apply the actuation_basis
59+
A = A @ actuation_basis
60+
61+
return A
62+
1363
return planar_pcs_factory(
14-
*args, stiffness_fn=stiffness_fn, **kwargs
64+
*args, stiffness_fn=stiffness_fn, actuation_mapping_fn=actuation_mapping_fn, **kwargs
1565
)
1666

1767
def _compute_stiffness_matrix_for_segment(

0 commit comments

Comments
 (0)