Professional Documents
Culture Documents
Robotic
Robotic
figure
subplot(2,2,1)
plot(t,X,'r', t,Xtd,'g', t,Xtdd,'b');
legend('X', 'Xd', 'Xdd');
xlabel('t')
ylabel('x(t)')
title('quintic path for X (time path)')
subplot(2,2,2)
plot(t,Y,'r')
grid on
legend('Y');
xlabel('t')
ylabel('y(t)')
title('quintic path for Y (time path)')
subplot(2,2,3)
plot(t,Z,'r')
grid on
legend('Z');
xlabel('t')
ylabel('z(t)')
title('quintic path for Z (time path)')
subplot(2,2,4)
plot3(X,Y,Z,'m')
grid on
xlabel('x(t)')
ylabel('y(t)')
zlabel('z(t)')
title('path planning from P1 to P2')
---------------------------------------
%inverse to find joint variables
l1 = 1;
l2 = 1;
l3 = 1;
q1=[];
q2=[];
q3=[];
for t = t0:t1
X = a0 + a1*t + a2*t^2 + a3*t^3+ a4*t^4+ a5*t^5;
Y = ((X-x0)*(y1-y0))/(x1-x0)+y0;
Z =(Y-y0)*((z1-z0)/(y1-y0))+z0;
if X>=0
theta1 = atan(Y/X);
elseif X<0
theta1 = atan(Y/X)+pi;
end
c2 = 2*l1*l2 - 2*l2*Z;
q1 = [q1 theta1];
q2 = [q2 theta2];
q3 = [q3 theta3];
end
figure
subplot(1,2,1)
plot(q1,'r');
hold on
plot(q2,'b');
hold on
plot(q3,'g');
legend('theta1','theta2','theta3');
xlabel('t')
ylabel('theta(t)')
title('theta angle')