Simplify doesn't work properly after IgnoreAnalyticConstraints
Show older comments
I tried to use combination of symbols and numbers to get my dynamics. Matlab is considering the same symbols from different matrices as different variables and creating it's own duplicate and hence not actually simplfying the symbolic solution. Can any one help me understand what am I missing. My symbol doesn't have any q1bar , q2 bar, q3 bar but the answer to simplify contains them.
here's my code
syms q1 q2 q3 dq1 dq2 dq3 t1 t2 t3
g = 9.8; % gravity in downward dir
m = 0.2;
m1 = 0.2;
m2 = 0.2;
m3 = 0.2;
mf = 0.2;
l1 = 0.07;
l2 = 0.095;
l3 = 0.11;
h = l1+l2+l3;
Jb_sl1 = [0 0 0;0 0 0;-l1/2 0 0;1 0 0;0 0 0;0 0 0];
Jb_sl2 = [0 l2/2 0;0 0 0; -(l2*cos(q2) + l1)/2 0 0;1 0 0;0 0 0;0 1 0];
Jb_sl3 = [0 (l3*cos(q3)+l2)/2 l3/2;0 -l3*sin(q3)/2 0;-(l2*cos(q2+q3)+l1)/2 0 0;1 0 0;0 0 0;0 1 1];
M11 = [m 0 0 0 0 0;0 m 0 0 0 0;0 0 m 0 0 0;0 0 0 0 0 0;0 0 0 0 0 0;0 0 0 0 0 0];
q = [q1;q2;q3];
dq = [dq1;dq2;dq3];
M = simplify((Jb_sl1'*M11*Jb_sl1)+ (Jb_sl2'*M11*Jb_sl2) + (Jb_sl3'*M11*Jb_sl3));
feval(symengine,'simplify',M,'IgnoreAnalyticConstraints')

V = -g*(m1*h + (m2*l1*sin(q1)) + (m3*l2*sin(q1)*sin(q2)) + mf*l3*sin(q1)*sin(q2+q3));
N = simplify([diff(V,q1);diff(V,q2);diff(V,q3)]);
% on differentiating M with respect to q we get C matrix as per given below
C = sym(zeros(3,3));
for i = 1:length(q)
for j = 1:length(q)
for k = 1:length(q)
k = 1:length(q)
C(i,j) = C(i,j) + 1/2*(diff(M(i,j),q(k)) + diff(M(i,k),q(j)) - diff(M(j,k),q(i)))*dq(k);
end
end
end
C = simplify(C);
Torque = [t1;t2;t3];
ddq = simplify(inv(M)*(Torque - N - C*dq))

Answers (0)
Categories
Find more on Calculus in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!