Matlab - Problemas Maximu recusrsion

 
Vista:
sin imagen de perfil

Problemas Maximu recusrsion

Publicado por Juan (2 intervenciones) el 08/09/2015 23:52:53
Hola a todos tengo el siguiente problema con matlab, me sale el siguiente error:

Maximum recursion limit of 500 reached.
Use set(0,'RecursionLimit',N) to change
the limit. Be aware that exceeding your
available stack space can crash MATLAB
and/or your computer.

Este es mi codigo, no se que hacer:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
%  Función Denavit-Hartenberg
function [dh ]=denavit(a,b,d,e)
dh=[cos(e) -cos(b)*sin(e)  sin(b)*sin(e) a*cos(e);
   sin(e)   cos(b)*cos(e) -sin(b)*cos(e) a*sin(e);
     0        sin(b)         cos(b)         d;
     0           0             0            1];
 
clear all; close all; clc
% CINEMATICA DIRECTA Robot RPPR
a2=0.1; l4=0.1; l1=0.2; g1=0.05; g2=0.05; g3=0.05; g4=0.05;
% Coordenadas Articulares Iniciales
q = [0 0.1 0.2 pi/4];
%------------------------------------------------------------------------
q1 = q(1); % Revoluta
q2 = q(2); % Prismática
q3 = q(3); % Prismática
q4 = q(4); % Revoluta
%------------------------------------------------------------------------
% Parámetros DH del robot
% % Parámetros Denavit-Hartenberg del robot
% e = [q1 0 0 q4 ];
% d = [l1 q2 q3 l4];
% a = [0 -a2 0 0 ];
% b = [0 -pi/2 0 0 ];
%------------------------------------------------------------------------
% Parámetros Denavit-Hartenberg del robot
% a alpha d theta
PD=[ 0 0 l1 q1
 -a2 -pi/2 q2 0
 0 0 q3 0
 0 0 l4 q4
 -g1 0 0 0
 0 0 g2 0
 g3 0 0 0
 0 0 g4 0];
%------------------------------------------------------------------------
% Matrices de transformación homogénea para cada artiuclación
A01 = denavit(PD(1,1),PD(1,2),PD(1,3),PD(1,4));% eslabon 1 movil
A12 = denavit(PD(2,1),PD(2,2),PD(2,3),PD(2,4));% eslabon 2 movil
A23 = denavit(PD(3,1),PD(3,2),PD(3,3),PD(3,4));% eslabon 3 movil
A34 = denavit(PD(4,1),PD(4,2),PD(4,3),PD(4,4));% efector final
Ag1 = denavit(PD(5,1),PD(5,2),PD(5,3),PD(5,4));
Ag2 = denavit(PD(6,1),PD(6,2),PD(6,3),PD(6,4));
Ag3 = denavit(PD(7,1),PD(7,2),PD(7,3),PD(7,4));
Ag4 = denavit(PD(8,1),PD(8,2),PD(8,3),PD(8,4));
S0=eye(4); %frame fijo (matriz identidad 4x4)
S1=A01*S0; % posición y orientación frame 1 (respect. al fijo xyz)
S2=A01*A12; % posición y orientación frame 2 (respct. al movil 1)
S3=A01*A12*A23; % posición y orientación frame 3 (respect. al movil 2)
S4=A01*A12*A23*A34; % posición y orientación frame 4(efector final)
S5=S4*Ag1; % PARA EL GRIPPER
S6=S5*Ag2; % PARA EL GRIPPER
S7=S4*Ag3; % PARA EL GRIPPER
S8=S7*Ag4; % PARA EL GRIPPER
%Extrayendo datos de eslabones para ploteo
P0=[S0(1,4) S0(2,4) S0(3,4)];
P1=[S1(1,4) S1(2,4) S1(3,4)];
P2=[S2(1,4) S2(2,4) S2(3,4)];
P3=[S3(1,4) S3(2,4) S3(3,4)];
P4=[S4(1,4) S4(2,4) S4(3,4)];
P5=[S5(1,4) S5(2,4) S5(3,4)];
P6=[S6(1,4) S6(2,4) S6(3,4)];
P7=[S7(1,4) S7(2,4) S7(3,4)];
P8=[S8(1,4) S8(2,4) S8(3,4)];
%-----------------------------ploteos------------------------------------
figure
plot3([P0(1) P1(1)],[P0(2) P1(2)],[P0(3) P1(3)],'c','LineWidth',4)
hold
plot3([P1(1) P2(1)],[P1(2) P2(2)],[P1(3) P2(3)],'r','LineWidth',4)
plot3([P2(1) P3(1)],[P2(2) P3(2)],[P2(3) P3(3)],'g','LineWidth',4)
plot3([P3(1) P4(1)],[P3(2) P4(2)],[P3(3) P4(3)],'m','Linewidth',4)
plot3([P4(1) P5(1)],[P4(2) P5(2)],[P4(3) P5(3)],'b','Linewidth',4)
plot3([P5(1) P6(1)],[P5(2) P6(2)],[P5(3) P6(3)],'b','Linewidth',4)
plot3([P4(1) P7(1)],[P4(2) P7(2)],[P4(3) P7(3)],'b','Linewidth',4)
plot3([P7(1) P8(1)],[P7(2) P8(2)],[P7(3) P8(3)],'b','Linewidth',4)
hold
frame(S0,'b',0.05),hold,frame(S1,'b',0.05),hold,frame(S2,'b',0.05)
%----------------------------resultados----------------------------------
disp('-----------------------------------------------------------------')
disp('------------------MATRIZ DE TH (ESLABON 4)-----------------------')
disp(S4)
disp('-----------------------------------------------------------------')
disp('------------------MATRIZ DE TH (ESLABON 3)-----------------------')
disp(S3)
disp('-----------------------------------------------------------------')
disp('-------------------MATRIZ DE TH (ESLABON 2)----------------------')
disp(S2)
disp('-----------------------------------------------------------------')
disp('-------------------MATRIZ DE TH (ESLABON 1)----------------------')
disp(S1)
disp('-----------------------------------------------------------------')
disp('---------------------MATRIZ DE TH (Fijo)-------------------------')
disp(S0)
disp('-----------------------------------------------------------------')
 
 
end




