Go to the documentation of this file.00001 """autogenerated by genpy from esc_ros/StateValue.msg. Do not edit."""
00002 import sys
00003 python3 = True if sys.hexversion > 0x03000000 else False
00004 import genpy
00005 import struct
00006
00007
00008 class StateValue(genpy.Message):
00009 _md5sum = "a00e93aed4e5872ccb0198d9ee9c9039"
00010 _type = "esc_ros/StateValue"
00011 _has_header = False
00012 _full_text = """float32[] state
00013 float32 value
00014
00015 """
00016 __slots__ = ['state','value']
00017 _slot_types = ['float32[]','float32']
00018
00019 def __init__(self, *args, **kwds):
00020 """
00021 Constructor. Any message fields that are implicitly/explicitly
00022 set to None will be assigned a default value. The recommend
00023 use is keyword arguments as this is more robust to future message
00024 changes. You cannot mix in-order arguments and keyword arguments.
00025
00026 The available fields are:
00027 state,value
00028
00029 :param args: complete set of field values, in .msg order
00030 :param kwds: use keyword arguments corresponding to message field names
00031 to set specific fields.
00032 """
00033 if args or kwds:
00034 super(StateValue, self).__init__(*args, **kwds)
00035
00036 if self.state is None:
00037 self.state = []
00038 if self.value is None:
00039 self.value = 0.
00040 else:
00041 self.state = []
00042 self.value = 0.
00043
00044 def _get_types(self):
00045 """
00046 internal API method
00047 """
00048 return self._slot_types
00049
00050 def serialize(self, buff):
00051 """
00052 serialize message into buffer
00053 :param buff: buffer, ``StringIO``
00054 """
00055 try:
00056 length = len(self.state)
00057 buff.write(_struct_I.pack(length))
00058 pattern = '<%sf'%length
00059 buff.write(struct.pack(pattern, *self.state))
00060 buff.write(_struct_f.pack(self.value))
00061 except struct.error as se: self._check_types(se)
00062 except TypeError as te: self._check_types(te)
00063
00064 def deserialize(self, str):
00065 """
00066 unpack serialized message in str into this message instance
00067 :param str: byte array of serialized message, ``str``
00068 """
00069 try:
00070 end = 0
00071 start = end
00072 end += 4
00073 (length,) = _struct_I.unpack(str[start:end])
00074 pattern = '<%sf'%length
00075 start = end
00076 end += struct.calcsize(pattern)
00077 self.state = struct.unpack(pattern, str[start:end])
00078 start = end
00079 end += 4
00080 (self.value,) = _struct_f.unpack(str[start:end])
00081 return self
00082 except struct.error as e:
00083 raise genpy.DeserializationError(e)
00084
00085
00086 def serialize_numpy(self, buff, numpy):
00087 """
00088 serialize message with numpy array types into buffer
00089 :param buff: buffer, ``StringIO``
00090 :param numpy: numpy python module
00091 """
00092 try:
00093 length = len(self.state)
00094 buff.write(_struct_I.pack(length))
00095 pattern = '<%sf'%length
00096 buff.write(self.state.tostring())
00097 buff.write(_struct_f.pack(self.value))
00098 except struct.error as se: self._check_types(se)
00099 except TypeError as te: self._check_types(te)
00100
00101 def deserialize_numpy(self, str, numpy):
00102 """
00103 unpack serialized message in str into this message instance using numpy for array types
00104 :param str: byte array of serialized message, ``str``
00105 :param numpy: numpy python module
00106 """
00107 try:
00108 end = 0
00109 start = end
00110 end += 4
00111 (length,) = _struct_I.unpack(str[start:end])
00112 pattern = '<%sf'%length
00113 start = end
00114 end += struct.calcsize(pattern)
00115 self.state = numpy.frombuffer(str[start:end], dtype=numpy.float32, count=length)
00116 start = end
00117 end += 4
00118 (self.value,) = _struct_f.unpack(str[start:end])
00119 return self
00120 except struct.error as e:
00121 raise genpy.DeserializationError(e)
00122
00123 _struct_I = genpy.struct_I
00124 _struct_f = struct.Struct("<f")