Skip to content

Commit ca408df

Browse files
committed
Add script to analyze segment fusion behavior
1 parent 3c3448f commit ca408df

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

examples/analyze_segment_fusion.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import sympy as sp
2+
3+
l1, l2 = sp.symbols('l1 l2', nonnegative=True, nonzero=True)
4+
kappa_be1, sigma_sh1, sigma_ax1 = sp.symbols('kappa_be1 sigma_sh1 sigma_ax1', real=True, nonnegative=True, nonzero=True)
5+
kappa_be2, sigma_sh2, sigma_ax2 = sp.symbols('kappa_be2 sigma_sh2 sigma_ax2', real=True, nonnegative=True, nonzero=True)
6+
7+
# deactivate shear and axial strains
8+
# sigma_sh1, sigma_sh2 = 0.0, 0.0
9+
# sigma_ax1, sigma_ax2 = 0.0, 0.0
10+
11+
# define the strains for the two segments
12+
q1 = [kappa_be1, sigma_sh1, sigma_ax1]
13+
q2 = [kappa_be2, sigma_sh2, sigma_ax2]
14+
15+
# average the strains for fused segments
16+
qfus = [(l1 * q1[i] + l2 * q2[i]) / (l1 + l2) for i in range(len(q1))]
17+
print("qfus =\n", qfus)
18+
19+
# apply the forward kinematics on the individual segments
20+
s_be1, c_be1 = sp.sin(kappa_be1 * l1), sp.cos(kappa_be1 * l1)
21+
s_be2, c_be2 = sp.sin(kappa_be2 * l2), sp.cos(kappa_be2 * l2)
22+
chi1 = sp.Matrix([
23+
[sigma_sh1 * s_be1 / kappa_be1 + sigma_ax1 * (c_be1 - 1) / kappa_be1],
24+
[sigma_sh1 * (1 - c_be1) / kappa_be1 + sigma_ax1 * s_be1 / kappa_be1],
25+
[kappa_be1 * l1],
26+
])
27+
# rotation matrix
28+
R1 = sp.Matrix([
29+
[c_be1, -s_be1, 0],
30+
[s_be1, c_be1, 0],
31+
[0, 0, 1],
32+
])
33+
chi2_rel = sp.Matrix([
34+
[sigma_sh2 * s_be2 / kappa_be2 + sigma_ax2 * (c_be2 - 1) / kappa_be2],
35+
[sigma_sh2 * (1 - c_be2) / kappa_be2 + sigma_ax2 * s_be2 / kappa_be2],
36+
[kappa_be2 * l2],
37+
])
38+
chi2 = sp.simplify(chi1 + R1 @ chi2_rel)
39+
# print("chi2 =\n", chi2)
40+
# apply the one-segment inverse kinematic on the distal end of the two segments
41+
px, py, th = chi2[0, 0], chi2[1, 0], chi2[2, 0]
42+
s_th, c_th = sp.sin(th), sp.cos(th)
43+
qfkik = sp.simplify(th / (2 * (l1 + l2)) * sp.Matrix([
44+
[2],
45+
[py - px * s_th / (c_th - 1)],
46+
[-px - py * s_th / (c_th - 1)],
47+
]))
48+
print("qfkik =\n", qfkik)

0 commit comments

Comments
 (0)