Borrar filtros
Borrar filtros

I'm tryng to calculate some number and matrix with my robotics project and facing this problem when run the code. Can anyone explain for me, i'm just a newbie. Thank you very much. The error is after the code.

2 visualizaciones (últimos 30 días)
clc
syms q1 q2 q3 dq1 dq2 dq3 a1 a2 m1 m2 m3 t g f
assume(a1, 'real');assume(a1>0);
assume(a2,'real');assume(a2>0);
assume(q3,'real');
assume(dq3,'real');
assume(q1,'real');
assume(q2,'real');
assume(dq1,'real');
assume(dq2,'real');
assume(t,'real');assume(t>0);
assume(f,'real');
q = [q1;q2;q3]; %vecto cac toa do suy rong
dq = [dq1;dq2;dq3]; %vecto cac dao ham toa do suy rong
%Nhap cac ma tran D-H
A_01=[ cos(q1) -sin(q1) 0 a1*cos(q1);sin(q1) cos(q1) 0 a1*sin(q1);0 0 1 0;0 0 0 1;];
A_12=[cos(q2) -sin(q2) 0 a2*cos(q2);sin(q2) cos(q2) 0 a2*sin(q2);0 0 1 0;0 0 0 1;];
A_23=[1 0 0 0;0 -1 0 0;0 0 -1 -q3;0 0 0 1;];
% Tính các ma tran cosin chi phuong
R_01=A_01(1:3,1:3);
A_03=A_01*A_12*A_23;
A_02=simplify(A_01*A_12);disp(A_02); % Sau khi tính toán ta thu gon ket qua ngay bang lenh simplify
R_02=A_02(1:3,1:3);
disp('Ma tran bien doi thuan nhat khau cuoi la');
A_03 = simplify(A_03);
R_03 = A_03(1:3,1:3);
disp(A_03);
%Giai bai toan dong hoc thuan
disp('Giai bai toan dong hoc thuan');
disp('toa do diem cuoi');
rE = A_03(1:3,4); disp(rE);% Vector toa do khâu thao tác
disp('van toc diem cuoi')
v_qE = simplify(jacobian(rE,q)*dq);disp(v_qE); % Tính vector van toc khâu tác dong cuoi
jacobian(rE,q); disp('Jacobi tinh tien'); disp(jacobian(rE,q));
R_0E = A_03(1:3,1:3); disp(R_0E);
diff_R_0E = diff(R_0E,q1)*dq1+diff(R_0E,q2)*dq2; %Tinh dao ham cua R
omega_curveE = diff_R_0E*R_0E.'; %omega song khau cuoi
omega_curveE = simplify(omega_curveE);
disp('Van toc goc khau cuoi:');
omega3 = [omega_curveE(3,2) omega_curveE(1,3) omega_curveE(2,1)]; disp(omega3); %omega
jacobian(omega3,dq); disp('Jacobi quay khau cuoi'); disp(jacobian(omega3,dq));
R_01 = A_01(1:3,1:3); disp(R_01);
diff_R_01 = diff(R_01,q1)*dq1+diff(R_01,q2)*dq2;
omega_curve1 = diff_R_01*R_01.';
omega_curve1 = simplify(omega_curve1);
disp('Van toc goc khau thu nhat');
omega1 = [omega_curve1(3,2) omega_curve1(1,3) omega_curve1(2,1)]; disp(omega1); %omega
jacobian(omega1,dq); disp('Jacobi quay khau thu nhat'); disp(jacobian(omega1,dq));
R_02 = A_02(1:3,1:3); disp(R_02);
diff_R_02 = diff(R_02,q1)*dq1+diff(R_02,q2)*dq2;
omega_curve2 = diff_R_02*R_02.';
omega_curve2 = simplify(omega_curve2);
disp('Van toc goc khau thu hai');
omega2 = [omega_curve2(3,2) omega_curve2(1,3) omega_curve2(2,1)]; disp(omega2); %omega
jacobian(omega2,dq); disp('Jacobi quay khau thu hai'); disp(jacobian(omega2,dq));
%tinh gia toc diem cuoi %chua tinh dc
diff_v_qE = diff(v_qE,q1)*dq1 + diff(v_qE,q2)*dq2;
disp('gia toc diem cuoi la:'); disp(diff_v_qE);
%tinh gia toc goc diem cuoi
%diff_omega = diff(omega,q1)*dq1 + diff(omega,q2)*dq2;
%disp('gia toc goc khau thao tac'); disp(diff_omega);
%khao sat can bang tinh
F_3E = [0 0 f]; % luc gia cong tai diem cuoi so voi he 3
F_0E = F_3E*R_03;
P_01 = [0 0 -m1*g]; %trong luc tac dung len C1
P_02 = [0 0 -m2*g];
P_03 = [0 0 -m3*g];
r_0C1 = [(a1/2)*cos(q1) (a1/2)*sin(q1) 0]; %toa do C1 so voi he 0
r_1C2 = [(a2/2)*cos(q2) (a2/2)*sin(q2) 0];
r_0C2 = r_1C2*R_01;
r_2C3 = [-q3/2 0 0];
r_0C3 = r_2C3*R_02;
J_TE = jacobian(rE,q);
J_TC1= jacobian(r_0C1,q);
J_TC2= jacobian(r_0C2,q);
J_TC3= jacobian(r_0C3,q);
%luc dong co
Tdc = -J_TE.'*F_0E - P1.'*J_TC1 - P2.'*J_TC2 - P3.'*J_TC3;
disp('luc dong co co gia tri la'); disp(Tdc);
F_0_32 = F_0E - P_03; disp('luc tac dung tu khau 2 len khau 3'); disp(F_0_32);
F_0_21 = F_0_32 - P_02; disp('luc tac dung tu khau 1 len khau 2'); disp(F_0_21);
F_0_10 = F_0_21 - P_01; disp('luc tac dung tu khau 0 len khau 1'); disp(F_0_10);
Csym = mupadmex(op,args{1}.s, args{2}.s, varargin{:});
Error in * (line 244)
X = privBinaryOp(A, B, 'symobj::mtimes');
Error in ltmp (line 97)
Tdc = -J_TE.'*F_0E - P1.'*J_TC1 - P2.'*J_TC2 - P3.'*J_TC3;

