Home > @robot > subsref.m

subsref

PURPOSE ^

SUBSREF Reference methods on a ROBOT object

SYNOPSIS ^

function v = subsref(r, s)

DESCRIPTION ^

SUBSREF Reference methods on a ROBOT object

    ROBOT.n            return number of links
    ROBOT.link        return cell array of link objects
    ROBOT.gravity         return gravity vector
    ROBOT.base         return homog xform of robot base
    ROBOT.tool         return homog xform of robot tool
    ROBOT.qlim         return joint limit matrix
    ROBOT.offset         return joint offset vector
    ROBOT.mdh        return MDH convention boolean (0=DH, 1=MDH)

    ROBOT.islimit         return joint limit boolean vector

    ROBOT.name        return name of robot
    ROBOT.manuf        return who built it
    ROBOT.comment        return general comment
    ROBOT.config        return joint configuration string

    ROBOT.plotopt         return options for plot(robot)
    ROBOT.lineopt         return line drawing option string for links
    ROBOT.shadowopt     return line drawing option string for shadow
    ROBOT.handle        return graphics handles in object
    ROBOT.q         return joint angles for plot(robot)

    ROBOT.dh        return legacy DH matrix
    ROBOT.dyn        return legacy DYN matrix

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %SUBSREF Reference methods on a ROBOT object
0002 %
0003 %    ROBOT.n            return number of links
0004 %    ROBOT.link        return cell array of link objects
0005 %    ROBOT.gravity         return gravity vector
0006 %    ROBOT.base         return homog xform of robot base
0007 %    ROBOT.tool         return homog xform of robot tool
0008 %    ROBOT.qlim         return joint limit matrix
0009 %    ROBOT.offset         return joint offset vector
0010 %    ROBOT.mdh        return MDH convention boolean (0=DH, 1=MDH)
0011 %
0012 %    ROBOT.islimit         return joint limit boolean vector
0013 %
0014 %    ROBOT.name        return name of robot
0015 %    ROBOT.manuf        return who built it
0016 %    ROBOT.comment        return general comment
0017 %    ROBOT.config        return joint configuration string
0018 %
0019 %    ROBOT.plotopt         return options for plot(robot)
0020 %    ROBOT.lineopt         return line drawing option string for links
0021 %    ROBOT.shadowopt     return line drawing option string for shadow
0022 %    ROBOT.handle        return graphics handles in object
0023 %    ROBOT.q         return joint angles for plot(robot)
0024 %
0025 %    ROBOT.dh        return legacy DH matrix
0026 %    ROBOT.dyn        return legacy DYN matrix
0027 
0028 % Copyright (C) 1999-2008, by Peter I. Corke
0029 %
0030 % This file is part of The Robotics Toolbox for Matlab (RTB).
0031 %
0032 % RTB is free software: you can redistribute it and/or modify
0033 % it under the terms of the GNU Lesser General Public License as published by
0034 % the Free Software Foundation, either version 3 of the License, or
0035 % (at your option) any later version.
0036 %
0037 % RTB is distributed in the hope that it will be useful,
0038 % but WITHOUT ANY WARRANTY; without even the implied warranty of
0039 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0040 % GNU Lesser General Public License for more details.
0041 %
0042 % You should have received a copy of the GNU Leser General Public License
0043 % along with RTB.  If not, see <http://www.gnu.org/licenses/>.
0044 
0045 function v = subsref(r, s)
0046 
0047     if s(1).type  ~= '.'
0048         %error('only .field supported')
0049     end
0050 
0051     % NOTE WELL:  the following code can't use getfield() since
0052     % getfield()  uses this, and Matlab will crash!!
0053 
0054     el = char(s(1).subs);
0055     switch el,
0056     %%%%%%%%% retrieve robot parameters
0057     case 'n',
0058         v = r.n;
0059     case 'gravity'
0060         v = r.gravity;
0061     case 'tool'
0062         v = r.tool;
0063     case 'base'
0064         v = r.base;
0065     case 'mdh',
0066         v = r.mdh;
0067 
0068     case {'link', 'links'},
0069         if length(s) == 1,
0070             v = r.link;
0071         elseif s(2).type == '{}'
0072             j = s(2).subs;
0073             j = j{1};
0074             if (j < 1) | (j > r.n)
0075                 error('link index out of bounds')
0076             end
0077             v = r.link{j};
0078         end
0079     case 'offset',
0080         L = r.link;
0081         v = [];
0082         for i=1:r.n,
0083             v = [v; L{i}.offset];
0084         end
0085     case 'qlim',
0086         L = r.link;
0087         v = [];
0088         for i=1:r.n,
0089             v = [v; L{i}.qlim];
0090         end
0091 
0092     %%%%%%%%% descriptive strings
0093     case 'name',
0094         v = r.name;
0095     case 'manuf',
0096         v = r.manuf;
0097     case 'comment',
0098         v = r.comment;
0099     case 'config',
0100         L = r.link;
0101         v = '';
0102         for i=1:r.n,
0103             v(i) = L{i}.RP;
0104         end
0105 
0106     %%%%%%%%% joint limit test
0107     case 'islimit',
0108         L = r.link;
0109         if s(2).type  ~= '()'
0110             error('expecting argument for islimit method');
0111         end
0112         q = s(2).subs{1};
0113         if length(q) ~= r.n,
0114             error('argument for islimit method is wrong length');
0115         end
0116         v = [];
0117         for i=1:r.n,
0118             v = [v; L{i}.islimit(q(i))];
0119         end
0120     %%%%%%%%% legacy DH/DYN support
0121     case 'dh',
0122         v = [];
0123         L = r.link;
0124         for i=1:r.n,
0125             v = [v; L{i}.dh];
0126         end
0127     case 'dyn'
0128         v = [];
0129         L = r.link;
0130         for i=1:r.n,
0131             v = [v; L{i}.dyn];
0132         end
0133 
0134     %%%%%%%%% graphics support
0135     case 'q',
0136         v = r.q;
0137     case 'plotopt',
0138         v = r.plotopt;
0139     case 'lineopt'
0140         v = r.lineopt;
0141     case 'shadowopt'
0142         v = r.shadowopt;
0143     case {'show', 'handle'}
0144         v = r.handle';
0145     otherwise, error('Unknown method')
0146     end

Generated on Sun 15-Feb-2009 18:09:29 by m2html © 2003