$search
00001 """autogenerated by genmsg_py from SonarArray.msg. Do not edit.""" 00002 import roslib.message 00003 import struct 00004 00005 import std_msgs.msg 00006 00007 class SonarArray(roslib.message.Message): 00008 _md5sum = "2984921c09aef26ad253c7629937a5bb" 00009 _type = "p2os_driver/SonarArray" 00010 _has_header = True #flag to mark the presence of a Header object 00011 _full_text = """Header header 00012 int32 ranges_count 00013 float64[] ranges 00014 00015 ================================================================================ 00016 MSG: std_msgs/Header 00017 # Standard metadata for higher-level stamped data types. 00018 # This is generally used to communicate timestamped data 00019 # in a particular coordinate frame. 00020 # 00021 # sequence ID: consecutively increasing ID 00022 uint32 seq 00023 #Two-integer timestamp that is expressed as: 00024 # * stamp.secs: seconds (stamp_secs) since epoch 00025 # * stamp.nsecs: nanoseconds since stamp_secs 00026 # time-handling sugar is provided by the client library 00027 time stamp 00028 #Frame this data is associated with 00029 # 0: no frame 00030 # 1: global frame 00031 string frame_id 00032 00033 """ 00034 __slots__ = ['header','ranges_count','ranges'] 00035 _slot_types = ['Header','int32','float64[]'] 00036 00037 def __init__(self, *args, **kwds): 00038 """ 00039 Constructor. Any message fields that are implicitly/explicitly 00040 set to None will be assigned a default value. The recommend 00041 use is keyword arguments as this is more robust to future message 00042 changes. You cannot mix in-order arguments and keyword arguments. 00043 00044 The available fields are: 00045 header,ranges_count,ranges 00046 00047 @param args: complete set of field values, in .msg order 00048 @param kwds: use keyword arguments corresponding to message field names 00049 to set specific fields. 00050 """ 00051 if args or kwds: 00052 super(SonarArray, self).__init__(*args, **kwds) 00053 #message fields cannot be None, assign default values for those that are 00054 if self.header is None: 00055 self.header = std_msgs.msg._Header.Header() 00056 if self.ranges_count is None: 00057 self.ranges_count = 0 00058 if self.ranges is None: 00059 self.ranges = [] 00060 else: 00061 self.header = std_msgs.msg._Header.Header() 00062 self.ranges_count = 0 00063 self.ranges = [] 00064 00065 def _get_types(self): 00066 """ 00067 internal API method 00068 """ 00069 return self._slot_types 00070 00071 def serialize(self, buff): 00072 """ 00073 serialize message into buffer 00074 @param buff: buffer 00075 @type buff: StringIO 00076 """ 00077 try: 00078 _x = self 00079 buff.write(_struct_3I.pack(_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs)) 00080 _x = self.header.frame_id 00081 length = len(_x) 00082 buff.write(struct.pack('<I%ss'%length, length, _x)) 00083 buff.write(_struct_i.pack(self.ranges_count)) 00084 length = len(self.ranges) 00085 buff.write(_struct_I.pack(length)) 00086 pattern = '<%sd'%length 00087 buff.write(struct.pack(pattern, *self.ranges)) 00088 except struct.error as se: self._check_types(se) 00089 except TypeError as te: self._check_types(te) 00090 00091 def deserialize(self, str): 00092 """ 00093 unpack serialized message in str into this message instance 00094 @param str: byte array of serialized message 00095 @type str: str 00096 """ 00097 try: 00098 if self.header is None: 00099 self.header = std_msgs.msg._Header.Header() 00100 end = 0 00101 _x = self 00102 start = end 00103 end += 12 00104 (_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs,) = _struct_3I.unpack(str[start:end]) 00105 start = end 00106 end += 4 00107 (length,) = _struct_I.unpack(str[start:end]) 00108 start = end 00109 end += length 00110 self.header.frame_id = str[start:end] 00111 start = end 00112 end += 4 00113 (self.ranges_count,) = _struct_i.unpack(str[start:end]) 00114 start = end 00115 end += 4 00116 (length,) = _struct_I.unpack(str[start:end]) 00117 pattern = '<%sd'%length 00118 start = end 00119 end += struct.calcsize(pattern) 00120 self.ranges = struct.unpack(pattern, str[start:end]) 00121 return self 00122 except struct.error as e: 00123 raise roslib.message.DeserializationError(e) #most likely buffer underfill 00124 00125 00126 def serialize_numpy(self, buff, numpy): 00127 """ 00128 serialize message with numpy array types into buffer 00129 @param buff: buffer 00130 @type buff: StringIO 00131 @param numpy: numpy python module 00132 @type numpy module 00133 """ 00134 try: 00135 _x = self 00136 buff.write(_struct_3I.pack(_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs)) 00137 _x = self.header.frame_id 00138 length = len(_x) 00139 buff.write(struct.pack('<I%ss'%length, length, _x)) 00140 buff.write(_struct_i.pack(self.ranges_count)) 00141 length = len(self.ranges) 00142 buff.write(_struct_I.pack(length)) 00143 pattern = '<%sd'%length 00144 buff.write(self.ranges.tostring()) 00145 except struct.error as se: self._check_types(se) 00146 except TypeError as te: self._check_types(te) 00147 00148 def deserialize_numpy(self, str, numpy): 00149 """ 00150 unpack serialized message in str into this message instance using numpy for array types 00151 @param str: byte array of serialized message 00152 @type str: str 00153 @param numpy: numpy python module 00154 @type numpy: module 00155 """ 00156 try: 00157 if self.header is None: 00158 self.header = std_msgs.msg._Header.Header() 00159 end = 0 00160 _x = self 00161 start = end 00162 end += 12 00163 (_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs,) = _struct_3I.unpack(str[start:end]) 00164 start = end 00165 end += 4 00166 (length,) = _struct_I.unpack(str[start:end]) 00167 start = end 00168 end += length 00169 self.header.frame_id = str[start:end] 00170 start = end 00171 end += 4 00172 (self.ranges_count,) = _struct_i.unpack(str[start:end]) 00173 start = end 00174 end += 4 00175 (length,) = _struct_I.unpack(str[start:end]) 00176 pattern = '<%sd'%length 00177 start = end 00178 end += struct.calcsize(pattern) 00179 self.ranges = numpy.frombuffer(str[start:end], dtype=numpy.float64, count=length) 00180 return self 00181 except struct.error as e: 00182 raise roslib.message.DeserializationError(e) #most likely buffer underfill 00183 00184 _struct_I = roslib.message.struct_I 00185 _struct_i = struct.Struct("<i") 00186 _struct_3I = struct.Struct("<3I")