Robot simulation of RRR robot

18 次查看(过去 30 天)
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.

采纳的回答

Chirag Gupta
Chirag Gupta 2011-3-11
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 个评论
Chirag Gupta
Chirag Gupta 2011-3-14
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 2011-4-3
[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'?

请先登录,再进行评论。

更多回答(2 个)

Chirag Gupta
Chirag Gupta 2011-3-8
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 个评论
Abraham Serrano
Abraham Serrano 2017-4-18
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 2021-2-15
I have the same problem do you solve it

请先登录,再进行评论。


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

类别

Help CenterFile Exchange 中查找有关 Grid Lines, Tick Values, and Labels 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by