www.gusucode.com > ros 工具箱 matlab源码程序 > ros/+robotics/+ros/+msggen/+cob_pick_place_action/CobPickGoal.m

    classdef CobPickGoal < robotics.ros.Message
    %CobPickGoal MATLAB implementation of cob_pick_place_action/CobPickGoal
    %   This class was automatically generated by
    %   robotics.ros.msg.internal.gen.MessageClassGenerator.
    
    %   Copyright 2014-2016 The MathWorks, Inc.
    
    %#ok<*INUSD>
    
    properties (Constant)
        MessageType = 'cob_pick_place_action/CobPickGoal' % The ROS message type
    end
    
    properties (Constant, Hidden)
        MD5Checksum = '98c44a3be849194f7362e5ea42420c0e' % The MD5 Checksum of the message definition
    end
    
    properties (Access = protected)
        JavaMessage % The Java message object
    end
    
    properties (Constant, Access = protected)
        GeometryMsgsPoseStampedClass = robotics.ros.msg.internal.MessageFactory.getClassForType('geometry_msgs/PoseStamped') % Dispatch to MATLAB class for message type geometry_msgs/PoseStamped
    end
    
    properties (Dependent)
        ObjectClass
        ObjectName
        ObjectPose
        GraspDatabase
        GraspId
        SupportSurface
    end
    
    properties (Access = protected)
        Cache = struct('ObjectPose', []) % The cache for fast data access
    end
    
    properties (Constant, Hidden)
        PropertyList = {'GraspDatabase', 'GraspId', 'ObjectClass', 'ObjectName', 'ObjectPose', 'SupportSurface'} % List of non-constant message properties
        ROSPropertyList = {'grasp_database', 'grasp_id', 'object_class', 'object_name', 'object_pose', 'support_surface'} % List of non-constant ROS message properties
    end
    
    methods
        function obj = CobPickGoal(msg)
            %CobPickGoal Construct the message object CobPickGoal
            import com.mathworks.toolbox.robotics.ros.message.MessageInfo;
            
            % Support default constructor
            if nargin == 0
                obj.JavaMessage = obj.createNewJavaMessage;
                return;
            end
            
            % Construct appropriate empty array
            if isempty(msg)
                obj = obj.empty(0,1);
                return;
            end
            
            % Make scalar construction fast
            if isscalar(msg)
                % Check for correct input class
                if ~MessageInfo.compareTypes(msg(1), obj.MessageType)
                    error(message('robotics:ros:message:NoTypeMatch', obj.MessageType, ...
                        char(MessageInfo.getType(msg(1))) ));
                end
                obj.JavaMessage = msg(1);
                return;
            end
            
            % Check that this is a vector of scalar messages. Since this
            % is an object array, use arrayfun to verify.
            if ~all(arrayfun(@isscalar, msg))
                error(message('robotics:ros:message:MessageArraySizeError'));
            end
            
            % Check that all messages in the array have the correct type
            if ~all(arrayfun(@(x) MessageInfo.compareTypes(x, obj.MessageType), msg))
                error(message('robotics:ros:message:NoTypeMatchArray', obj.MessageType));
            end
            
            % Construct array of objects if necessary
            objType = class(obj);
            for i = 1:length(msg)
                obj(i,1) = feval(objType, msg(i)); %#ok<AGROW>
            end
        end
        
        function objectclass = get.ObjectClass(obj)
            %get.ObjectClass Get the value for property ObjectClass
            objectclass = typecast(int32(obj.JavaMessage.getObjectClass), 'uint32');
        end
        
        function set.ObjectClass(obj, objectclass)
            %set.ObjectClass Set the value for property ObjectClass
            validateattributes(objectclass, {'numeric'}, {'nonempty', 'scalar'}, 'CobPickGoal', 'ObjectClass');
            
            obj.JavaMessage.setObjectClass(objectclass);
        end
        
        function objectname = get.ObjectName(obj)
            %get.ObjectName Get the value for property ObjectName
            objectname = char(obj.JavaMessage.getObjectName);
        end
        
        function set.ObjectName(obj, objectname)
            %set.ObjectName Set the value for property ObjectName
            validateattributes(objectname, {'char'}, {}, 'CobPickGoal', 'ObjectName');
            
            obj.JavaMessage.setObjectName(objectname);
        end
        
        function objectpose = get.ObjectPose(obj)
            %get.ObjectPose Get the value for property ObjectPose
            if isempty(obj.Cache.ObjectPose)
                obj.Cache.ObjectPose = feval(obj.GeometryMsgsPoseStampedClass, obj.JavaMessage.getObjectPose);
            end
            objectpose = obj.Cache.ObjectPose;
        end
        
        function set.ObjectPose(obj, objectpose)
            %set.ObjectPose Set the value for property ObjectPose
            validateattributes(objectpose, {obj.GeometryMsgsPoseStampedClass}, {'nonempty', 'scalar'}, 'CobPickGoal', 'ObjectPose');
            
            obj.JavaMessage.setObjectPose(objectpose.getJavaObject);
            
            % Update cache if necessary
            if ~isempty(obj.Cache.ObjectPose)
                obj.Cache.ObjectPose.setJavaObject(objectpose.getJavaObject);
            end
        end
        
        function graspdatabase = get.GraspDatabase(obj)
            %get.GraspDatabase Get the value for property GraspDatabase
            graspdatabase = char(obj.JavaMessage.getGraspDatabase);
        end
        
        function set.GraspDatabase(obj, graspdatabase)
            %set.GraspDatabase Set the value for property GraspDatabase
            validateattributes(graspdatabase, {'char'}, {}, 'CobPickGoal', 'GraspDatabase');
            
            obj.JavaMessage.setGraspDatabase(graspdatabase);
        end
        
        function graspid = get.GraspId(obj)
            %get.GraspId Get the value for property GraspId
            graspid = typecast(int32(obj.JavaMessage.getGraspId), 'uint32');
        end
        
        function set.GraspId(obj, graspid)
            %set.GraspId Set the value for property GraspId
            validateattributes(graspid, {'numeric'}, {'nonempty', 'scalar'}, 'CobPickGoal', 'GraspId');
            
            obj.JavaMessage.setGraspId(graspid);
        end
        
        function supportsurface = get.SupportSurface(obj)
            %get.SupportSurface Get the value for property SupportSurface
            supportsurface = char(obj.JavaMessage.getSupportSurface);
        end
        
        function set.SupportSurface(obj, supportsurface)
            %set.SupportSurface Set the value for property SupportSurface
            validateattributes(supportsurface, {'char'}, {}, 'CobPickGoal', 'SupportSurface');
            
            obj.JavaMessage.setSupportSurface(supportsurface);
        end
    end
    
    methods (Access = protected)
        function resetCache(obj)
            %resetCache Resets any cached properties
            obj.Cache.ObjectPose = [];
        end
        
        function cpObj = copyElement(obj)
            %copyElement Implements deep copy behavior for message
            
            % Call default copy method for shallow copy
            cpObj = copyElement@robotics.ros.Message(obj);
            
            % Clear any existing cached properties
            cpObj.resetCache;
            
            % Create a new Java message object
            cpObj.JavaMessage = obj.createNewJavaMessage;
            
            % Iterate over all primitive properties
            cpObj.ObjectClass = obj.ObjectClass;
            cpObj.ObjectName = obj.ObjectName;
            cpObj.GraspDatabase = obj.GraspDatabase;
            cpObj.GraspId = obj.GraspId;
            cpObj.SupportSurface = obj.SupportSurface;
            
            % Recursively copy compound properties
            cpObj.ObjectPose = copy(obj.ObjectPose);
        end
        
        function reload(obj, strObj)
            %reload Called by loadobj to assign properties
            obj.ObjectClass = strObj.ObjectClass;
            obj.ObjectName = strObj.ObjectName;
            obj.GraspDatabase = strObj.GraspDatabase;
            obj.GraspId = strObj.GraspId;
            obj.SupportSurface = strObj.SupportSurface;
            obj.ObjectPose = feval([obj.GeometryMsgsPoseStampedClass '.loadobj'], strObj.ObjectPose);
        end
    end
    
    methods (Access = ?robotics.ros.Message)
        function strObj = saveobj(obj)
            %saveobj Implements saving of message to MAT file
            
            % Return an empty element if object array is empty
            if isempty(obj)
                strObj = struct.empty;
                return
            end
            
            strObj.ObjectClass = obj.ObjectClass;
            strObj.ObjectName = obj.ObjectName;
            strObj.GraspDatabase = obj.GraspDatabase;
            strObj.GraspId = obj.GraspId;
            strObj.SupportSurface = obj.SupportSurface;
            strObj.ObjectPose = saveobj(obj.ObjectPose);
        end
    end
    
    methods (Static, Access = {?matlab.unittest.TestCase, ?robotics.ros.Message})
        function obj = loadobj(strObj)
            %loadobj Implements loading of message from MAT file
            
            % Return an empty object array if the structure element is not defined
            if isempty(strObj)
                obj = robotics.ros.msggen.cob_pick_place_action.CobPickGoal.empty(0,1);
                return
            end
            
            % Create an empty message object
            obj = robotics.ros.msggen.cob_pick_place_action.CobPickGoal;
            obj.reload(strObj);
        end
    end
end