Respuesta aceptada

madhan ravi
madhan ravi el 10 de Dic. de 2018
Editada: madhan ravi el 10 de Dic. de 2018
EDITED
Rules of matrix multiplication 3 by 3 times 3 by 1 but what you did was you transposed J_TE which is size 3 by 3 is also 3 by 3 after and you multiply it with 1 by 3(size of F_0E) which contradicts the rule.
Tdc = -J_TE*F_0E.' - P1*J_TC1 - P2*J_TC2 - P3*J_TC3; %change to this line
^---- transposed
Note : P1 ,P2 & P3 is not defined , I suspect they should be P_01 , P_02 & P_03
  5 comentarios
Anh Tong
Anh Tong el 10 de Dic. de 2018
There a lot of mistakes in my code, i think i gonna find them with your advise Ravi. Thank again
madhan ravi
madhan ravi el 10 de Dic. de 2018
Editada: madhan ravi el 10 de Dic. de 2018
You don't have to ask the same question multiple times just use size() to check the variable sizes, run the below code:
clc
syms q1 q2 q3 dq1 dq2 dq3 a1 a2 m1 m2 m3 t g f
assume(a1, 'real');assume(a1>0);
assume(a2,'real');assume(a2>0);
assume(q3,'real');
assume(dq3,'real');
assume(q1,'real');
assume(q2,'real');
assume(dq1,'real');
assume(dq2,'real');
assume(t,'real');assume(t>0);
assume(f,'real');
q = [q1;q2;q3]; %vecto cac toa do suy rong
dq = [dq1;dq2;dq3]; %vecto cac dao ham toa do suy rong
%Nhap cac ma tran D-H
A_01=[ cos(q1) -sin(q1) 0 a1*cos(q1);sin(q1) cos(q1) 0 a1*sin(q1);0 0 1 0;0 0 0 1;];
A_12=[cos(q2) -sin(q2) 0 a2*cos(q2);sin(q2) cos(q2) 0 a2*sin(q2);0 0 1 0;0 0 0 1;];
A_23=[1 0 0 0;0 -1 0 0;0 0 -1 -q3;0 0 0 1;];
% Tính các ma tran cosin chi phuong
R_01=A_01(1:3,1:3);
A_03=A_01*A_12*A_23;
A_02=simplify(A_01*A_12);disp(A_02); % Sau khi tính toán ta thu gon ket qua ngay bang lenh simplify
R_02=A_02(1:3,1:3);
disp('Ma tran bien doi thuan nhat khau cuoi la');
A_03 = simplify(A_03);
R_03 = A_03(1:3,1:3);
disp(A_03);
%Giai bai toan dong hoc thuan
disp('Giai bai toan dong hoc thuan');
disp('toa do diem cuoi');
rE = A_03(1:3,4); disp(rE);% Vector toa do khâu thao tác
disp('van toc diem cuoi')
v_qE = simplify(jacobian(rE,q)*dq);disp(v_qE); % Tính vector van toc khâu tác dong cuoi
jacobian(rE,q); disp('Jacobi tinh tien'); disp(jacobian(rE,q));
R_0E = A_03(1:3,1:3); disp(R_0E);
diff_R_0E = diff(R_0E,q1)*dq1+diff(R_0E,q2)*dq2; %Tinh dao ham cua R
omega_curveE = diff_R_0E*R_0E.'; %omega song khau cuoi
omega_curveE = simplify(omega_curveE);
disp('Van toc goc khau cuoi:');
omega3 = [omega_curveE(3,2) omega_curveE(1,3) omega_curveE(2,1)]; disp(omega3); %omega
jacobian(omega3,dq); disp('Jacobi quay khau cuoi'); disp(jacobian(omega3,dq));
R_01 = A_01(1:3,1:3); disp(R_01);
diff_R_01 = diff(R_01,q1)*dq1+diff(R_01,q2)*dq2;
omega_curve1 = diff_R_01*R_01.';
omega_curve1 = simplify(omega_curve1);
disp('Van toc goc khau thu nhat');
omega1 = [omega_curve1(3,2) omega_curve1(1,3) omega_curve1(2,1)]; disp(omega1); %omega
jacobian(omega1,dq); disp('Jacobi quay khau thu nhat'); disp(jacobian(omega1,dq));
R_02 = A_02(1:3,1:3); disp(R_02);
diff_R_02 = diff(R_02,q1)*dq1+diff(R_02,q2)*dq2;
omega_curve2 = diff_R_02*R_02.';
omega_curve2 = simplify(omega_curve2);
disp('Van toc goc khau thu hai');
omega2 = [omega_curve2(3,2) omega_curve2(1,3) omega_curve2(2,1)]; disp(omega2); %omega
jacobian(omega2,dq); disp('Jacobi quay khau thu hai'); disp(jacobian(omega2,dq));
%tinh gia toc diem cuoi %chua tinh dc
diff_v_qE = diff(v_qE,q1)*dq1 + diff(v_qE,q2)*dq2;
disp('gia toc diem cuoi la:'); disp(diff_v_qE);
%tinh gia toc goc diem cuoi
%diff_omega = diff(omega,q1)*dq1 + diff(omega,q2)*dq2;
%disp('gia toc goc khau thao tac'); disp(diff_omega);
%khao sat can bang tinh
F_3E = [0;0;f]; % luc gia cong tai diem cuoi so voi he 3
F_0E = F_3E.'*R_03;
P_01 = [0 0 -m1*g]; %trong luc tac dung len C1
P_02 = [0 0 -m2*g];
P_03 = [0 0 -m3*g];
r_0C1 = [(a1/2)*cos(q1) (a1/2)*sin(q1) 0]; %toa do C1 so voi he 0
r_1C2 = [(a2/2)*cos(q2) (a2/2)*sin(q2) 0];
r_0C2 = r_1C2*R_01;
r_2C3 = [-q3/2 0 0];
r_0C3 = r_2C3*R_02;
J_TE = jacobian(rE,q);
J_TC1= jacobian(r_0C1,q);
J_TC2= jacobian(r_0C2,q);
J_TC3= jacobian(r_0C3,q);
%luc dong co
Tdc = -J_TE*F_0E.' - P_01*J_TC1 - P_02*J_TC2 - P_03*J_TC3;
disp('luc dong co co gia tri la'); disp(Tdc);
F_0_32 = F_0E - P_03; disp('luc tac dung tu khau 2 len khau 3'); disp(F_0_32);
F_0_21 = F_0_32 - P_02; disp('luc tac dung tu khau 1 len khau 2'); disp(F_0_21);
F_0_10 = F_0_21 - P_01; disp('luc tac dung tu khau 0 len khau 1'); disp(F_0_10);

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Elementary Math en Help Center y File Exchange.

Productos


Versión

R2015a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by