%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LOAD_ROBOT Loads a data structure corresponding to the specified robot. robot = LOAD_ROBOT(MANUFACTURER, VERSION) returns a robot data structure of the specified robot. Each robot parameters' are stored in the directory named robots/manufacturer/version. For example: Example: robot = load_robot('ABB', 'IRB140') gets the available data for the ABB IRB140 robotic arm whose parameters are stored in the directory robots/ABB/IRB140 robot = LOAD_ROBOT(PATH) specifies a relative path to the robots directory. For example: robot = load_robot('ABB/IRB140') robot = LOAD_ROBOT() with no arguments opens a dialog box to select a robot's parameters file. Execute SUPPORTED_ROBOTS to see a list of all supported robots. The robot data structure consists of the following fields: See also SUPPORTED_ROBOTS. Author: Arturo Gil. Universidad Miguel Hern�ndez de Elche. email: arturo.gil@umh.es date: 02/01/2012 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0001 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0002 % LOAD_ROBOT Loads a data structure corresponding to the specified robot. 0003 % 0004 % 0005 % robot = LOAD_ROBOT(MANUFACTURER, VERSION) returns a robot data 0006 % structure of the specified robot. Each robot parameters' are stored in 0007 % the directory named robots/manufacturer/version. For example: 0008 % 0009 % Example: 0010 % robot = load_robot('ABB', 'IRB140') 0011 % 0012 % gets the available data for the ABB IRB140 robotic arm whose 0013 % parameters are stored in the directory robots/ABB/IRB140 0014 % 0015 % robot = LOAD_ROBOT(PATH) specifies a relative path to the robots 0016 % directory. For example: 0017 % robot = load_robot('ABB/IRB140') 0018 % 0019 % robot = LOAD_ROBOT() with no arguments opens a dialog box to select a 0020 % robot's parameters file. 0021 % 0022 % 0023 % Execute 0024 % SUPPORTED_ROBOTS to see a list of all supported robots. 0025 % 0026 % The robot data structure consists of the following fields: 0027 % 0028 % See also SUPPORTED_ROBOTS. 0029 % 0030 % Author: Arturo Gil. Universidad Miguel Hern�ndez de Elche. email: 0031 % arturo.gil@umh.es date: 02/01/2012 0032 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0033 0034 % Copyright (C) 2012, by Arturo Gil Aparicio 0035 % 0036 % This file is part of ARTE (A Robotics Toolbox for Education). 0037 % 0038 % ARTE is free software: you can redistribute it and/or modify 0039 % it under the terms of the GNU Lesser General Public License as published by 0040 % the Free Software Foundation, either version 3 of the License, or 0041 % (at your option) any later version. 0042 % 0043 % ARTE is distributed in the hope that it will be useful, 0044 % but WITHOUT ANY WARRANTY; without even the implied warranty of 0045 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0046 % GNU Lesser General Public License for more details. 0047 % 0048 % You should have received a copy of the GNU Leser General Public License 0049 % along with ARTE. If not, see <http://www.gnu.org/licenses/>. 0050 %function robot = load_robot(manufacturer, version) 0051 0052 function robot = load_robot(varargin) 0053 0054 global configuration %robot 0055 0056 %process variable number of arguments 0057 %if the function is called with no arguments then a dialog 0058 %box is used to retrieve the absolute path of the parameters.m file. 0059 if nargin==0 0060 [FileName,PathName,FilterIndex] = uigetfile({'*.m','Parameter-files (*.m)'},'Pick a robot parameters.m file', 'MultiSelect', 'off'); 0061 full_name=[PathName '/' FileName]; 0062 cd(PathName); 0063 elseif nargin==1 % the relative path is expressed in a single argument%load base libpath 0064 cd(configuration.libpath); 0065 % go to the directory where the robot is stored 0066 temp_path = [ configuration.libpath '/robots/' varargin{1}]; 0067 cd(temp_path); 0068 0069 %make a command to evaluate the parameter.m file at this directory 0070 full_name = [temp_path '/parameters.m']; 0071 0072 elseif nargin==2 % the relative path is expressed in the 'manufacturer', 'version' style 0073 manufacturer = varargin{1}; 0074 version = varargin{2}; 0075 %load base libpath 0076 cd(configuration.libpath); 0077 % go to the directory where the robot is stored 0078 temp_path = [ configuration.libpath '/robots/' manufacturer '/' version]; 0079 cd(temp_path); 0080 0081 %make a command to evaluate the parameter.m file at this directory 0082 full_name = [temp_path '/parameters.m']; 0083 end 0084 0085 %initialize robot data structure 0086 %robot=[]; 0087 0088 0089 0090 %Eval parameters file for the selected robot 0091 %eval(command); 0092 %check whether the parameters.m file exists at the required location 0093 if exist(full_name,'file')==2 0094 robot=eval('parameters'); 0095 0096 %now draw robot 0097 drawrobot3d(robot, zeros(1,robot.DOF)); 0098 %default view 0099 axis(robot.axis); 0100 else %if there's no parameters.m file 0101 fprintf('ERROR: No valid parameters.m file found. Please check the following directory') 0102 full_name 0103 end 0104 0105 0106 0107 0108