Gracias por su ayuda
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
sin imagen de perfil

Problemas Maximu recusrsion

Publicado por Miguel González (42 intervenciones) el 25/09/2015 19:29:28
Hola Juan,

probablemente estas cayendo en un problema de recursividad
en el cual se llama la función así mismo y se agota la memoria asignada para tal caso.
Prueba con éste código. Puse comentarios en la función frame no sé qué hace y/o matlab
no lo reconoce a no ser que sea una función tuya.

Saludos



function robot = Programa_robot

clear all;

% CINEMATICA DIRECTA Robot RPPR

a2=0.1; l4=0.1; l1=0.2; g1=0.05; g2=0.05; g3=0.05; g4=0.05;

% Coordenadas Articulares Iniciales
q = [0 0.1 0.2 pi/4];

%------------------------------------------------------------------------
q1 = q(1); % Revoluta
q2 = q(2); % Prismática
q3 = q(3); % Prismática
q4 = q(4); % Revoluta

%------------------------------------------------------------------------
% Parámetros DH del robot
% % Parámetros Denavit-Hartenberg del robot
% e = [q1 0 0 q4 ];
% d = [l1 q2 q3 l4];
% a = [0 -a2 0 0 ];
% b = [0 -pi/2 0 0 ];
%------------------------------------------------------------------------
% Parámetros Denavit-Hartenberg del robot
% a alpha d theta

PD=[ 0 0 l1 q1
-a2 -pi/2 q2 0
0 0 q3 0
0 0 l4 q4
-g1 0 0 0
0 0 g2 0
g3 0 0 0
0 0 g4 0];
%------------------------------------------------------------------------

