www.gusucode.com > ros 工具箱 matlab源码程序 > ros/+robotics/+ros/+msggen/+segway_rmp/SegwayStatus.m
classdef SegwayStatus < robotics.ros.Message %SegwayStatus MATLAB implementation of segway_rmp/SegwayStatus % This class was automatically generated by % robotics.ros.msg.internal.gen.MessageClassGenerator. % Copyright 2014-2016 The MathWorks, Inc. %#ok<*INUSD> properties (Constant) MessageType = 'segway_rmp/SegwayStatus' % The ROS message type end properties (Constant, Hidden) MD5Checksum = '658b68a87a84c7483fa3f522de0a2f66' % The MD5 Checksum of the message definition end properties (Access = protected) JavaMessage % The Java message object end properties (Constant) LIGHT = int8(1) TALL = int8(2) HEAVY = int8(3) BALANCE = int8(1) TRACTOR = int8(2) POWERDOWN = int8(3) end properties (Dependent) PitchAngle PitchRate RollAngle RollRate LeftWheelVelocity RightWheelVelocity YawRate ServoFrames LeftWheelDisplacement RightWheelDisplacement ForwardDisplacement YawDisplacement LeftMotorTorque RightMotorTorque OperationMode GainSchedule UiBattery PowerbaseBattery MotorsEnabled end properties (Constant, Hidden) PropertyList = {'ForwardDisplacement', 'GainSchedule', 'LeftMotorTorque', 'LeftWheelDisplacement', 'LeftWheelVelocity', 'MotorsEnabled', 'OperationMode', 'PitchAngle', 'PitchRate', 'PowerbaseBattery', 'RightMotorTorque', 'RightWheelDisplacement', 'RightWheelVelocity', 'RollAngle', 'RollRate', 'ServoFrames', 'UiBattery', 'YawDisplacement', 'YawRate'} % List of non-constant message properties ROSPropertyList = {'forward_displacement', 'gain_schedule', 'left_motor_torque', 'left_wheel_displacement', 'left_wheel_velocity', 'motors_enabled', 'operation_mode', 'pitch_angle', 'pitch_rate', 'powerbase_battery', 'right_motor_torque', 'right_wheel_displacement', 'right_wheel_velocity', 'roll_angle', 'roll_rate', 'servo_frames', 'ui_battery', 'yaw_displacement', 'yaw_rate'} % List of non-constant ROS message properties end methods function obj = SegwayStatus(msg) %SegwayStatus Construct the message object SegwayStatus 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 pitchangle = get.PitchAngle(obj) %get.PitchAngle Get the value for property PitchAngle pitchangle = single(obj.JavaMessage.getPitchAngle); end function set.PitchAngle(obj, pitchangle) %set.PitchAngle Set the value for property PitchAngle validateattributes(pitchangle, {'numeric'}, {'nonempty', 'scalar'}, 'SegwayStatus', 'PitchAngle'); obj.JavaMessage.setPitchAngle(pitchangle); end function pitchrate = get.PitchRate(obj) %get.PitchRate Get the value for property PitchRate pitchrate = single(obj.JavaMessage.getPitchRate); end function set.PitchRate(obj, pitchrate) %set.PitchRate Set the value for property PitchRate validateattributes(pitchrate, {'numeric'}, {'nonempty', 'scalar'}, 'SegwayStatus', 'PitchRate'); obj.JavaMessage.setPitchRate(pitchrate); end function rollangle = get.RollAngle(obj) %get.RollAngle Get the value for property RollAngle rollangle = single(obj.JavaMessage.getRollAngle); end function set.RollAngle(obj, rollangle) %set.RollAngle Set the value for property RollAngle validateattributes(rollangle, {'numeric'}, {'nonempty', 'scalar'}, 'SegwayStatus', 'RollAngle'); obj.JavaMessage.setRollAngle(rollangle); end function rollrate = get.RollRate(obj) %get.RollRate Get the value for property RollRate rollrate = single(obj.JavaMessage.getRollRate); end function set.RollRate(obj, rollrate) %set.RollRate Set the value for property RollRate validateattributes(rollrate, {'numeric'}, {'nonempty', 'scalar'}, 'SegwayStatus', 'RollRate'); obj.JavaMessage.setRollRate(rollrate); end function leftwheelvelocity = get.LeftWheelVelocity(obj) %get.LeftWheelVelocity Get the value for property LeftWheelVelocity leftwheelvelocity = single(obj.JavaMessage.getLeftWheelVelocity); end function set.LeftWheelVelocity(obj, leftwheelvelocity) %set.LeftWheelVelocity Set the value for property LeftWheelVelocity validateattributes(leftwheelvelocity, {'numeric'}, {'nonempty', 'scalar'}, 'SegwayStatus', 'LeftWheelVelocity'); obj.JavaMessage.setLeftWheelVelocity(leftwheelvelocity); end function rightwheelvelocity = get.RightWheelVelocity(obj) %get.RightWheelVelocity Get the value for property RightWheelVelocity rightwheelvelocity = single(obj.JavaMessage.getRightWheelVelocity); end function set.RightWheelVelocity(obj, rightwheelvelocity) %set.RightWheelVelocity Set the value for property RightWheelVelocity validateattributes(rightwheelvelocity, {'numeric'}, {'nonempty', 'scalar'}, 'SegwayStatus', 'RightWheelVelocity'); obj.JavaMessage.setRightWheelVelocity(rightwheelvelocity); end function yawrate = get.YawRate(obj) %get.YawRate Get the value for property YawRate yawrate = single(obj.JavaMessage.getYawRate); end function set.YawRate(obj, yawrate) %set.YawRate Set the value for property YawRate validateattributes(yawrate, {'numeric'}, {'nonempty', 'scalar'}, 'SegwayStatus', 'YawRate'); obj.JavaMessage.setYawRate(yawrate); end function servoframes = get.ServoFrames(obj) %get.ServoFrames Get the value for property ServoFrames servoframes = single(obj.JavaMessage.getServoFrames); end function set.ServoFrames(obj, servoframes) %set.ServoFrames Set the value for property ServoFrames validateattributes(servoframes, {'numeric'}, {'nonempty', 'scalar'}, 'SegwayStatus', 'ServoFrames'); obj.JavaMessage.setServoFrames(servoframes); end function leftwheeldisplacement = get.LeftWheelDisplacement(obj) %get.LeftWheelDisplacement Get the value for property LeftWheelDisplacement leftwheeldisplacement = single(obj.JavaMessage.getLeftWheelDisplacement); end function set.LeftWheelDisplacement(obj, leftwheeldisplacement) %set.LeftWheelDisplacement Set the value for property LeftWheelDisplacement validateattributes(leftwheeldisplacement, {'numeric'}, {'nonempty', 'scalar'}, 'SegwayStatus', 'LeftWheelDisplacement'); obj.JavaMessage.setLeftWheelDisplacement(leftwheeldisplacement); end function rightwheeldisplacement = get.RightWheelDisplacement(obj) %get.RightWheelDisplacement Get the value for property RightWheelDisplacement rightwheeldisplacement = single(obj.JavaMessage.getRightWheelDisplacement); end function set.RightWheelDisplacement(obj, rightwheeldisplacement) %set.RightWheelDisplacement Set the value for property RightWheelDisplacement validateattributes(rightwheeldisplacement, {'numeric'}, {'nonempty', 'scalar'}, 'SegwayStatus', 'RightWheelDisplacement'); obj.JavaMessage.setRightWheelDisplacement(rightwheeldisplacement); end function forwarddisplacement = get.ForwardDisplacement(obj) %get.ForwardDisplacement Get the value for property ForwardDisplacement forwarddisplacement = single(obj.JavaMessage.getForwardDisplacement); end function set.ForwardDisplacement(obj, forwarddisplacement) %set.ForwardDisplacement Set the value for property ForwardDisplacement validateattributes(forwarddisplacement, {'numeric'}, {'nonempty', 'scalar'}, 'SegwayStatus', 'ForwardDisplacement'); obj.JavaMessage.setForwardDisplacement(forwarddisplacement); end function yawdisplacement = get.YawDisplacement(obj) %get.YawDisplacement Get the value for property YawDisplacement yawdisplacement = single(obj.JavaMessage.getYawDisplacement); end function set.YawDisplacement(obj, yawdisplacement) %set.YawDisplacement Set the value for property YawDisplacement validateattributes(yawdisplacement, {'numeric'}, {'nonempty', 'scalar'}, 'SegwayStatus', 'YawDisplacement'); obj.JavaMessage.setYawDisplacement(yawdisplacement); end function leftmotortorque = get.LeftMotorTorque(obj) %get.LeftMotorTorque Get the value for property LeftMotorTorque leftmotortorque = single(obj.JavaMessage.getLeftMotorTorque); end function set.LeftMotorTorque(obj, leftmotortorque) %set.LeftMotorTorque Set the value for property LeftMotorTorque validateattributes(leftmotortorque, {'numeric'}, {'nonempty', 'scalar'}, 'SegwayStatus', 'LeftMotorTorque'); obj.JavaMessage.setLeftMotorTorque(leftmotortorque); end function rightmotortorque = get.RightMotorTorque(obj) %get.RightMotorTorque Get the value for property RightMotorTorque rightmotortorque = single(obj.JavaMessage.getRightMotorTorque); end function set.RightMotorTorque(obj, rightmotortorque) %set.RightMotorTorque Set the value for property RightMotorTorque validateattributes(rightmotortorque, {'numeric'}, {'nonempty', 'scalar'}, 'SegwayStatus', 'RightMotorTorque'); obj.JavaMessage.setRightMotorTorque(rightmotortorque); end function operationmode = get.OperationMode(obj) %get.OperationMode Get the value for property OperationMode operationmode = int8(obj.JavaMessage.getOperationMode); end function set.OperationMode(obj, operationmode) %set.OperationMode Set the value for property OperationMode validateattributes(operationmode, {'numeric'}, {'nonempty', 'scalar'}, 'SegwayStatus', 'OperationMode'); obj.JavaMessage.setOperationMode(operationmode); end function gainschedule = get.GainSchedule(obj) %get.GainSchedule Get the value for property GainSchedule gainschedule = int8(obj.JavaMessage.getGainSchedule); end function set.GainSchedule(obj, gainschedule) %set.GainSchedule Set the value for property GainSchedule validateattributes(gainschedule, {'numeric'}, {'nonempty', 'scalar'}, 'SegwayStatus', 'GainSchedule'); obj.JavaMessage.setGainSchedule(gainschedule); end function uibattery = get.UiBattery(obj) %get.UiBattery Get the value for property UiBattery uibattery = single(obj.JavaMessage.getUiBattery); end function set.UiBattery(obj, uibattery) %set.UiBattery Set the value for property UiBattery validateattributes(uibattery, {'numeric'}, {'nonempty', 'scalar'}, 'SegwayStatus', 'UiBattery'); obj.JavaMessage.setUiBattery(uibattery); end function powerbasebattery = get.PowerbaseBattery(obj) %get.PowerbaseBattery Get the value for property PowerbaseBattery powerbasebattery = single(obj.JavaMessage.getPowerbaseBattery); end function set.PowerbaseBattery(obj, powerbasebattery) %set.PowerbaseBattery Set the value for property PowerbaseBattery validateattributes(powerbasebattery, {'numeric'}, {'nonempty', 'scalar'}, 'SegwayStatus', 'PowerbaseBattery'); obj.JavaMessage.setPowerbaseBattery(powerbasebattery); end function motorsenabled = get.MotorsEnabled(obj) %get.MotorsEnabled Get the value for property MotorsEnabled motorsenabled = logical(obj.JavaMessage.getMotorsEnabled); end function set.MotorsEnabled(obj, motorsenabled) %set.MotorsEnabled Set the value for property MotorsEnabled validateattributes(motorsenabled, {'logical', 'numeric'}, {'nonempty', 'scalar'}, 'SegwayStatus', 'MotorsEnabled'); obj.JavaMessage.setMotorsEnabled(motorsenabled); end end methods (Access = protected) function cpObj = copyElement(obj) %copyElement Implements deep copy behavior for message % Call default copy method for shallow copy cpObj = copyElement@robotics.ros.Message(obj); % Create a new Java message object cpObj.JavaMessage = obj.createNewJavaMessage; % Iterate over all primitive properties cpObj.PitchAngle = obj.PitchAngle; cpObj.PitchRate = obj.PitchRate; cpObj.RollAngle = obj.RollAngle; cpObj.RollRate = obj.RollRate; cpObj.LeftWheelVelocity = obj.LeftWheelVelocity; cpObj.RightWheelVelocity = obj.RightWheelVelocity; cpObj.YawRate = obj.YawRate; cpObj.ServoFrames = obj.ServoFrames; cpObj.LeftWheelDisplacement = obj.LeftWheelDisplacement; cpObj.RightWheelDisplacement = obj.RightWheelDisplacement; cpObj.ForwardDisplacement = obj.ForwardDisplacement; cpObj.YawDisplacement = obj.YawDisplacement; cpObj.LeftMotorTorque = obj.LeftMotorTorque; cpObj.RightMotorTorque = obj.RightMotorTorque; cpObj.OperationMode = obj.OperationMode; cpObj.GainSchedule = obj.GainSchedule; cpObj.UiBattery = obj.UiBattery; cpObj.PowerbaseBattery = obj.PowerbaseBattery; cpObj.MotorsEnabled = obj.MotorsEnabled; end function reload(obj, strObj) %reload Called by loadobj to assign properties obj.PitchAngle = strObj.PitchAngle; obj.PitchRate = strObj.PitchRate; obj.RollAngle = strObj.RollAngle; obj.RollRate = strObj.RollRate; obj.LeftWheelVelocity = strObj.LeftWheelVelocity; obj.RightWheelVelocity = strObj.RightWheelVelocity; obj.YawRate = strObj.YawRate; obj.ServoFrames = strObj.ServoFrames; obj.LeftWheelDisplacement = strObj.LeftWheelDisplacement; obj.RightWheelDisplacement = strObj.RightWheelDisplacement; obj.ForwardDisplacement = strObj.ForwardDisplacement; obj.YawDisplacement = strObj.YawDisplacement; obj.LeftMotorTorque = strObj.LeftMotorTorque; obj.RightMotorTorque = strObj.RightMotorTorque; obj.OperationMode = strObj.OperationMode; obj.GainSchedule = strObj.GainSchedule; obj.UiBattery = strObj.UiBattery; obj.PowerbaseBattery = strObj.PowerbaseBattery; obj.MotorsEnabled = strObj.MotorsEnabled; 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.PitchAngle = obj.PitchAngle; strObj.PitchRate = obj.PitchRate; strObj.RollAngle = obj.RollAngle; strObj.RollRate = obj.RollRate; strObj.LeftWheelVelocity = obj.LeftWheelVelocity; strObj.RightWheelVelocity = obj.RightWheelVelocity; strObj.YawRate = obj.YawRate; strObj.ServoFrames = obj.ServoFrames; strObj.LeftWheelDisplacement = obj.LeftWheelDisplacement; strObj.RightWheelDisplacement = obj.RightWheelDisplacement; strObj.ForwardDisplacement = obj.ForwardDisplacement; strObj.YawDisplacement = obj.YawDisplacement; strObj.LeftMotorTorque = obj.LeftMotorTorque; strObj.RightMotorTorque = obj.RightMotorTorque; strObj.OperationMode = obj.OperationMode; strObj.GainSchedule = obj.GainSchedule; strObj.UiBattery = obj.UiBattery; strObj.PowerbaseBattery = obj.PowerbaseBattery; strObj.MotorsEnabled = obj.MotorsEnabled; 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.segway_rmp.SegwayStatus.empty(0,1); return end % Create an empty message object obj = robotics.ros.msggen.segway_rmp.SegwayStatus; obj.reload(strObj); end end end