http://www.youtube.com/watch?v=QMkykqeSVWg&feature=related Anyone can tell me how to this simulation? I think it is in the field of mechatronics student. I just want to know how to plot the 3 links robot, the tracing part is not an important issue.

 Akzeptierte Antwort

Chirag Gupta
Chirag Gupta am 11 Mär. 2011

0 Stimmen

Crude code for a 3 link RRR robot given DH params:
figure;
h = plot3(0,0,0);p = get(h,'Parent');xlim(p,'manual');
xlim(p,[0 2]);ylim(p,'manual');ylim(p,[0 2]);zlim(p,'manual');
zlim(p,[0 2]);axis vis3d;grid on;
point1.x =0;point1.y = 0;point1.z = 0;
point2.x = 0;point2.y = 0;point2.z = 1;
point3.x = 0;point3.y = 0;point3.z = 1;
point4.x = 2;point4.y = 0;point4.z = 1;
l= line([point1.x, point2.x],[point1.y,point2.y],[point1.z,point2.z],'Color','r','LineWidth',4);
l1 = line([point2.x, point3.x],[point2.y,point3.y],[point2.z,point3.z],'Color','b','LineWidth',4);
l2 = line([point3.x, point4.x],[point3.y,point4.y],[point3.z,point4.z],'Color','g','LineWidth',4);
pause(0.5);
theta2 = 30;
theta3 =0;
for theta1 =70:-1:0
[point2,point3,point4] = fromDHandTheta(theta1,theta1,theta1); %(each individual theta)
set(l,'ZData',[point1.z,point2.z],'YData',[point1.y,point2.y],'XData',[point1.x,point2.x]);
set(l1,'ZData',[point2.z,point3.z],'YData',[point2.y,point3.y],'XData',[point2.x,point3.x]);
set(l2,'ZData',[point3.z,point4.z],'YData',[point3.y,point4.y],'XData',[point3.x,point4.x]);
hold on;
plot3(point4.x,point4.y,point4.z,'xk');
pause(0.1);
end
end
function [point2,point3,point4] = fromDHandTheta(theta1,theta2,theta3)
% D-H Params:
% N Theta Alpha dN rN
% 1 theta1 alpha1 0 0
% 2 theta2 alpha2 1 0
% 3 theta3 alpha3 1 0
s1 = [0;0;0]; % from dN and rN
s2 = [1;0;0];
s3 = [1;0;0];
alpha1 = 90;
alpha2 = 0;
alpha3 = 0;
pointa = returnUfromTheta(theta1)*returnVfromAlpha(alpha1)*s1 + [0;0;1]; % [0;0;1] is orig position
pointb = returnUfromTheta(theta1)*returnVfromAlpha(alpha1)*returnUfromTheta(theta2)*returnVfromAlpha(alpha2)*s2 + pointa;
pointc = returnUfromTheta(theta1)*returnVfromAlpha(alpha1)*returnUfromTheta(theta2)*returnVfromAlpha(alpha2)*...
returnUfromTheta(theta3)*returnVfromAlpha(alpha3)*s3 + pointb;
point2.x = pointa(1); point2.y = pointa(2); point2.z = pointa(3);
point3.x = pointb(1); point3.y = pointb(2); point3.z = pointb(3);
point4.x = pointc(1); point4.y = pointc(2); point4.z = pointc(3);
end
function U = returnUfromTheta(theta)
U = [ cosd(theta), -sind(theta), 0;...
sind(theta), cosd(theta), 0 ;...
0, 0, 1];
end
function V = returnVfromAlpha(alpha)
V = [ 1, 0 ,0;...
0, cosd(alpha), -sind(alpha);...
0, sind(alpha), cosd(alpha)];
end

3 Kommentare

