www.gusucode.com > ros 工具箱 matlab源码程序 > ros/+robotics/+ros/+msggen/+calibration_msgs/RobotMeasurement.m
classdef RobotMeasurement < robotics.ros.Message %RobotMeasurement MATLAB implementation of calibration_msgs/RobotMeasurement % This class was automatically generated by % robotics.ros.msg.internal.gen.MessageClassGenerator. % Copyright 2014-2016 The MathWorks, Inc. %#ok<*INUSD> properties (Constant) MessageType = 'calibration_msgs/RobotMeasurement' % The ROS message type end properties (Constant, Hidden) MD5Checksum = 'fe22486c078efbf7892430dd0b99305c' % The MD5 Checksum of the message definition end properties (Access = protected) JavaMessage % The Java message object end properties (Constant, Access = protected) CalibrationMsgsCameraMeasurementClass = robotics.ros.msg.internal.MessageFactory.getClassForType('calibration_msgs/CameraMeasurement') % Dispatch to MATLAB class for message type calibration_msgs/CameraMeasurement CalibrationMsgsChainMeasurementClass = robotics.ros.msg.internal.MessageFactory.getClassForType('calibration_msgs/ChainMeasurement') % Dispatch to MATLAB class for message type calibration_msgs/ChainMeasurement CalibrationMsgsLaserMeasurementClass = robotics.ros.msg.internal.MessageFactory.getClassForType('calibration_msgs/LaserMeasurement') % Dispatch to MATLAB class for message type calibration_msgs/LaserMeasurement end properties (Dependent) SampleId TargetId ChainId MCam MLaser MChain end properties (Access = protected) Cache = struct('MCam', [], 'MLaser', [], 'MChain', []) % The cache for fast data access end properties (Constant, Hidden) PropertyList = {'ChainId', 'MCam', 'MChain', 'MLaser', 'SampleId', 'TargetId'} % List of non-constant message properties ROSPropertyList = {'chain_id', 'M_cam', 'M_chain', 'M_laser', 'sample_id', 'target_id'} % List of non-constant ROS message properties end methods function obj = RobotMeasurement(msg) %RobotMeasurement Construct the message object RobotMeasurement 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 sampleid = get.SampleId(obj) %get.SampleId Get the value for property SampleId sampleid = char(obj.JavaMessage.getSampleId); end function set.SampleId(obj, sampleid) %set.SampleId Set the value for property SampleId validateattributes(sampleid, {'char'}, {}, 'RobotMeasurement', 'SampleId'); obj.JavaMessage.setSampleId(sampleid); end function targetid = get.TargetId(obj) %get.TargetId Get the value for property TargetId targetid = char(obj.JavaMessage.getTargetId); end function set.TargetId(obj, targetid) %set.TargetId Set the value for property TargetId validateattributes(targetid, {'char'}, {}, 'RobotMeasurement', 'TargetId'); obj.JavaMessage.setTargetId(targetid); end function chainid = get.ChainId(obj) %get.ChainId Get the value for property ChainId chainid = char(obj.JavaMessage.getChainId); end function set.ChainId(obj, chainid) %set.ChainId Set the value for property ChainId validateattributes(chainid, {'char'}, {}, 'RobotMeasurement', 'ChainId'); obj.JavaMessage.setChainId(chainid); end function mcam = get.MCam(obj) %get.MCam Get the value for property MCam if isempty(obj.Cache.MCam) javaArray = obj.JavaMessage.getMCam; array = obj.readJavaArray(javaArray, obj.CalibrationMsgsCameraMeasurementClass); obj.Cache.MCam = feval(obj.CalibrationMsgsCameraMeasurementClass, array); end mcam = obj.Cache.MCam; end function set.MCam(obj, mcam) %set.MCam Set the value for property MCam if ~isvector(mcam) && isempty(mcam) % Allow empty [] input mcam = feval([obj.CalibrationMsgsCameraMeasurementClass '.empty'], 0, 1); end validateattributes(mcam, {obj.CalibrationMsgsCameraMeasurementClass}, {'vector'}, 'RobotMeasurement', 'MCam'); javaArray = obj.JavaMessage.getMCam; array = obj.writeJavaArray(mcam, javaArray, obj.CalibrationMsgsCameraMeasurementClass); obj.JavaMessage.setMCam(array); % Update cache if necessary if ~isempty(obj.Cache.MCam) obj.Cache.MCam = []; obj.Cache.MCam = obj.MCam; end end function mlaser = get.MLaser(obj) %get.MLaser Get the value for property MLaser if isempty(obj.Cache.MLaser) javaArray = obj.JavaMessage.getMLaser; array = obj.readJavaArray(javaArray, obj.CalibrationMsgsLaserMeasurementClass); obj.Cache.MLaser = feval(obj.CalibrationMsgsLaserMeasurementClass, array); end mlaser = obj.Cache.MLaser; end function set.MLaser(obj, mlaser) %set.MLaser Set the value for property MLaser if ~isvector(mlaser) && isempty(mlaser) % Allow empty [] input mlaser = feval([obj.CalibrationMsgsLaserMeasurementClass '.empty'], 0, 1); end validateattributes(mlaser, {obj.CalibrationMsgsLaserMeasurementClass}, {'vector'}, 'RobotMeasurement', 'MLaser'); javaArray = obj.JavaMessage.getMLaser; array = obj.writeJavaArray(mlaser, javaArray, obj.CalibrationMsgsLaserMeasurementClass); obj.JavaMessage.setMLaser(array); % Update cache if necessary if ~isempty(obj.Cache.MLaser) obj.Cache.MLaser = []; obj.Cache.MLaser = obj.MLaser; end end function mchain = get.MChain(obj) %get.MChain Get the value for property MChain if isempty(obj.Cache.MChain) javaArray = obj.JavaMessage.getMChain; array = obj.readJavaArray(javaArray, obj.CalibrationMsgsChainMeasurementClass); obj.Cache.MChain = feval(obj.CalibrationMsgsChainMeasurementClass, array); end mchain = obj.Cache.MChain; end function set.MChain(obj, mchain) %set.MChain Set the value for property MChain if ~isvector(mchain) && isempty(mchain) % Allow empty [] input mchain = feval([obj.CalibrationMsgsChainMeasurementClass '.empty'], 0, 1); end validateattributes(mchain, {obj.CalibrationMsgsChainMeasurementClass}, {'vector'}, 'RobotMeasurement', 'MChain'); javaArray = obj.JavaMessage.getMChain; array = obj.writeJavaArray(mchain, javaArray, obj.CalibrationMsgsChainMeasurementClass); obj.JavaMessage.setMChain(array); % Update cache if necessary if ~isempty(obj.Cache.MChain) obj.Cache.MChain = []; obj.Cache.MChain = obj.MChain; end end end methods (Access = protected) function resetCache(obj) %resetCache Resets any cached properties obj.Cache.MCam = []; obj.Cache.MLaser = []; obj.Cache.MChain = []; 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.SampleId = obj.SampleId; cpObj.TargetId = obj.TargetId; cpObj.ChainId = obj.ChainId; % Recursively copy compound properties cpObj.MCam = copy(obj.MCam); cpObj.MLaser = copy(obj.MLaser); cpObj.MChain = copy(obj.MChain); end function reload(obj, strObj) %reload Called by loadobj to assign properties obj.SampleId = strObj.SampleId; obj.TargetId = strObj.TargetId; obj.ChainId = strObj.ChainId; MCamCell = arrayfun(@(x) feval([obj.CalibrationMsgsCameraMeasurementClass '.loadobj'], x), strObj.MCam, 'UniformOutput', false); obj.MCam = vertcat(MCamCell{:}); MLaserCell = arrayfun(@(x) feval([obj.CalibrationMsgsLaserMeasurementClass '.loadobj'], x), strObj.MLaser, 'UniformOutput', false); obj.MLaser = vertcat(MLaserCell{:}); MChainCell = arrayfun(@(x) feval([obj.CalibrationMsgsChainMeasurementClass '.loadobj'], x), strObj.MChain, 'UniformOutput', false); obj.MChain = vertcat(MChainCell{:}); 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.SampleId = obj.SampleId; strObj.TargetId = obj.TargetId; strObj.ChainId = obj.ChainId; strObj.MCam = arrayfun(@(x) saveobj(x), obj.MCam); strObj.MLaser = arrayfun(@(x) saveobj(x), obj.MLaser); strObj.MChain = arrayfun(@(x) saveobj(x), obj.MChain); 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.calibration_msgs.RobotMeasurement.empty(0,1); return end % Create an empty message object obj = robotics.ros.msggen.calibration_msgs.RobotMeasurement; obj.reload(strObj); end end end