想使用matlab机器人工具箱的命令robot.plot3d命令,然后跟着网上教程做完之后显示:
函数或变量 'v' 无法识别。
出错 SerialLink/plot3d>rndread (第 469 行)
vout = v'; % "
出错 SerialLink/plot3d (第 124 行)
[F,P] = rndread( fullfile(pth, sprintf('link%d.stl', i-1)) );
请问大佬们怎么解决
↓我的代码
clear;
clc;
% theta d a alpha offset
L(1)=Link([0 0.215 0 pi/2],'standard'); %定义连杆的D-H参数
L(2)=Link([0 0 1 0],'standard');
L(3)=Link([0 0 0.8 0],'standard');
L(4)=Link([0 0 0.7 -pi/2],'standard');
L(5)=Link([0 0 0.23 0],'standard');
Robot=SerialLink(L,'name','Robot');
Robot.base=transl(0,0,0);
L(2).qlim=[0,120/180*pi];
L(3).qlim=[-170/180*pi,-20/180*pi];
L(4).qlim=[10/180*pi,160/180*pi];
L(5).qlim=[-120/180*pi,120/180*pi];
v=[130 20];%观看视角【方位角,仰角】
w=[-2 2 -2 2 0 2.5];%工作空间大小
q0=[0,92*pi/180,210*pi/180,137*pi/180,-80*pi/180];%工作角度
Robot.plot3d(q0,'tilesize',0.1,'workspace',w,'path','C:\Users\administor\Desktop\robot','nowrist','view',v);
light('posotion',[1 1 1],'color','w');
报错后查看错误代码内容
function [fout, vout, cout] = rndread(filename)
% Reads CAD STL ASCII files, which most CAD programs can export.
% Used to create Matlab patches of CAD 3D data.
% Returns a vertex list and face list, for Matlab patch command.
%
% filename = 'hook.stl'; % Example file.
%
fid=fopen(filename, 'r'); %Open the file, assumes STL ASCII format.
if fid == -1
error('File could not be opened, check name or path.')
end
%
% Render files take the form:
%
%solid BLOCK
% color 1.000 1.000 1.000
% facet
% normal 0.000000e+00 0.000000e+00 -1.000000e+00
% normal 0.000000e+00 0.000000e+00 -1.000000e+00
% normal 0.000000e+00 0.000000e+00 -1.000000e+00
% outer loop
% vertex 5.000000e-01 -5.000000e-01 -5.000000e-01
% vertex -5.000000e-01 -5.000000e-01 -5.000000e-01
% vertex -5.000000e-01 5.000000e-01 -5.000000e-01
% endloop
% endfacet
%
% The first line is object name, then comes multiple facet and vertex lines.
% A color specifier is next, followed by those faces of that color, until
% next color line.
%
CAD_object_name = sscanf(fgetl(fid), '%*s %s'); %CAD object name, if needed.
% %Some STLs have it, some don't.
vnum=0; %Vertex number counter.
report_num=0; %Report the status as we go.
VColor = 0;
%
while feof(fid) == 0 % test for end of file, if not then do stuff
tline = fgetl(fid); % reads a line of data from file.
fword = sscanf(tline, '%s '); % make the line a character string
% Check for color
if strncmpi(fword, 'c',1) == 1; % Checking if a "C"olor line, as "C" is 1st char.
VColor = sscanf(tline, '%*s %f %f %f'); % & if a C, get the RGB color data of the face.
end % Keep this color, until the next color is used.
if strncmpi(fword, 'v',1) == 1; % Checking if a "V"ertex line, as "V" is 1st char.
vnum = vnum + 1; % If a V we count the # of V's
report_num = report_num + 1; % Report a counter, so long files show status
if report_num > 249;
%disp(sprintf('Reading vertix num: %d.',vnum));
report_num = 0;
end
v(:,vnum) = sscanf(tline, '%*s %f %f %f'); % & if a V, get the XYZ data of it.
c(:,vnum) = VColor; % A color for each vertex, which will color the faces.
end % we "*s" skip the name "color" and get the data.
end
% Build face list; The vertices are in order, so just number them.
%
fnum = vnum/3; %Number of faces, vnum is number of vertices. STL is triangles.
flist = 1:vnum; %Face list of vertices, all in order.
F = reshape(flist, 3,fnum); %Make a "3 by fnum" matrix of face list data.
%
% Return the faces and vertexs.
%
fout = F'; %Orients the array for direct use in patch.
vout = v'; % "
cout = c';
%
fclose(fid);
end
就是其中那个vout=v';%''出了问题,显示函数或变量 'v' 无法识别。
请问大佬们怎么解决呀
版权声明:本文为LaoBi_1998原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。