$search
00001 """autogenerated by genmsg_py from PDFImpl.msg. Do not edit.""" 00002 import roslib.message 00003 import struct 00004 00005 import problib.msg 00006 00007 class PDFImpl(roslib.message.Message): 00008 _md5sum = "fb6528e73eebd5785d5111d28934c039" 00009 _type = "problib/PDFImpl" 00010 _has_header = False #flag to mark the presence of a Header object 00011 _full_text = """uint8 GAUSSIAN=1 00012 uint8 UNIFORM=2 00013 uint8 DISJUNCTION_STRING = 3 # PMF 00014 uint8 DISJUNCTION_FLOAT = 4 # PMF 00015 uint8 DISJUNCTION_PDF = 5 # Mixture 00016 uint8 CONJUNCTION = 6 00017 00018 uint8 type 00019 uint32 num_dimensions 00020 DimensionDescription[] dimensions 00021 00022 # Gaussian 00023 float64[] mean 00024 float64[] covariance 00025 00026 # Uniform 00027 float64 density 00028 00029 # For both mixture and discrete 00030 float64[] probabilities 00031 00032 # mixture of PFDs (conjunction or disjunction) 00033 uint32[] sub_pdf_ptrs 00034 00035 # discrete 00036 int32 domain_size 00037 float64[] values_float 00038 string[] values_string 00039 00040 00041 ================================================================================ 00042 MSG: problib/DimensionDescription 00043 # example: object1.pos_x = ["object1", "pos_x"] 00044 string[] fields 00045 00046 """ 00047 # Pseudo-constants 00048 GAUSSIAN = 1 00049 UNIFORM = 2 00050 DISJUNCTION_STRING = 3 00051 DISJUNCTION_FLOAT = 4 00052 DISJUNCTION_PDF = 5 00053 CONJUNCTION = 6 00054 00055 __slots__ = ['type','num_dimensions','dimensions','mean','covariance','density','probabilities','sub_pdf_ptrs','domain_size','values_float','values_string'] 00056 _slot_types = ['uint8','uint32','problib/DimensionDescription[]','float64[]','float64[]','float64','float64[]','uint32[]','int32','float64[]','string[]'] 00057 00058 def __init__(self, *args, **kwds): 00059 """ 00060 Constructor. Any message fields that are implicitly/explicitly 00061 set to None will be assigned a default value. The recommend 00062 use is keyword arguments as this is more robust to future message 00063 changes. You cannot mix in-order arguments and keyword arguments. 00064 00065 The available fields are: 00066 type,num_dimensions,dimensions,mean,covariance,density,probabilities,sub_pdf_ptrs,domain_size,values_float,values_string 00067 00068 @param args: complete set of field values, in .msg order 00069 @param kwds: use keyword arguments corresponding to message field names 00070 to set specific fields. 00071 """ 00072 if args or kwds: 00073 super(PDFImpl, self).__init__(*args, **kwds) 00074 #message fields cannot be None, assign default values for those that are 00075 if self.type is None: 00076 self.type = 0 00077 if self.num_dimensions is None: 00078 self.num_dimensions = 0 00079 if self.dimensions is None: 00080 self.dimensions = [] 00081 if self.mean is None: 00082 self.mean = [] 00083 if self.covariance is None: 00084 self.covariance = [] 00085 if self.density is None: 00086 self.density = 0. 00087 if self.probabilities is None: 00088 self.probabilities = [] 00089 if self.sub_pdf_ptrs is None: 00090 self.sub_pdf_ptrs = [] 00091 if self.domain_size is None: 00092 self.domain_size = 0 00093 if self.values_float is None: 00094 self.values_float = [] 00095 if self.values_string is None: 00096 self.values_string = [] 00097 else: 00098 self.type = 0 00099 self.num_dimensions = 0 00100 self.dimensions = [] 00101 self.mean = [] 00102 self.covariance = [] 00103 self.density = 0. 00104 self.probabilities = [] 00105 self.sub_pdf_ptrs = [] 00106 self.domain_size = 0 00107 self.values_float = [] 00108 self.values_string = [] 00109 00110 def _get_types(self): 00111 """ 00112 internal API method 00113 """ 00114 return self._slot_types 00115 00116 def serialize(self, buff): 00117 """ 00118 serialize message into buffer 00119 @param buff: buffer 00120 @type buff: StringIO 00121 """ 00122 try: 00123 _x = self 00124 buff.write(_struct_BI.pack(_x.type, _x.num_dimensions)) 00125 length = len(self.dimensions) 00126 buff.write(_struct_I.pack(length)) 00127 for val1 in self.dimensions: 00128 length = len(val1.fields) 00129 buff.write(_struct_I.pack(length)) 00130 for val2 in val1.fields: 00131 length = len(val2) 00132 buff.write(struct.pack('<I%ss'%length, length, val2)) 00133 length = len(self.mean) 00134 buff.write(_struct_I.pack(length)) 00135 pattern = '<%sd'%length 00136 buff.write(struct.pack(pattern, *self.mean)) 00137 length = len(self.covariance) 00138 buff.write(_struct_I.pack(length)) 00139 pattern = '<%sd'%length 00140 buff.write(struct.pack(pattern, *self.covariance)) 00141 buff.write(_struct_d.pack(self.density)) 00142 length = len(self.probabilities) 00143 buff.write(_struct_I.pack(length)) 00144 pattern = '<%sd'%length 00145 buff.write(struct.pack(pattern, *self.probabilities)) 00146 length = len(self.sub_pdf_ptrs) 00147 buff.write(_struct_I.pack(length)) 00148 pattern = '<%sI'%length 00149 buff.write(struct.pack(pattern, *self.sub_pdf_ptrs)) 00150 buff.write(_struct_i.pack(self.domain_size)) 00151 length = len(self.values_float) 00152 buff.write(_struct_I.pack(length)) 00153 pattern = '<%sd'%length 00154 buff.write(struct.pack(pattern, *self.values_float)) 00155 length = len(self.values_string) 00156 buff.write(_struct_I.pack(length)) 00157 for val1 in self.values_string: 00158 length = len(val1) 00159 buff.write(struct.pack('<I%ss'%length, length, val1)) 00160 except struct.error as se: self._check_types(se) 00161 except TypeError as te: self._check_types(te) 00162 00163 def deserialize(self, str): 00164 """ 00165 unpack serialized message in str into this message instance 00166 @param str: byte array of serialized message 00167 @type str: str 00168 """ 00169 try: 00170 end = 0 00171 _x = self 00172 start = end 00173 end += 5 00174 (_x.type, _x.num_dimensions,) = _struct_BI.unpack(str[start:end]) 00175 start = end 00176 end += 4 00177 (length,) = _struct_I.unpack(str[start:end]) 00178 self.dimensions = [] 00179 for i in range(0, length): 00180 val1 = problib.msg.DimensionDescription() 00181 start = end 00182 end += 4 00183 (length,) = _struct_I.unpack(str[start:end]) 00184 val1.fields = [] 00185 for i in range(0, length): 00186 start = end 00187 end += 4 00188 (length,) = _struct_I.unpack(str[start:end]) 00189 start = end 00190 end += length 00191 val2 = str[start:end] 00192 val1.fields.append(val2) 00193 self.dimensions.append(val1) 00194 start = end 00195 end += 4 00196 (length,) = _struct_I.unpack(str[start:end]) 00197 pattern = '<%sd'%length 00198 start = end 00199 end += struct.calcsize(pattern) 00200 self.mean = struct.unpack(pattern, str[start:end]) 00201 start = end 00202 end += 4 00203 (length,) = _struct_I.unpack(str[start:end]) 00204 pattern = '<%sd'%length 00205 start = end 00206 end += struct.calcsize(pattern) 00207 self.covariance = struct.unpack(pattern, str[start:end]) 00208 start = end 00209 end += 8 00210 (self.density,) = _struct_d.unpack(str[start:end]) 00211 start = end 00212 end += 4 00213 (length,) = _struct_I.unpack(str[start:end]) 00214 pattern = '<%sd'%length 00215 start = end 00216 end += struct.calcsize(pattern) 00217 self.probabilities = struct.unpack(pattern, str[start:end]) 00218 start = end 00219 end += 4 00220 (length,) = _struct_I.unpack(str[start:end]) 00221 pattern = '<%sI'%length 00222 start = end 00223 end += struct.calcsize(pattern) 00224 self.sub_pdf_ptrs = struct.unpack(pattern, str[start:end]) 00225 start = end 00226 end += 4 00227 (self.domain_size,) = _struct_i.unpack(str[start:end]) 00228 start = end 00229 end += 4 00230 (length,) = _struct_I.unpack(str[start:end]) 00231 pattern = '<%sd'%length 00232 start = end 00233 end += struct.calcsize(pattern) 00234 self.values_float = struct.unpack(pattern, str[start:end]) 00235 start = end 00236 end += 4 00237 (length,) = _struct_I.unpack(str[start:end]) 00238 self.values_string = [] 00239 for i in range(0, length): 00240 start = end 00241 end += 4 00242 (length,) = _struct_I.unpack(str[start:end]) 00243 start = end 00244 end += length 00245 val1 = str[start:end] 00246 self.values_string.append(val1) 00247 return self 00248 except struct.error as e: 00249 raise roslib.message.DeserializationError(e) #most likely buffer underfill 00250 00251 00252 def serialize_numpy(self, buff, numpy): 00253 """ 00254 serialize message with numpy array types into buffer 00255 @param buff: buffer 00256 @type buff: StringIO 00257 @param numpy: numpy python module 00258 @type numpy module 00259 """ 00260 try: 00261 _x = self 00262 buff.write(_struct_BI.pack(_x.type, _x.num_dimensions)) 00263 length = len(self.dimensions) 00264 buff.write(_struct_I.pack(length)) 00265 for val1 in self.dimensions: 00266 length = len(val1.fields) 00267 buff.write(_struct_I.pack(length)) 00268 for val2 in val1.fields: 00269 length = len(val2) 00270 buff.write(struct.pack('<I%ss'%length, length, val2)) 00271 length = len(self.mean) 00272 buff.write(_struct_I.pack(length)) 00273 pattern = '<%sd'%length 00274 buff.write(self.mean.tostring()) 00275 length = len(self.covariance) 00276 buff.write(_struct_I.pack(length)) 00277 pattern = '<%sd'%length 00278 buff.write(self.covariance.tostring()) 00279 buff.write(_struct_d.pack(self.density)) 00280 length = len(self.probabilities) 00281 buff.write(_struct_I.pack(length)) 00282 pattern = '<%sd'%length 00283 buff.write(self.probabilities.tostring()) 00284 length = len(self.sub_pdf_ptrs) 00285 buff.write(_struct_I.pack(length)) 00286 pattern = '<%sI'%length 00287 buff.write(self.sub_pdf_ptrs.tostring()) 00288 buff.write(_struct_i.pack(self.domain_size)) 00289 length = len(self.values_float) 00290 buff.write(_struct_I.pack(length)) 00291 pattern = '<%sd'%length 00292 buff.write(self.values_float.tostring()) 00293 length = len(self.values_string) 00294 buff.write(_struct_I.pack(length)) 00295 for val1 in self.values_string: 00296 length = len(val1) 00297 buff.write(struct.pack('<I%ss'%length, length, val1)) 00298 except struct.error as se: self._check_types(se) 00299 except TypeError as te: self._check_types(te) 00300 00301 def deserialize_numpy(self, str, numpy): 00302 """ 00303 unpack serialized message in str into this message instance using numpy for array types 00304 @param str: byte array of serialized message 00305 @type str: str 00306 @param numpy: numpy python module 00307 @type numpy: module 00308 """ 00309 try: 00310 end = 0 00311 _x = self 00312 start = end 00313 end += 5 00314 (_x.type, _x.num_dimensions,) = _struct_BI.unpack(str[start:end]) 00315 start = end 00316 end += 4 00317 (length,) = _struct_I.unpack(str[start:end]) 00318 self.dimensions = [] 00319 for i in range(0, length): 00320 val1 = problib.msg.DimensionDescription() 00321 start = end 00322 end += 4 00323 (length,) = _struct_I.unpack(str[start:end]) 00324 val1.fields = [] 00325 for i in range(0, length): 00326 start = end 00327 end += 4 00328 (length,) = _struct_I.unpack(str[start:end]) 00329 start = end 00330 end += length 00331 val2 = str[start:end] 00332 val1.fields.append(val2) 00333 self.dimensions.append(val1) 00334 start = end 00335 end += 4 00336 (length,) = _struct_I.unpack(str[start:end]) 00337 pattern = '<%sd'%length 00338 start = end 00339 end += struct.calcsize(pattern) 00340 self.mean = numpy.frombuffer(str[start:end], dtype=numpy.float64, count=length) 00341 start = end 00342 end += 4 00343 (length,) = _struct_I.unpack(str[start:end]) 00344 pattern = '<%sd'%length 00345 start = end 00346 end += struct.calcsize(pattern) 00347 self.covariance = numpy.frombuffer(str[start:end], dtype=numpy.float64, count=length) 00348 start = end 00349 end += 8 00350 (self.density,) = _struct_d.unpack(str[start:end]) 00351 start = end 00352 end += 4 00353 (length,) = _struct_I.unpack(str[start:end]) 00354 pattern = '<%sd'%length 00355 start = end 00356 end += struct.calcsize(pattern) 00357 self.probabilities = numpy.frombuffer(str[start:end], dtype=numpy.float64, count=length) 00358 start = end 00359 end += 4 00360 (length,) = _struct_I.unpack(str[start:end]) 00361 pattern = '<%sI'%length 00362 start = end 00363 end += struct.calcsize(pattern) 00364 self.sub_pdf_ptrs = numpy.frombuffer(str[start:end], dtype=numpy.uint32, count=length) 00365 start = end 00366 end += 4 00367 (self.domain_size,) = _struct_i.unpack(str[start:end]) 00368 start = end 00369 end += 4 00370 (length,) = _struct_I.unpack(str[start:end]) 00371 pattern = '<%sd'%length 00372 start = end 00373 end += struct.calcsize(pattern) 00374 self.values_float = numpy.frombuffer(str[start:end], dtype=numpy.float64, count=length) 00375 start = end 00376 end += 4 00377 (length,) = _struct_I.unpack(str[start:end]) 00378 self.values_string = [] 00379 for i in range(0, length): 00380 start = end 00381 end += 4 00382 (length,) = _struct_I.unpack(str[start:end]) 00383 start = end 00384 end += length 00385 val1 = str[start:end] 00386 self.values_string.append(val1) 00387 return self 00388 except struct.error as e: 00389 raise roslib.message.DeserializationError(e) #most likely buffer underfill 00390 00391 _struct_I = roslib.message.struct_I 00392 _struct_i = struct.Struct("<i") 00393 _struct_BI = struct.Struct("<BI") 00394 _struct_d = struct.Struct("<d")