MATLAB机器⼈⼯具箱错误合集
⽬录
尝试将 SCRIPT robot 作为函数执⾏
运⾏程序:
clc
clear
close all
%绘制机器⼈
m=143.5;
alpha=[pi/2 pi pi/2 pi/2-pi/20];
a=[150600100000];
d=[000-6150100+m];
theta=[0 pi/200 pi 0];
L{1}=Link([alpha(1)a(1)0d(1)]);
L{2}=Link([alpha(2)a(2) pi/2d(2)]);
L{3}=Link([alpha(3)a(3)0d(3)]);
L{4}=Link([alpha(4)a(4)0d(4)]);
L{5}=Link([alpha(5)a(5)-pi d(5)]);
L{6}=Link([alpha(6)a(6)0d(6)]);
JRB =robot(L,'JRB');
JRB.name ='JRB';
plot(JRB,theta);
drivebot(JRB);
报错:
尝试将 SCRIPT robot 作为函数执⾏:
D:\Applications\matlab\MATLAB\toolbox\rvctools\robot\demos\robot.m
出错 Untitled3 (line 16)
JRB = robot(L,‘JRB’);
(如果是英⽂版,错误应该是Attempt to execute SCRIPT robot as a function:
G:\MATLAB2012\toolbox\robot-9.8\rvctools\robot\demos\robot.m)
错误原因
MATLAB运⾏⽬录下有个同名的 robot.m⽂件,它与此函数冲突。
所以不能⽤robot函数了,⽹上这个代码有点⽼了,新的都不再使⽤了。
现在⽤的是SerialLink函数了,不是robot,drivebot也变成了teach函数
可以直接仿照机器⼈⼯具箱下的demo⽂件robot.m编写(直接运⾏robot.m就可以看到效果图啦~)两个同问题的参考链接:
1.
2.
demo的参考代码
%%begin
% A serial link manipulator comprises a series of links.  Each link is described
% by four Denavit-Hartenberg parameters.
%
% Let's define a simple 2 link manipulator.  The first link is
L1 =Link('d',0,'a',1,'alpha', pi/2)
% The Link object we created has a number of properties
L1.a
L1.d
%and we determine that it is a revolute joint
L1.isrevolute
% For a given joint angle, say q=0.2 rad, we can determine the link transform
% matrix
L1.A(0.2)
% The second link is
L2 =Link('d',0,'a',1,'alpha',0)
% Now we need to join these into a serial-link robot manipulator
bot =SerialLink([L1 L2],'name','my robot')
% The displayed robot object shows a lot of details.  It also has a number of
% properties such as the number of joints
bot.n
% Given the joint angles q1 =0.1and q2 =0.2 we can determine the pose of the % robot's end-effector
bot.fkine([0.10.2])
tool工具箱% which is referred to as the forward kinematics of the robot.  This,and the
% inverse kinematics are covered in separate demos.
% Finally we can draw a stick figure of our robot
bot.plot([0.10.2])
对于每⼀个语句的运⾏结果如下
>> L1 =Link('d',0,'a',1,'alpha', pi/2)
L1 =
theta=q, d=0, a=1, alpha=  1.571, offset=0(R,stdDH) >> L1.a
ans =
1
>> L1.d
ans =
>> L1.isrevolute
ans =
1
>> L1.A(0.2)
ans =
0.9801-0.00000.19870.9801
0.19870.0000-0.98010.1987
0  1.00000.00000
000  1.0000
>> L2 =Link('d',0,'a',1,'alpha',0)
L2 =
theta=q, d=0, a=1, alpha=0, offset=0(R,stdDH)
>> bot =SerialLink([L1 L2],'name','my robot')
bot =
my robot (2 axis, RR, stdDH, fastRNE)
+---+-----------+-----------+-----------+-----------+-----------+
| j |    theta |        d |        a |    alpha |    offset |
+---+-----------+-----------+-----------+-----------+-----------+
|1|        q1|0|1|  1.571|0|
|2|        q2|0|1|0|0|
+---+-----------+-----------+-----------+-----------+-----------+
grav =0  base =1000  tool =1000
001000100
9.8100100010
00010001
>> bot.n
ans =
2
>> bot.fkine([0.10.2])
ans =
0.9752-0.19770.0998  1.9702
0.0978-0.0198-0.99500.1977
0.19870.98010.00000.1987
000  1.0000
>> bot.plot([0.10.2])
>>
错误使⽤ - 内存不⾜。请键⼊ HELPMEMORY 查看选项。
L1 =Link([0,450,0,0,0,0],'modified');
L2 =Link([0,0,160,-pi/2,0,-pi/2],'modified');
L3 =Link([0,0,580,0,0,0],'modified');
L4 =Link([0,640,200,-pi/2,0,0],'modified');
L5 =Link([0,0,0,        pi/2,0,0],'modified');
L6 =Link([0,228,0,-pi/2,0,0],'modified');
robot=SerialLink([L1,L2,L3,L4,L5,L6]);%SerialLink 类函数
robot.display();%Link 类函数
theta=[000000];
robot.plot(theta);%SerialLink 类函数
错误原因
robotics toolbox 9.10版本基本单位是m,⽽我们⽤的是mm单位,缩⼩1000倍即可

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。