www.gusucode.com > ros 工具箱 matlab源码程序 > ros/+robotics/+ros/+msggen/+pr2_controllers_msgs/PointHeadGoal.m
classdef PointHeadGoal < robotics.ros.Message %PointHeadGoal MATLAB implementation of pr2_controllers_msgs/PointHeadGoal % This class was automatically generated by % robotics.ros.msg.internal.gen.MessageClassGenerator. % Copyright 2014-2016 The MathWorks, Inc. %#ok<*INUSD> properties (Constant) MessageType = 'pr2_controllers_msgs/PointHeadGoal' % The ROS message type end properties (Constant, Hidden) MD5Checksum = '8b92b1cd5e06c8a94c917dc3209a4c1d' % The MD5 Checksum of the message definition end properties (Access = protected) JavaMessage % The Java message object end properties (Constant, Access = protected) DurationClass = robotics.ros.msg.internal.MessageFactory.getClassForType('duration') % Dispatch to MATLAB class for message type duration GeometryMsgsPointStampedClass = robotics.ros.msg.internal.MessageFactory.getClassForType('geometry_msgs/PointStamped') % Dispatch to MATLAB class for message type geometry_msgs/PointStamped GeometryMsgsVector3Class = robotics.ros.msg.internal.MessageFactory.getClassForType('geometry_msgs/Vector3') % Dispatch to MATLAB class for message type geometry_msgs/Vector3 end properties (Dependent) Target PointingAxis PointingFrame MinDuration MaxVelocity end properties (Access = protected) Cache = struct('Target', [], 'PointingAxis', [], 'MinDuration', []) % The cache for fast data access end properties (Constant, Hidden) PropertyList = {'MaxVelocity', 'MinDuration', 'PointingAxis', 'PointingFrame', 'Target'} % List of non-constant message properties ROSPropertyList = {'max_velocity', 'min_duration', 'pointing_axis', 'pointing_frame', 'target'} % List of non-constant ROS message properties end methods function obj = PointHeadGoal(msg) %PointHeadGoal Construct the message object PointHeadGoal 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 target = get.Target(obj) %get.Target Get the value for property Target if isempty(obj.Cache.Target) obj.Cache.Target = feval(obj.GeometryMsgsPointStampedClass, obj.JavaMessage.getTarget); end target = obj.Cache.Target; end function set.Target(obj, target) %set.Target Set the value for property Target validateattributes(target, {obj.GeometryMsgsPointStampedClass}, {'nonempty', 'scalar'}, 'PointHeadGoal', 'Target'); obj.JavaMessage.setTarget(target.getJavaObject); % Update cache if necessary if ~isempty(obj.Cache.Target) obj.Cache.Target.setJavaObject(target.getJavaObject); end end function pointingaxis = get.PointingAxis(obj) %get.PointingAxis Get the value for property PointingAxis if isempty(obj.Cache.PointingAxis) obj.Cache.PointingAxis = feval(obj.GeometryMsgsVector3Class, obj.JavaMessage.getPointingAxis); end pointingaxis = obj.Cache.PointingAxis; end function set.PointingAxis(obj, pointingaxis) %set.PointingAxis Set the value for property PointingAxis validateattributes(pointingaxis, {obj.GeometryMsgsVector3Class}, {'nonempty', 'scalar'}, 'PointHeadGoal', 'PointingAxis'); obj.JavaMessage.setPointingAxis(pointingaxis.getJavaObject); % Update cache if necessary if ~isempty(obj.Cache.PointingAxis) obj.Cache.PointingAxis.setJavaObject(pointingaxis.getJavaObject); end end function pointingframe = get.PointingFrame(obj) %get.PointingFrame Get the value for property PointingFrame pointingframe = char(obj.JavaMessage.getPointingFrame); end function set.PointingFrame(obj, pointingframe) %set.PointingFrame Set the value for property PointingFrame validateattributes(pointingframe, {'char'}, {}, 'PointHeadGoal', 'PointingFrame'); obj.JavaMessage.setPointingFrame(pointingframe); end function minduration = get.MinDuration(obj) %get.MinDuration Get the value for property MinDuration if isempty(obj.Cache.MinDuration) obj.Cache.MinDuration = feval(obj.DurationClass, obj.JavaMessage.getMinDuration); end minduration = obj.Cache.MinDuration; end function set.MinDuration(obj, minduration) %set.MinDuration Set the value for property MinDuration validateattributes(minduration, {obj.DurationClass}, {'nonempty', 'scalar'}, 'PointHeadGoal', 'MinDuration'); obj.JavaMessage.setMinDuration(minduration.getJavaObject); % Update cache if necessary if ~isempty(obj.Cache.MinDuration) obj.Cache.MinDuration.setJavaObject(minduration.getJavaObject); end end function maxvelocity = get.MaxVelocity(obj) %get.MaxVelocity Get the value for property MaxVelocity maxvelocity = double(obj.JavaMessage.getMaxVelocity); end function set.MaxVelocity(obj, maxvelocity) %set.MaxVelocity Set the value for property MaxVelocity validateattributes(maxvelocity, {'numeric'}, {'nonempty', 'scalar'}, 'PointHeadGoal', 'MaxVelocity'); obj.JavaMessage.setMaxVelocity(maxvelocity); end end methods (Access = protected) function resetCache(obj) %resetCache Resets any cached properties obj.Cache.Target = []; obj.Cache.PointingAxis = []; obj.Cache.MinDuration = []; 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.PointingFrame = obj.PointingFrame; cpObj.MaxVelocity = obj.MaxVelocity; % Recursively copy compound properties cpObj.Target = copy(obj.Target); cpObj.PointingAxis = copy(obj.PointingAxis); cpObj.MinDuration = copy(obj.MinDuration); end function reload(obj, strObj) %reload Called by loadobj to assign properties obj.PointingFrame = strObj.PointingFrame; obj.MaxVelocity = strObj.MaxVelocity; obj.Target = feval([obj.GeometryMsgsPointStampedClass '.loadobj'], strObj.Target); obj.PointingAxis = feval([obj.GeometryMsgsVector3Class '.loadobj'], strObj.PointingAxis); obj.MinDuration = feval([obj.DurationClass '.loadobj'], strObj.MinDuration); 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.PointingFrame = obj.PointingFrame; strObj.MaxVelocity = obj.MaxVelocity; strObj.Target = saveobj(obj.Target); strObj.PointingAxis = saveobj(obj.PointingAxis); strObj.MinDuration = saveobj(obj.MinDuration); 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.pr2_controllers_msgs.PointHeadGoal.empty(0,1); return end % Create an empty message object obj = robotics.ros.msggen.pr2_controllers_msgs.PointHeadGoal; obj.reload(strObj); end end end