1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
| syms x_A x_E y_A y_E phi_1(t) phi_2(t) phi_3(t) phi_4(t) phi_dot_1 phi_dot_4 l_1 l_2 l_3 l_4 l_5
x_A = -l_5/2; x_E = l_5/2; y_A = 0; y_E = 0;
x_B = x_A + l_1*cos(phi_1); y_B = y_A + l_1*sin(phi_1); x_D = x_E + l_4*cos(phi_4); y_D = y_E + l_4*sin(phi_4);
x_C = x_B + l_2*cos(phi_2); y_C = y_B + l_2*sin(phi_2);
x_dot_B = diff(x_B,t); y_dot_B = diff(y_B,t); x_dot_D = diff(x_D,t); y_dot_D = diff(y_D,t);
x_dot_C = diff(x_C,t); y_dot_C = diff(y_C,t);
phi_dot_2 = ((x_dot_D-x_dot_B)*cos(phi_3)+(y_dot_D-y_dot_B)*sin(phi_3))/l_2/sin(phi_3-phi_2);
x_dot_C = subs(x_dot_C,diff(phi_2,t),phi_dot_2); x_dot_C = subs(x_dot_C,[diff(phi_1,t),diff(phi_4,t)],[phi_dot_1,phi_dot_4]); y_dot_C = subs(y_dot_C,diff(phi_2,t),phi_dot_2); y_dot_C = subs(y_dot_C,[diff(phi_2,t),diff(phi_1,t),diff(phi_4,t)],[phi_dot_2,phi_dot_1,phi_dot_4]);
x_dot = [x_dot_C;y_dot_C]; q_dot = [phi_dot_1;phi_dot_4]; x_dot = simplify(collect(x_dot,q_dot)); J=simplify(jacobian(x_dot,q_dot))
syms phi_0 l_0
R = [cos(phi_0-pi/2) -sin(phi_0-pi/2); sin(phi_0-pi/2) cos(phi_0-pi/2)]; M = [0 -1/l_0; 1 0]; T = simplify(J.'*R*M)
|