btvn3 Robot
btvn3 Robot
btvn3 Robot
code Matlab:
hàm basic_01
function x = basic_01(a,b,d)
alpha = atan2d(a/(sqrt(a*a+b*b)), b/(sqrt(a*a+b*b)));
x1 = atan2d(d/(sqrt(a*a+b*b)), sqrt(1-(d*d/(a*a+b*b)))) -
alpha;
x2 = atan2d(d/(sqrt(a*a+b*b)), -sqrt(1-(d*d/(a*a+b*b)))) -
alpha;
x = [x1; x2];
hàm HW3
function the = HW3(d3, d4, a2, a3, x6_0_ORG, y6_0_ORG,
z6_0_ORG, phi0_x, phi0_y, phi0_z)
%l1c1 + l2c12 = x
%l1s1 + l2s12 = y
%y6_0_ORG * c1 - x_6_ORG * s1 = d3
the1 = basic_01(y6_0_ORG, -x6_0_ORG, d3);
%a3 * c3 - d4 *s3 = K = (Px^2 + Py^2 + Pz^2 - a2^2
- a3^2 - d3^2
%-d4^2)/(2 *a2)
K = (x6_0_ORG^2 + y6_0_ORG^2 + z6_0_ORG^2 - a2^2 -
a3^2 - d3^2 -d4^2)/(2*a2);
the3 = basic_01(a3, -d4, K);
the1 = the13(:,1);
the3 = the13(:,2);
%s23 = ((-a3 - a2c3)pz + (c1px + s1py)(a2s3 -
d4))/(pz^2+ (c1px +
%s1py)^2)
%c23 = ((a2s3 - d4)pz - (a3 + a2c3)(c1px +
s1py))/(pz^2+ (c1px +
%s1py)^2)
s23 = [(-a3 - a2*cos(the3(1,1)))*z6_0_ORG +
(cos(the1(1,1))*x6_0_ORG +
sin(the1(1,1))*y6_0_ORG)*(a2*sin(the3(1,1)) -
d4)/((z6_0_ORG^2+ (cos(the1(1,1)))*x6_0_ORG +
sin(the1(1,1))*y6_0_ORG)^2)
(-a3 - a2*cos(the3(2,1)))*z6_0_ORG +
(cos(the1(2,1))*x6_0_ORG +
sin(the1(2,1))*y6_0_ORG)*(a2*sin(the3(2,1)) -
d4)/((z6_0_ORG^2+ (cos(the1(2,1)))*x6_0_ORG +
sin(the1(2,1))*y6_0_ORG)^2)
(-a3 - a2*cos(the3(3,1)))*z6_0_ORG +
(cos(the1(3,1))*x6_0_ORG +
sin(the1(3,1))*y6_0_ORG)*(a2*sin(the3(3,1)) -
d4)/((z6_0_ORG^2+ (cos(the1(3,1)))*x6_0_ORG +
sin(the1(3,1))*y6_0_ORG)^2)
(-a3 - a2*cos(the3(4,1)))*z6_0_ORG +
(cos(the1(4,1))*x6_0_ORG +
sin(the1(4,1))*y6_0_ORG)*(a2*sin(the3(4,1)) -
d4)/((z6_0_ORG^2+ (cos(the1(4,1)))*x6_0_ORG +
sin(the1(4,1))*y6_0_ORG)^2)];
c23 = [(a2*sin(the3(1,1) - d4))*z6_0_ORG +
(cos(the1(1,1))*x6_0_ORG + sin(the1(1,1))*y6_0_ORG)*(a3 +
a2*cos(the3(1,1)))/((z6_0_ORG^2+ (cos(the1(1,1)))*x6_0_ORG
+ sin(the1(1,1))*y6_0_ORG)^2)
(a2*sin(the3(2,1) - d4))*z6_0_ORG +
(cos(the1(2,1))*x6_0_ORG + sin(the1(2,1))*y6_0_ORG)*(a3 +
a2*cos(the3(2,1)))/((z6_0_ORG^2+ (cos(the1(2,1)))*x6_0_ORG
+ sin(the1(2,1))*y6_0_ORG)^2)
(a2*sin(the3(3,1) - d4))*z6_0_ORG +
(cos(the1(3,1))*x6_0_ORG + sin(the1(3,1))*y6_0_ORG)*(a3 +
a2*cos(the3(3,1)))/((z6_0_ORG^2+ (cos(the1(3,1)))*x6_0_ORG
+ sin(the1(3,1))*y6_0_ORG)^2)
(a2*sin(the3(4,1) - d4))*z6_0_ORG +
(cos(the1(4,1))*x6_0_ORG + sin(the1(4,1))*y6_0_ORG)*(a3 +
a2*cos(the3(4,1)))/((z6_0_ORG^2+ (cos(the1(4,1)))*x6_0_ORG
+ sin(the1(4,1))*y6_0_ORG)^2)];
the23 = atan2(s23, c23);
the2 = the23 - the3;
the = [the13(:,1) the2 the13(:,2)];
r11 = cos (phi0_x)*cos (phi0_y);r21 = sin
(phi0_x)*cos (phi0_y);r31 = -sin (phi0_y);
r12 = cos (phi0_x)*sin (phi0_y)*sin (phi0_z) - sin
(phi0_x)*cos (phi0_z); r22 = sin (phi0_x)*sin (phi0_y)*sin
(phi0_z) + cos (phi0_x)*cos (phi0_z); r32 = cos
(phi0_y)*sin (phi0_z);
r13 = cos (phi0_x)*sin (phi0_y)*cos (phi0_z) + sin
(phi0_x)*sin (phi0_z); r23 = sin (phi0_x)*sin (phi0_y)*cos
(phi0_z) - cos (phi0_x)*sin (phi0_z); r33 = cos
(phi0_y)*cos (phi0_z);
R = [r11 r12 r13; r21 r22 r23; r31 r32 r33];
for i = 1:6
%NOTATION
ci = cos(DH(i, 4)); si = sin(DH(i, 4));
c_anpi_1 = cos(DH(i, 1)); s_anpi_1 = sin(DH(i, 1));
ai_1 = DH(i, 2); di = DH(i, 3);
%T_0_i
P_0_1 = T_0_i_all(1:3,4,1);
P_0_2 = T_0_i_all(1:3,4,2);
P_0_3 = T_0_i_all(1:3,4,3);
P_0_4 = T_0_i_all(1:3,4,4);
P_0_5 = T_0_i_all(1:3,4,5);
P_0_6 = T_0_i_all(1:3,4,6);
plot3([P_0_0(1);P_0_1(1)],[P_0_0(2);P_0_1(2)],[P_0_0(3);P_0
_1(3)], '-rO',...
[P_0_1(1);P_0_2(1)],[P_0_1(2);P_0_2(2)],...
[P_0_1(3);P_0_2(3)],'-bO',...
[P_0_2(1);P_0_3(1)],[P_0_2(2);P_0_3(2)],...
[P_0_2(3);P_0_3(3)],'-bO',...
[P_0_3(1);P_0_4(1)],[P_0_3(2);P_0_4(2)],...
[P_0_3(3);P_0_4(3)],'-bO',...
[P_0_4(1);P_0_5(1)],[P_0_4(2);P_0_5(2)],...
[P_0_4(3);P_0_5(3)],'-bO',...
[P_0_5(1);P_0_6(1)],[P_0_5(2);P_0_6(2)],...
[P_0_5(3);P_0_6(3)],'-bO');
hold on;
grid on;
xlim([-2.5 4]) ; ylim([-2.5 4]) ; zlim([-2.5 4]);
xlabel('x') ; ylabel('y') ; zlabel('z') ;
end
hình mô phỏng