Cheng Yoong
Cheng Yoong am 12 Mär. 2011
Thanks man.This is really helpful.Anyway can you explain the function of this line?
h = plot3(0,0,0);p = get(h,'Parent');xlim(p,'manual');
what is p?and what is the function of 'Parent' and 'manual'?
Chirag Gupta
Chirag Gupta am 14 Mär. 2011
plot3(0,0,0) was just to open a emtyp 3d plot. The 'Parent' and 'manula' are various properties relating to handle graphics.
I get the axis handle using the Parent property. The property 'manual' just refers to setting up of the axis limits. 'manual' ensures that the x axis limit will remain fixed and not auto adjust.
Cheng Yoong
Cheng Yoong am 3 Apr. 2011
[point2,point3,point4] = fromDHandTheta(theta1,theta1,theta1);
I don't have to define the DHandTheta this parameter?
What is the purpose for returnUfromTheta and other return'something'from'something'?

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (2)

Chirag Gupta
Chirag Gupta am 8 Mär. 2011

0 Stimmen

There are numerous ways to plot the 3 links. A simple way would be to use the line function. Assuming you always know the end positions of your links. A crude simple example(2 links):
figure;
h = plot3(0,0,0);
p = get(h,'Parent');
xlim(p,'manual');
xlim(p,[0 2]);
ylim(p,'manual');
ylim(p,[0 2]);
zlim(p,'manual');
zlim(p,[0 2]);
axis vis3d;
grid on;
point1.x =0;
point1.y = 0;
point1.z = 0;
point2.x = 1;
point2.y = 1;
point2.z = 1;
point3.x = 1.5;
point3.y = 1;
point3.z = 1.2;
l= line([point1.x, point2.x],[point1.y,point2.y],[point1.z,point2.z],'Color','r','LineWidth',4);
l1 = line([point2.x, point3.x],[point2.y,point3.y],[point2.z,point3.z],'Color','b','LineWidth',4);
for i =0.1:0.1:1
set(l,'ZData',[point1.z,i],'YData',[point1.y,i]);
set(l1,'ZData',[i,point3.z],'YData',[i,point3.y]);
pause(0.1);
end

6 Kommentare

Cheng Yoong
Cheng Yoong am 9 Mär. 2011
How about if I don't know the position of the end position of link?
Chirag Gupta
Chirag Gupta am 9 Mär. 2011
What information do you have? If you know the trajectories of the robot, then possibly you know the individual angles of the links. Knowing the angles, you should be able to compute the end points your links, if you have the D-H parameters.
Cheng Yoong
Cheng Yoong am 10 Mär. 2011
So far I have the DH parameters.I want to make a GUI software that simulate the manipulator.I want user to key in angle instead end position of end effector.
My biggest problem now is I dont know how to define the DH parameters in Matlab.And what is the forward kinematic equation to use to plot the links.
Chirag Gupta
Chirag Gupta am 11 Mär. 2011
If you have the D-H parameters, then you can get the individual Rotation matrices around X axis ( Alphas of the D-H params), you know the rotation about the Z axis (thetas which you are going to key in) and the vector that you can form from a and r's [a;0;r]
Let Rotation Matrix about the X axis be V = [1 0 0;0 cos(alpha) -sin(alpha); 0 sin(alpha) cos(alpha)]
This value is known as you know each alpha. These can be V1 (alpha1), V2 and V3
Similarly Rotation Matrix about Z axis be U = [cos(theta) -sin(theta) 0; ....]
s vectors from a's and r's [a;0;r]
Then: link1 = U1*V1*s1
link2 = U2*V2*U1*V1*s2 + U1*V1*s1
link3 = U3*V3*U2*V2*U1*V1*s3 + U2*V2*U1*V1*s2 + U1*V1*s1
These will give you the end positions from the same frame of reference.
Abraham Serrano
Abraham Serrano am 18 Apr. 2017
Hello! I´m trying to do this but with a 4R manipulator, right know I have the D-H parameters and the FK equations. I know this thread is 6 years old but I hope anyone can help me. What do I have to do to add another joint and link? I don´t know anything about matlab. Thanks in advance.
Sabrine Ouhichi
Sabrine Ouhichi am 15 Feb. 2021
I have the same problem do you solve it

Melden Sie sich an, um zu kommentieren.

reyam ahmed
reyam ahmed am 11 Nov. 2017

0 Stimmen

i want to plot 2-link robot manipulator using dynamic equation , can you help me?

Kategorien

Community Treasure Hunt

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

Start Hunting!

Translated by