Skip to content

Commit 362493e

Browse files
committed
Update sweep_actuation_mapping
1 parent 5eef91d commit 362493e

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

examples/simulate_pneumatic_planar_pcs.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,21 @@ def sweep_actuation_mapping():
9999
A = actuation_mapping_fn(params, B_xi, q)
100100
print("Evaluating actuation matrix for straight backbone: A =\n", A)
101101

102-
kappa_be_pts = jnp.linspace(-jnp.pi, jnp.pi, 500)
102+
kappa_be_pts = jnp.linspace(-3*jnp.pi, 3*jnp.pi, 500)
103103
sigma_ax_pts = jnp.zeros_like(kappa_be_pts)
104104
q_pts = jnp.stack([kappa_be_pts, sigma_ax_pts], axis=-1)
105105
A_pts = vmap(actuation_mapping_fn, in_axes=(None, None, 0))(params, B_xi, q_pts)
106+
# mark the points that are not controllable as the u1 and u2 terms share the same sign
107+
non_controllable_selector = A_pts[..., 0, 0] * A_pts[..., 0, 1] >= 0.0
108+
non_controllable_indices = jnp.where(non_controllable_selector)[0]
109+
non_controllable_boundary_indices = jnp.where(non_controllable_selector[:-1] != non_controllable_selector[1:])[0]
106110
# plot the mapping on the bending strain for various bending strains
107111
fig, ax = plt.subplots(num="pneumatic_planar_pcs_actuation_mapping_bending_torque_vs_bending_strain")
108112
plt.title(r"Actuation mapping from $u$ to $\tau_\mathrm{be}$")
109-
# shade the region where the actuation mapping is negative as we are not able to bend the robot further
110-
ax.axhspan(A_pts[:, 0, 0:2].min(), 0.0, facecolor='red', alpha=0.2)
113+
# # shade the region where the actuation mapping is negative as we are not able to bend the robot further
114+
# ax.axhspan(A_pts[:, 0, 0:2].min(), 0.0, facecolor='red', alpha=0.2)
115+
for idx in non_controllable_indices:
116+
ax.axvspan(kappa_be_pts[idx], kappa_be_pts[idx+1], facecolor='red', alpha=0.2)
111117
ax.plot(kappa_be_pts, A_pts[:, 0, 0], linewidth=2, label=r"$\frac{\partial \tau_\mathrm{be}}{\partial u_1}$")
112118
ax.plot(kappa_be_pts, A_pts[:, 0, 1], linewidth=2, label=r"$\frac{\partial \tau_\mathrm{ax}}{\partial u_2}$")
113119
ax.set_xlabel(r"$\kappa_\mathrm{be}$ [rad/m]")

0 commit comments

Comments
 (0)