Home > arte3.2.0 > lib > transform_to_own.m

transform_to_own

PURPOSE ^

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

SYNOPSIS ^

function transform_to_own(manufacturer,model, mm2m)

DESCRIPTION ^

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   Script used to change the coordinates of the points stored in STL format
   The coordinates in files link0_base.stl, link1_base.stl... are referred to
   the base reference system. The script creates the files link0.stl,
   link1.stl, link2.stl. The points in these files are referred to its own
   D-H reference
   USAGE: Please follow the steps below.
   STEPS:
       STEP 1: Name each of the links as link0_base.stl, link1_base.stl,
       link2_base.stl. And save them under the same directory of your robot,
       namely, robots/abb/IRB6620.
       The vertices in each of the STL files are referred to the reference
       system of the robot base. They are normally expressed in millimeters.
       script 

       STEP 2: In robots/abb/IRB6620/parameters.m, set robot.graphical.has_graphics=0

       STEP 3: Now you should visualize the STL files. They are normally
       referred to the robots base reference system.

       STEP 4: Write the DH parameters of your robot.

       STEP 5: The units of your STL files are generally millimeters. If they
       are meters, change the variable mm2m=1 in the following call script.
       Run transform_to_own

       >>transform_to_own('ABB', 'IRB6620', 1000)

       which changes the units in the stl file to the standard meters.
       The script should create the files link0.stl, link1.stl, ... etc.
       Each referred to its own reference system.

       STEP 6: In robots/abb/IRB6620/parameters.m, set
       robot.graphical.has_graphics=1. Now you've got graphics for your robot!

       STEP 7: Load the robot:
       >> robot=load_robot('abb', 'IRB6620');
       >> drawrobot3d(robot, [0 0 0 0 0 0])
       you should see your robot in 3D
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0002 %   Script used to change the coordinates of the points stored in STL format
0003 %   The coordinates in files link0_base.stl, link1_base.stl... are referred to
0004 %   the base reference system. The script creates the files link0.stl,
0005 %   link1.stl, link2.stl. The points in these files are referred to its own
0006 %   D-H reference
0007 %   USAGE: Please follow the steps below.
0008 %   STEPS:
0009 %       STEP 1: Name each of the links as link0_base.stl, link1_base.stl,
0010 %       link2_base.stl. And save them under the same directory of your robot,
0011 %       namely, robots/abb/IRB6620.
0012 %       The vertices in each of the STL files are referred to the reference
0013 %       system of the robot base. They are normally expressed in millimeters.
0014 %       script
0015 %
0016 %       STEP 2: In robots/abb/IRB6620/parameters.m, set robot.graphical.has_graphics=0
0017 %
0018 %       STEP 3: Now you should visualize the STL files. They are normally
0019 %       referred to the robots base reference system.
0020 %
0021 %       STEP 4: Write the DH parameters of your robot.
0022 %
0023 %       STEP 5: The units of your STL files are generally millimeters. If they
0024 %       are meters, change the variable mm2m=1 in the following call script.
0025 %       Run transform_to_own
0026 %
0027 %       >>transform_to_own('ABB', 'IRB6620', 1000)
0028 %
0029 %       which changes the units in the stl file to the standard meters.
0030 %       The script should create the files link0.stl, link1.stl, ... etc.
0031 %       Each referred to its own reference system.
0032 %
0033 %       STEP 6: In robots/abb/IRB6620/parameters.m, set
0034 %       robot.graphical.has_graphics=1. Now you've got graphics for your robot!
0035 %
0036 %       STEP 7: Load the robot:
0037 %       >> robot=load_robot('abb', 'IRB6620');
0038 %       >> drawrobot3d(robot, [0 0 0 0 0 0])
0039 %       you should see your robot in 3D
0040 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0041 
0042 % Copyright (C) 2012, by Arturo Gil Aparicio
0043 %
0044 % This file is part of ARTE (A Robotics Toolbox for Education).
0045 %
0046 % ARTE is free software: you can redistribute it and/or modify
0047 % it under the terms of the GNU Lesser General Public License as published by
0048 % the Free Software Foundation, either version 3 of the License, or
0049 % (at your option) any later version.
0050 %
0051 % ARTE is distributed in the hope that it will be useful,
0052 % but WITHOUT ANY WARRANTY; without even the implied warranty of
0053 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0054 % GNU Lesser General Public License for more details.
0055 %
0056 % You should have received a copy of the GNU Leser General Public License
0057 % along with ARTE.  If not, see <http://www.gnu.org/licenses/>.
0058 
0059 function transform_to_own(manufacturer,model, mm2m)
0060 
0061 %save current path
0062 path=pwd;
0063 
0064 %load basic parameters for the robot
0065 %CHANGE ROBOT name accordingly
0066 robot = load_robot(manufacturer, model);
0067 
0068 q=[0 0 0 0 0 0];
0069 % Denavit-Hartenberg parameters of the robot
0070 theta = eval(robot.DH.theta);
0071 d = eval(robot.DH.d);
0072 a = eval(robot.DH.a);
0073 alfa = eval(robot.DH.alpha);
0074 
0075 n=length(theta); %# number of DOFs
0076 T=eye(4);
0077 
0078 for i=0:robot.DOF,
0079     fprintf('\nReading link %d BASE\n %s\n', i, sprintf([robot.path '/link%d_base.stl'], i));
0080     %read file in base reference system. Please note that link0 is already
0081     %defined in the base reference system. In the first loop T= identity
0082     [fout, vout, cout] = stl_read(sprintf([robot.path '/link%d_base.stl'], i));
0083     
0084     %change points from mm to meters.
0085     V=vout/mm2m;
0086     V(:,4) = ones(length(V),1); %homogeneous coordinates
0087    
0088     %You can also specify any homogeneous transformation matrix here
0089     %      T=[1 0 0 -0.06/2;
0090     %         0 1 0 0.1/2;
0091     %         0 0 1 0.02/2;
0092     %         0 0 0 1]
0093    
0094    %Or even re-scale the points
0095     %        T=[2 0 0 0;
0096     %          0 1/2 0 0;
0097     %          0 0 1/5 0;
0098     %          0 0 0 1];
0099     
0100     %inverse transform, the points V in link i are now referred to its own D-H reference system
0101     V = (inv(T)*V')';
0102     V  = V(:,1:3);
0103     fprintf('\nWriting link %d\n %s\n', i, sprintf([robot.path '/link%d.stl'], i));
0104     stlwrite(sprintf([robot.path '/link%d.stl'], i), fout, V, 'mode', 'ascii');
0105     %compute transformation for the next link
0106     if (i+1) > robot.DOF
0107         continue;
0108     end
0109     T = T*dh(theta(i+1), d(i+1), a(i+1), alfa(i+1));
0110 end
0111 
0112 %restore path
0113 cd(path);
0114 
0115 %load the robot again for changes to take place
0116 robot = load_robot(manufacturer, model);
0117

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