【发布时间】:2014-01-10 12:12:33
【问题描述】:
我在 Matlab 中使用 Peter Corke 的机器人工具箱。我有 puma560 机器人的 .m 文件(它用于机器人轨迹。机器人遵循给定的路径)。当我尝试使用前。机器人工具箱中的“sl_ctorque”simulink 文件(它是关于计算扭矩方法),我无法将我的 .m 文件集成到 simulink 文件中。我的 .m 文件如下所示。因此,如果有人知道如何实现这个想法,我将不胜感激。谢谢!
clear;clc;
mdl_puma560 %to create puma robot
for type=1:3 % main for loop. It turns 3 times. At first, it sets the path
% to x-y plane and draw the robot, at second for y-z plane
% and then for x-z plane
if type==1
% The path of robot for x-y plane
path=[0 0 1;0 0 0;0 2 0 ;0.5 1 0 ;1 2 0;1 0 0;1.5 0 1;1.5 0 0;
1.5 2 0;2.2 2 0;2.5 1.6 0;2.5 0.4 0;2.2 0 0;1.5 0 0;0 0 1];
elseif type==2
% Same thing as first part
path=[-0.5 0 0;0 0 0;0 0 1;0 -0.5 0.5;0 -1 1;0 -1 0;-0.5 -1.2 0;0 -1.2 0;
0 -1.2 1;0 -1.7 1;0 -2 0.7;0 -2 0.3;0 -1.7 0;0 -1.2 0];
elseif type==3
% Same thing as first and second part
path=[0 -0.5 0;0 0 0;0 0 1;0.5 0 0.5;1 0 1;1 0 0;1.3 -0.5 0;1.3 0 0;
1.3 0 1;1.7 0 1;2 0 0.7;2 0 0.3;1.7 0 0;1.3 0 0];
end
% I created a trajectory
p=mstraj(path, [15 15 15], [], [1 0 1], 0.02 , 0.2);
% [15 15 15] means the maximum speed in x,y,z directions.
% [1 0 1] means the initial coordinates
% 0.02 means acceleration time
% 0.2 means smoothness of robot
numrows(p)*0.2; % 200 ms sample interval
Tp=transl(0.1*p); % Scale factor of robot
Tp=homtrans( transl(0.4,0,0),Tp); % Origin of the letter
q=p560.ikine6s(Tp); % The inverse kinematic
for i=1:length(q)
% q matrix has 280 rows and 6 columns. So this for loop turns 280 times
% At every turns , it plots one part of movement. q(1,:), q(2,:), ...
p560.plot(q(i,:))
end
end
【问题讨论】:
-
如前所述,这里没有人会知道机器人工具箱,它是一个非常“小众”的工具箱,不是标准 MATLAB 版本的一部分,我之前从未听说过它阅读您的帖子。
-
@am304 我的帖子不仅仅是关于机器人工具箱,这个工具箱只是一个例子。如果您知道如何将任何 .m 文件集成到任何 .mdl 文件中,请帮助我。
-
被问到的方式,听起来像是机器人工具箱特有的。请参阅 NKN 在 Simulink 中集成 MATLAB 函数的答案。
标签: matlab model simulink robotics robot