Sei sulla pagina 1di 2

CD_2gdl_graficaROBOT3.

m
%Cierra ventanas y limpia variables
close all
clc
clear all

%Parmetros del robot


L1=1;
L2=1;

%Rango de variables articulares


th1=0:(pi/2)/40:2*pi;
th2=0:(pi/2)/40:2*pi;

%Ecuaciones de cinemtica directa


px=L1*cos(th1)+L2*cos(th1+th2);
py=L1*sin(th1)+L2*sin(th1+th2);

%Figura con animacin del robot


%Animacin parte 1. Grafica la trayectoria del efector final
figure('Name','Animacin','NumberTitle','off')
plot(px,py,'Linewidth',4)
xlabel('Eje x')
ylabel('Eje y')
m=max(max(th1));
m2=m*180/pi;
n=max(max(th2));
n2=n*180/pi;
title(['\theta_1^p = ',num2str(m2),' \theta_2 = ',num2str(n2),'' ])
grid
axis equal
hold

%Animacin parte 2. Grafica la representacin espacial del robot


th4=0;%th4=th2
for th3=0:(pi/2)/10:2*pi; %th3=th1
px2=L1*cos(th3)+L2*cos(th3+th4);
py2=L1*sin(th3)+L2*sin(th3+th4);
x=[0 L1*cos(th3)];
y=[0 L1*sin(th3)];
plot(x,y,'r','Linewidth',0.5)
x1=[L1*cos(th3) px2];
y1=[L1*sin(th3) py2];
plot(x1,y1,'k','Linewidth',0.5)
pause(0.1)
th4=th4+((pi/2)/10);
end
legend('trayectoria','esla1','esla2')

Pgina 1
CD_2gdl_graficaROBOT3.m
% Grfica del espacio de trabajo
figure('Name','Espacio de trabajo','NumberTitle','off')
th5=0:(pi/2)/20:2*pi;%th5=th1
th6=0*th5;%th6=th2
px3=L1*cos(th5)+L2*cos(th5+th6);
py3=L1*sin(th5)+L2*sin(th5+th6);
plot(px3,py3,'Linewidth',3)
grid
xlabel('Eje x')
ylabel('Eje y')
m3=max(max(th5));
m4=m3*180/pi;
n3=max(max(th6));
n4=n3*180/pi;
title(['\theta_1 = ',num2str(m4),' \theta_2 = ',num2str(n4),'' ])
axis equal

figure('Name','Espacio de trabajo total','NumberTitle','off')


hold
for th7=0:(pi/2)/2:2*pi;
for th8=0:(pi/2)/2:2*pi;
px4=L1*cos(th7)+L2*cos(th7+th8);
py4=L1*sin(th7)+L2*sin(th7+th8);
% x2=[0 L1*cos(th7)];
% y2=[0 L1*sin(th7)];
%plot(x2,y2,'r','Linewidth',0.5)
% x3=[L1*cos(th7) px4];
% y3=[L1*sin(th7) py4];
%plot(x3,y3,'k','Linewidth',0.5)
plot(px4,py4,'*')
grid
axis equal
%pause (0.1)
end
end

% figure()
% for th9=0:(pi/2)/20:2*pi;
% th10=0:(pi/2)/20:2*pi;
% px5=L1*cos(th9)+L2*cos(th9+th10);
% py5=L1*sin(th9)+L2*sin(th9+th10);
% plot(px5,py5,'r','Linewidth',2)
% end

Pgina 2

Potrebbero piacerti anche