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