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

    classdef CameraInfo < robotics.ros.Message
    %CameraInfo MATLAB implementation of sensor_msgs/CameraInfo
    %   This class was automatically generated by
    %   robotics.ros.msg.internal.gen.MessageClassGenerator.
    
    %   Copyright 2014-2016 The MathWorks, Inc.
    
    %#ok<*INUSD>
    
    properties (Constant)
        MessageType = 'sensor_msgs/CameraInfo' % The ROS message type
    end
    
    properties (Constant, Hidden)
        MD5Checksum = 'c9a58c1b0b154e0e6da7578cb991d214' % The MD5 Checksum of the message definition
    end
    
    properties (Access = protected)
        JavaMessage % The Java message object
    end
    
    properties (Constant, Access = protected)
        SensorMsgsRegionOfInterestClass = robotics.ros.msg.internal.MessageFactory.getClassForType('sensor_msgs/RegionOfInterest') % Dispatch to MATLAB class for message type sensor_msgs/RegionOfInterest
        StdMsgsHeaderClass = robotics.ros.msg.internal.MessageFactory.getClassForType('std_msgs/Header') % Dispatch to MATLAB class for message type std_msgs/Header
    end
    
    properties (Dependent)
        Header
        Height
        Width
        DistortionModel
        BinningX
        BinningY
        Roi
        D
        K
        R
        P
    end
    
    properties (Access = protected)
        Cache = struct('Header', [], 'Roi', []) % The cache for fast data access
    end
    
    properties (Constant, Hidden)
        PropertyList = {'BinningX', 'BinningY', 'D', 'DistortionModel', 'Header', 'Height', 'K', 'P', 'R', 'Roi', 'Width'} % List of non-constant message properties
        ROSPropertyList = {'binning_x', 'binning_y', 'D', 'distortion_model', 'header', 'height', 'K', 'P', 'R', 'roi', 'width'} % List of non-constant ROS message properties
    end
    
    methods
        function obj = CameraInfo(msg)
            %CameraInfo Construct the message object CameraInfo
            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 header = get.Header(obj)
            %get.Header Get the value for property Header
            if isempty(obj.Cache.Header)
                obj.Cache.Header = feval(obj.StdMsgsHeaderClass, obj.JavaMessage.getHeader);
            end
            header = obj.Cache.Header;
        end
        
        function set.Header(obj, header)
            %set.Header Set the value for property Header
            validateattributes(header, {obj.StdMsgsHeaderClass}, {'nonempty', 'scalar'}, 'CameraInfo', 'Header');
            
            obj.JavaMessage.setHeader(header.getJavaObject);
            
            % Update cache if necessary
            if ~isempty(obj.Cache.Header)
                obj.Cache.Header.setJavaObject(header.getJavaObject);
            end
        end
        
        function height = get.Height(obj)
            %get.Height Get the value for property Height
            height = typecast(int32(obj.JavaMessage.getHeight), 'uint32');
        end
        
        function set.Height(obj, height)
            %set.Height Set the value for property Height
            validateattributes(height, {'numeric'}, {'nonempty', 'scalar'}, 'CameraInfo', 'Height');
            
            obj.JavaMessage.setHeight(height);
        end
        
        function width = get.Width(obj)
            %get.Width Get the value for property Width
            width = typecast(int32(obj.JavaMessage.getWidth), 'uint32');
        end
        
        function set.Width(obj, width)
            %set.Width Set the value for property Width
            validateattributes(width, {'numeric'}, {'nonempty', 'scalar'}, 'CameraInfo', 'Width');
            
            obj.JavaMessage.setWidth(width);
        end
        
        function distortionmodel = get.DistortionModel(obj)
            %get.DistortionModel Get the value for property DistortionModel
            distortionmodel = char(obj.JavaMessage.getDistortionModel);
        end
        
        function set.DistortionModel(obj, distortionmodel)
            %set.DistortionModel Set the value for property DistortionModel
            validateattributes(distortionmodel, {'char'}, {}, 'CameraInfo', 'DistortionModel');
            
            obj.JavaMessage.setDistortionModel(distortionmodel);
        end
        
        function binningx = get.BinningX(obj)
            %get.BinningX Get the value for property BinningX
            binningx = typecast(int32(obj.JavaMessage.getBinningX), 'uint32');
        end
        
        function set.BinningX(obj, binningx)
            %set.BinningX Set the value for property BinningX
            validateattributes(binningx, {'numeric'}, {'nonempty', 'scalar'}, 'CameraInfo', 'BinningX');
            
            obj.JavaMessage.setBinningX(binningx);
        end
        
        function binningy = get.BinningY(obj)
            %get.BinningY Get the value for property BinningY
            binningy = typecast(int32(obj.JavaMessage.getBinningY), 'uint32');
        end
        
        function set.BinningY(obj, binningy)
            %set.BinningY Set the value for property BinningY
            validateattributes(binningy, {'numeric'}, {'nonempty', 'scalar'}, 'CameraInfo', 'BinningY');
            
            obj.JavaMessage.setBinningY(binningy);
        end
        
        function roi = get.Roi(obj)
            %get.Roi Get the value for property Roi
            if isempty(obj.Cache.Roi)
                obj.Cache.Roi = feval(obj.SensorMsgsRegionOfInterestClass, obj.JavaMessage.getRoi);
            end
            roi = obj.Cache.Roi;
        end
        
        function set.Roi(obj, roi)
            %set.Roi Set the value for property Roi
            validateattributes(roi, {obj.SensorMsgsRegionOfInterestClass}, {'nonempty', 'scalar'}, 'CameraInfo', 'Roi');
            
            obj.JavaMessage.setRoi(roi.getJavaObject);
            
            % Update cache if necessary
            if ~isempty(obj.Cache.Roi)
                obj.Cache.Roi.setJavaObject(roi.getJavaObject);
            end
        end
        
        function d = get.D(obj)
            %get.D Get the value for property D
            javaArray = obj.JavaMessage.getD;
            array = obj.readJavaArray(javaArray, 'double');
            d = double(array);
        end
        
        function set.D(obj, d)
            %set.D Set the value for property D
            if ~isvector(d) && isempty(d)
                % Allow empty [] input
                d = double.empty(0,1);
            end
            
            validateattributes(d, {'numeric'}, {'vector'}, 'CameraInfo', 'D');
            
            javaArray = obj.JavaMessage.getD;
            array = obj.writeJavaArray(d, javaArray, 'double');
            obj.JavaMessage.setD(array);
        end
        
        function k = get.K(obj)
            %get.K Get the value for property K
            javaArray = obj.JavaMessage.getK;
            array = obj.readJavaArray(javaArray, 'double');
            k = double(array);
        end
        
        function set.K(obj, k)
            %set.K Set the value for property K
            validateattributes(k, {'numeric'}, {'vector', 'numel', 9}, 'CameraInfo', 'K');
            
            javaArray = obj.JavaMessage.getK;
            array = obj.writeJavaArray(k, javaArray, 'double');
            obj.JavaMessage.setK(array);
        end
        
        function r = get.R(obj)
            %get.R Get the value for property R
            javaArray = obj.JavaMessage.getR;
            array = obj.readJavaArray(javaArray, 'double');
            r = double(array);
        end
        
        function set.R(obj, r)
            %set.R Set the value for property R
            validateattributes(r, {'numeric'}, {'vector', 'numel', 9}, 'CameraInfo', 'R');
            
            javaArray = obj.JavaMessage.getR;
            array = obj.writeJavaArray(r, javaArray, 'double');
            obj.JavaMessage.setR(array);
        end
        
        function p = get.P(obj)
            %get.P Get the value for property P
            javaArray = obj.JavaMessage.getP;
            array = obj.readJavaArray(javaArray, 'double');
            p = double(array);
        end
        
        function set.P(obj, p)
            %set.P Set the value for property P
            validateattributes(p, {'numeric'}, {'vector', 'numel', 12}, 'CameraInfo', 'P');
            
            javaArray = obj.JavaMessage.getP;
            array = obj.writeJavaArray(p, javaArray, 'double');
            obj.JavaMessage.setP(array);
        end
    end
    
    methods (Access = protected)
        function resetCache(obj)
            %resetCache Resets any cached properties
            obj.Cache.Header = [];
            obj.Cache.Roi = [];
        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.Height = obj.Height;
            cpObj.Width = obj.Width;
            cpObj.DistortionModel = obj.DistortionModel;
            cpObj.BinningX = obj.BinningX;
            cpObj.BinningY = obj.BinningY;
            cpObj.D = obj.D;
            cpObj.K = obj.K;
            cpObj.R = obj.R;
            cpObj.P = obj.P;
            
            % Recursively copy compound properties
            cpObj.Header = copy(obj.Header);
            cpObj.Roi = copy(obj.Roi);
        end
        
        function reload(obj, strObj)
            %reload Called by loadobj to assign properties
            obj.Height = strObj.Height;
            obj.Width = strObj.Width;
            obj.DistortionModel = strObj.DistortionModel;
            obj.BinningX = strObj.BinningX;
            obj.BinningY = strObj.BinningY;
            obj.D = strObj.D;
            obj.K = strObj.K;
            obj.R = strObj.R;
            obj.P = strObj.P;
            obj.Header = feval([obj.StdMsgsHeaderClass '.loadobj'], strObj.Header);
            obj.Roi = feval([obj.SensorMsgsRegionOfInterestClass '.loadobj'], strObj.Roi);
        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.Height = obj.Height;
            strObj.Width = obj.Width;
            strObj.DistortionModel = obj.DistortionModel;
            strObj.BinningX = obj.BinningX;
            strObj.BinningY = obj.BinningY;
            strObj.D = obj.D;
            strObj.K = obj.K;
            strObj.R = obj.R;
            strObj.P = obj.P;
            strObj.Header = saveobj(obj.Header);
            strObj.Roi = saveobj(obj.Roi);
        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.sensor_msgs.CameraInfo.empty(0,1);
                return
            end
            
            % Create an empty message object
            obj = robotics.ros.msggen.sensor_msgs.CameraInfo;
            obj.reload(strObj);
        end
    end
end