% Matrices de transformación homogénea para cada artiuclación
A01 = denavit(PD(1,1),PD(1,2),PD(1,3),PD(1,4));% eslabon 1 movil
A12 = denavit(PD(2,1),PD(2,2),PD(2,3),PD(2,4));% eslabon 2 movil
A23 = denavit(PD(3,1),PD(3,2),PD(3,3),PD(3,4));% eslabon 3 movil
A34 = denavit(PD(4,1),PD(4,2),PD(4,3),PD(4,4));% efector final
Ag1 = denavit(PD(5,1),PD(5,2),PD(5,3),PD(5,4));
Ag2 = denavit(PD(6,1),PD(6,2),PD(6,3),PD(6,4));
Ag3 = denavit(PD(7,1),PD(7,2),PD(7,3),PD(7,4));
Ag4 = denavit(PD(8,1),PD(8,2),PD(8,3),PD(8,4));

S0=eye(4); %frame fijo (matriz identidad 4x4)
S1=A01*S0; % posición y orientación frame 1 (respect. al fijo xyz)
S2=A01*A12; % posición y orientación frame 2 (respct. al movil 1)
S3=A01*A12*A23; % posición y orientación frame 3 (respect. al movil 2)
S4=A01*A12*A23*A34; % posición y orientación frame 4(efector final)
S5=S4*Ag1; % PARA EL GRIPPER
S6=S5*Ag2; % PARA EL GRIPPER
S7=S4*Ag3; % PARA EL GRIPPER
S8=S7*Ag4; % PARA EL GRIPPER

%Extrayendo datos de eslabones para ploteo
P0=[S0(1,4) S0(2,4) S0(3,4)];
P1=[S1(1,4) S1(2,4) S1(3,4)];
P2=[S2(1,4) S2(2,4) S2(3,4)];
P3=[S3(1,4) S3(2,4) S3(3,4)];
P4=[S4(1,4) S4(2,4) S4(3,4)];
P5=[S5(1,4) S5(2,4) S5(3,4)];
P6=[S6(1,4) S6(2,4) S6(3,4)];
P7=[S7(1,4) S7(2,4) S7(3,4)];
P8=[S8(1,4) S8(2,4) S8(3,4)];
%-----------------------------ploteos------------------------------------

figure
plot3([P0(1) P1(1)],[P0(2) P1(2)],[P0(3) P1(3)],'c','LineWidth',4)

hold
plot3([P1(1) P2(1)],[P1(2) P2(2)],[P1(3) P2(3)],'r','LineWidth',4)
plot3([P2(1) P3(1)],[P2(2) P3(2)],[P2(3) P3(3)],'g','LineWidth',4)
plot3([P3(1) P4(1)],[P3(2) P4(2)],[P3(3) P4(3)],'m','Linewidth',4)
plot3([P4(1) P5(1)],[P4(2) P5(2)],[P4(3) P5(3)],'b','Linewidth',4)
plot3([P5(1) P6(1)],[P5(2) P6(2)],[P5(3) P6(3)],'b','Linewidth',4)
plot3([P4(1) P7(1)],[P4(2) P7(2)],[P4(3) P7(3)],'b','Linewidth',4)
plot3([P7(1) P8(1)],[P7(2) P8(2)],[P7(3) P8(3)],'b','Linewidth',4)
hold

%frame(S0,'b',0.05)
%hold
%frame(S1,'b',0.05)
%hold
%frame(S2,'b',0.05)

%----------------------------resultados----------------------------------
disp('-----------------------------------------------------------------')
disp('------------------MATRIZ DE TH (ESLABON 4)-----------------------')
disp(S4)
disp('-----------------------------------------------------------------')
disp('------------------MATRIZ DE TH (ESLABON 3)-----------------------')
disp(S3)
disp('-----------------------------------------------------------------')
disp('-------------------MATRIZ DE TH (ESLABON 2)----------------------')
disp(S2)
disp('-----------------------------------------------------------------')
disp('-------------------MATRIZ DE TH (ESLABON 1)----------------------')
disp(S1)
disp('-----------------------------------------------------------------')
disp('---------------------MATRIZ DE TH (Fijo)-------------------------')
disp(S0)
disp('-----------------------------------------------------------------')

robot = 1;


function dh = denavit(a,b,d,e)
% Función Denavit-Hartenberg
dh=[cos(e) -cos(b)*sin(e) sin(b)*sin(e) a*cos(e);
sin(e) cos(b)*cos(e) -sin(b)*cos(e) a*sin(e);
0 sin(b) cos(b) d;
0 0 0 1];
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar