Home > arte3.2.0 > tools > read_graphics.m

read_graphics

PURPOSE ^

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

SYNOPSIS ^

function robot=read_graphics(robot)

DESCRIPTION ^

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 ROBOT=READ_GRAPHICS(ROBOT)    
 Reads the 3D graphics files associated to the robot.
 Each robot has N+1 graphics files stored at its directory: robot/abb/IRB140
 link0.stl, link1.stl, ..., link6.stl, where link0.stl defines the robot
 base, link1.stl, the first link connecting the base and link 2 etc.
 Each graphics file is defined in STL (Standard Tessellation Language)
 format, supported by many 3D software packages:
   http://en.wikipedia.org/wiki/STL_%28file_format%29

 Prior to the call of READ_GRAPHICS, the variable
 robot.graphical.has_graphics has to be set to one.

 ROBOT=READ_GRAPHICS(ROBOT), stores the current robot Faces and vertices
 of each file in the variables:
   
  robot.graphical.link{1}.f --> faces robot base, 
  robot.graphical.link{1}.v --> vertices robot base,
  robot.graphical.link{2}.f --> faces link 1, 
  robot.graphical.link{2}.v --> vertices link 1...

  the vector f defines the position of a set of points that represent each
  robot link in its current DH reference system. The units of f are
  meters.

  READ_GRAPHICS calls the function STL_READ, in charge of reading each of
  the files associated to the robot.

 See also DRAW_LINK, DRAW_PATCH, STL_READ.

   Author: Arturo Gil. Universidad Miguel Hernández de Elche.
   email: arturo.gil@umh.es date:   05/02/2012
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0002 % ROBOT=READ_GRAPHICS(ROBOT)
0003 % Reads the 3D graphics files associated to the robot.
0004 % Each robot has N+1 graphics files stored at its directory: robot/abb/IRB140
0005 % link0.stl, link1.stl, ..., link6.stl, where link0.stl defines the robot
0006 % base, link1.stl, the first link connecting the base and link 2 etc.
0007 % Each graphics file is defined in STL (Standard Tessellation Language)
0008 % format, supported by many 3D software packages:
0009 %   http://en.wikipedia.org/wiki/STL_%28file_format%29
0010 %
0011 % Prior to the call of READ_GRAPHICS, the variable
0012 % robot.graphical.has_graphics has to be set to one.
0013 %
0014 % ROBOT=READ_GRAPHICS(ROBOT), stores the current robot Faces and vertices
0015 % of each file in the variables:
0016 %
0017 %  robot.graphical.link{1}.f --> faces robot base,
0018 %  robot.graphical.link{1}.v --> vertices robot base,
0019 %  robot.graphical.link{2}.f --> faces link 1,
0020 %  robot.graphical.link{2}.v --> vertices link 1...
0021 %
0022 %  the vector f defines the position of a set of points that represent each
0023 %  robot link in its current DH reference system. The units of f are
0024 %  meters.
0025 %
0026 %  READ_GRAPHICS calls the function STL_READ, in charge of reading each of
0027 %  the files associated to the robot.
0028 %
0029 % See also DRAW_LINK, DRAW_PATCH, STL_READ.
0030 %
0031 %   Author: Arturo Gil. Universidad Miguel Hernández de Elche.
0032 %   email: arturo.gil@umh.es date:   05/02/2012
0033 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0034 
0035 % Copyright (C) 2012, by Arturo Gil Aparicio
0036 %
0037 % This file is part of ARTE (A Robotics Toolbox for Education).
0038 %
0039 % ARTE is free software: you can redistribute it and/or modify
0040 % it under the terms of the GNU Lesser General Public License as published by
0041 % the Free Software Foundation, either version 3 of the License, or
0042 % (at your option) any later version.
0043 %
0044 % ARTE is distributed in the hope that it will be useful,
0045 % but WITHOUT ANY WARRANTY; without even the implied warranty of
0046 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0047 % GNU Lesser General Public License for more details.
0048 %
0049 % You should have received a copy of the GNU Leser General Public License
0050 % along with ARTE.  If not, see <http://www.gnu.org/licenses/>.
0051 function robot=read_graphics(robot)
0052 
0053 %degrees of freedom
0054 n=robot.DOF;
0055 
0056 if robot.graphical.has_graphics    
0057     
0058     full_name = [robot.path '/link0.stl'];
0059     
0060     %check whether there exist graphics files for the robot
0061     if exist(full_name, 'file')~=2
0062         disp('NO GRAPHICS FILE FOUND, not reading graphics');
0063         disp('Please, remember to place link0.stl, link1.stl at each robot directory');
0064         disp('Check the following directory: ')
0065         robot.path
0066         robot.graphical.has_graphics=0
0067         return;
0068     end
0069     pwd
0070     for i=0:n,
0071         link_name=sprintf('/link%d.stl', i);
0072         fprintf('\nReading link %d\n %s\n', i, [robot.path link_name]);
0073         %load link 0, base
0074         [fout, vout, cout] = stl_read([robot.path link_name]);
0075         robot.graphical.link{i+1}.f = fout;
0076         robot.graphical.link{i+1}.v = vout;
0077         %robot.graphical.link{i+1}.c = cout+robot.graphical.color;
0078     end
0079     %load a default color if not specified
0080     if robot.graphical.color(1) > 1.0
0081         robot.graphical.color = [204 51 0]./255;
0082         disp('NO VALID COLOR FOUND, PLEASE SPECIFY robot.graphical.color as [0.5 0.6 0.7]');
0083     end
0084 end

Generated on Fri 03-Jan-2014 12:20:01 by m2html © 2005