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

    classdef SceneRegion < robotics.ros.Message
    %SceneRegion MATLAB implementation of manipulation_msgs/SceneRegion
    %   This class was automatically generated by
    %   robotics.ros.msg.internal.gen.MessageClassGenerator.
    
    %   Copyright 2014-2016 The MathWorks, Inc.
    
    %#ok<*INUSD>
    
    properties (Constant)
        MessageType = 'manipulation_msgs/SceneRegion' % The ROS message type
    end
    
    properties (Constant, Hidden)
        MD5Checksum = '0a9ab02b19292633619876c9d247690c' % 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
        GeometryMsgsVector3Class = robotics.ros.msg.internal.MessageFactory.getClassForType('geometry_msgs/Vector3') % Dispatch to MATLAB class for message type geometry_msgs/Vector3
        SensorMsgsCameraInfoClass = robotics.ros.msg.internal.MessageFactory.getClassForType('sensor_msgs/CameraInfo') % Dispatch to MATLAB class for message type sensor_msgs/CameraInfo
        SensorMsgsImageClass = robotics.ros.msg.internal.MessageFactory.getClassForType('sensor_msgs/Image') % Dispatch to MATLAB class for message type sensor_msgs/Image
        SensorMsgsPointCloud2Class = robotics.ros.msg.internal.MessageFactory.getClassForType('sensor_msgs/PointCloud2') % Dispatch to MATLAB class for message type sensor_msgs/PointCloud2
    end
    
    properties (Dependent)
        Cloud
        Image
        DisparityImage
        CamInfo
        RoiBoxPose
        RoiBoxDims
        Mask
    end
    
    properties (Access = protected)
        Cache = struct('Cloud', [], 'Image', [], 'DisparityImage', [], 'CamInfo', [], 'RoiBoxPose', [], 'RoiBoxDims', []) % The cache for fast data access
    end
    
    properties (Constant, Hidden)
        PropertyList = {'CamInfo', 'Cloud', 'DisparityImage', 'Image', 'Mask', 'RoiBoxDims', 'RoiBoxPose'} % List of non-constant message properties
        ROSPropertyList = {'cam_info', 'cloud', 'disparity_image', 'image', 'mask', 'roi_box_dims', 'roi_box_pose'} % List of non-constant ROS message properties
    end
    
    methods
        function obj = SceneRegion(msg)
            %SceneRegion Construct the message object SceneRegion
            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 cloud = get.Cloud(obj)
            %get.Cloud Get the value for property Cloud
            if isempty(obj.Cache.Cloud)
                obj.Cache.Cloud = feval(obj.SensorMsgsPointCloud2Class, obj.JavaMessage.getCloud);
            end
            cloud = obj.Cache.Cloud;
        end
        
        function set.Cloud(obj, cloud)
            %set.Cloud Set the value for property Cloud
            validateattributes(cloud, {obj.SensorMsgsPointCloud2Class}, {'nonempty', 'scalar'}, 'SceneRegion', 'Cloud');
            
            obj.JavaMessage.setCloud(cloud.getJavaObject);
            
            % Update cache if necessary
            if ~isempty(obj.Cache.Cloud)
                obj.Cache.Cloud.setJavaObject(cloud.getJavaObject);
            end
        end
        
        function image = get.Image(obj)
            %get.Image Get the value for property Image
            if isempty(obj.Cache.Image)
                obj.Cache.Image = feval(obj.SensorMsgsImageClass, obj.JavaMessage.getImage);
            end
            image = obj.Cache.Image;
        end
        
        function set.Image(obj, image)
            %set.Image Set the value for property Image
            validateattributes(image, {obj.SensorMsgsImageClass}, {'nonempty', 'scalar'}, 'SceneRegion', 'Image');
            
            obj.JavaMessage.setImage(image.getJavaObject);
            
            % Update cache if necessary
            if ~isempty(obj.Cache.Image)
                obj.Cache.Image.setJavaObject(image.getJavaObject);
            end
        end
        
        function disparityimage = get.DisparityImage(obj)
            %get.DisparityImage Get the value for property DisparityImage
            if isempty(obj.Cache.DisparityImage)
                obj.Cache.DisparityImage = feval(obj.SensorMsgsImageClass, obj.JavaMessage.getDisparityImage);
            end
            disparityimage = obj.Cache.DisparityImage;
        end
        
        function set.DisparityImage(obj, disparityimage)
            %set.DisparityImage Set the value for property DisparityImage
            validateattributes(disparityimage, {obj.SensorMsgsImageClass}, {'nonempty', 'scalar'}, 'SceneRegion', 'DisparityImage');
            
            obj.JavaMessage.setDisparityImage(disparityimage.getJavaObject);
            
            % Update cache if necessary
            if ~isempty(obj.Cache.DisparityImage)
                obj.Cache.DisparityImage.setJavaObject(disparityimage.getJavaObject);
            end
        end
        
        function caminfo = get.CamInfo(obj)
            %get.CamInfo Get the value for property CamInfo
            if isempty(obj.Cache.CamInfo)
                obj.Cache.CamInfo = feval(obj.SensorMsgsCameraInfoClass, obj.JavaMessage.getCamInfo);
            end
            caminfo = obj.Cache.CamInfo;
        end
        
        function set.CamInfo(obj, caminfo)
            %set.CamInfo Set the value for property CamInfo
            validateattributes(caminfo, {obj.SensorMsgsCameraInfoClass}, {'nonempty', 'scalar'}, 'SceneRegion', 'CamInfo');
            
            obj.JavaMessage.setCamInfo(caminfo.getJavaObject);
            
            % Update cache if necessary
            if ~isempty(obj.Cache.CamInfo)
                obj.Cache.CamInfo.setJavaObject(caminfo.getJavaObject);
            end
        end
        
        function roiboxpose = get.RoiBoxPose(obj)
            %get.RoiBoxPose Get the value for property RoiBoxPose
            if isempty(obj.Cache.RoiBoxPose)
                obj.Cache.RoiBoxPose = feval(obj.GeometryMsgsPoseStampedClass, obj.JavaMessage.getRoiBoxPose);
            end
            roiboxpose = obj.Cache.RoiBoxPose;
        end
        
        function set.RoiBoxPose(obj, roiboxpose)
            %set.RoiBoxPose Set the value for property RoiBoxPose
            validateattributes(roiboxpose, {obj.GeometryMsgsPoseStampedClass}, {'nonempty', 'scalar'}, 'SceneRegion', 'RoiBoxPose');
            
            obj.JavaMessage.setRoiBoxPose(roiboxpose.getJavaObject);
            
            % Update cache if necessary
            if ~isempty(obj.Cache.RoiBoxPose)
                obj.Cache.RoiBoxPose.setJavaObject(roiboxpose.getJavaObject);
            end
        end
        
        function roiboxdims = get.RoiBoxDims(obj)
            %get.RoiBoxDims Get the value for property RoiBoxDims
            if isempty(obj.Cache.RoiBoxDims)
                obj.Cache.RoiBoxDims = feval(obj.GeometryMsgsVector3Class, obj.JavaMessage.getRoiBoxDims);
            end
            roiboxdims = obj.Cache.RoiBoxDims;
        end
        
        function set.RoiBoxDims(obj, roiboxdims)
            %set.RoiBoxDims Set the value for property RoiBoxDims
            validateattributes(roiboxdims, {obj.GeometryMsgsVector3Class}, {'nonempty', 'scalar'}, 'SceneRegion', 'RoiBoxDims');
            
            obj.JavaMessage.setRoiBoxDims(roiboxdims.getJavaObject);
            
            % Update cache if necessary
            if ~isempty(obj.Cache.RoiBoxDims)
                obj.Cache.RoiBoxDims.setJavaObject(roiboxdims.getJavaObject);
            end
        end
        
        function mask = get.Mask(obj)
            %get.Mask Get the value for property Mask
            javaArray = obj.JavaMessage.getMask;
            array = obj.readJavaArray(javaArray, 'int32');
            mask = int32(array);
        end
        
        function set.Mask(obj, mask)
            %set.Mask Set the value for property Mask
            if ~isvector(mask) && isempty(mask)
                % Allow empty [] input
                mask = int32.empty(0,1);
            end
            
            validateattributes(mask, {'numeric'}, {'vector'}, 'SceneRegion', 'Mask');
            
            javaArray = obj.JavaMessage.getMask;
            array = obj.writeJavaArray(mask, javaArray, 'int32');
            obj.JavaMessage.setMask(array);
        end
    end
    
    methods (Access = protected)
        function resetCache(obj)
            %resetCache Resets any cached properties
            obj.Cache.Cloud = [];
            obj.Cache.Image = [];
            obj.Cache.DisparityImage = [];
            obj.Cache.CamInfo = [];
            obj.Cache.RoiBoxPose = [];
            obj.Cache.RoiBoxDims = [];
        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.Mask = obj.Mask;
            
            % Recursively copy compound properties
            cpObj.Cloud = copy(obj.Cloud);
            cpObj.Image = copy(obj.Image);
            cpObj.DisparityImage = copy(obj.DisparityImage);
            cpObj.CamInfo = copy(obj.CamInfo);
            cpObj.RoiBoxPose = copy(obj.RoiBoxPose);
            cpObj.RoiBoxDims = copy(obj.RoiBoxDims);
        end
        
        function reload(obj, strObj)
            %reload Called by loadobj to assign properties
            obj.Mask = strObj.Mask;
            obj.Cloud = feval([obj.SensorMsgsPointCloud2Class '.loadobj'], strObj.Cloud);
            obj.Image = feval([obj.SensorMsgsImageClass '.loadobj'], strObj.Image);
            obj.DisparityImage = feval([obj.SensorMsgsImageClass '.loadobj'], strObj.DisparityImage);
            obj.CamInfo = feval([obj.SensorMsgsCameraInfoClass '.loadobj'], strObj.CamInfo);
            obj.RoiBoxPose = feval([obj.GeometryMsgsPoseStampedClass '.loadobj'], strObj.RoiBoxPose);
            obj.RoiBoxDims = feval([obj.GeometryMsgsVector3Class '.loadobj'], strObj.RoiBoxDims);
        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.Mask = obj.Mask;
            strObj.Cloud = saveobj(obj.Cloud);
            strObj.Image = saveobj(obj.Image);
            strObj.DisparityImage = saveobj(obj.DisparityImage);
            strObj.CamInfo = saveobj(obj.CamInfo);
            strObj.RoiBoxPose = saveobj(obj.RoiBoxPose);
            strObj.RoiBoxDims = saveobj(obj.RoiBoxDims);
        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.manipulation_msgs.SceneRegion.empty(0,1);
                return
            end
            
            % Create an empty message object
            obj = robotics.ros.msggen.manipulation_msgs.SceneRegion;
            obj.reload(strObj);
        end
    end
end