$search
00001 """autogenerated by genmsg_py from PDF.msg. Do not edit.""" 00002 import roslib.message 00003 import struct 00004 00005 00006 class PDF(roslib.message.Message): 00007 _md5sum = "75a0d678d0983733e909d6d13b746309" 00008 _type = "problib/PDF" 00009 _has_header = False #flag to mark the presence of a Header object 00010 _full_text = """uint8 EXACT=0 # Is here for easier msg creation, but is actually a specialized case: 00011 # - continuous: is a Gaussian with zero covariance 00012 # - discrete: is a Discrete pdf with one entry with P=1 00013 uint8 GAUSSIAN=1 00014 uint8 UNIFORM=2 00015 uint8 PARTICLES=3 00016 uint8 MIXTURE=4 00017 uint8 DISCRETE=5 00018 uint8 HYBRID=6 00019 00020 uint8 type 00021 uint32 dimensions 00022 00023 # For continuous pdf's 00024 float64[] data 00025 00026 # For discrete pdf's (pmf) 00027 int32 domain_size 00028 string[] values 00029 float64[] probabilities 00030 00031 # For exact values, either a string or a vector 00032 string exact_value_str 00033 float64[] exact_value_vec 00034 00035 """ 00036 # Pseudo-constants 00037 EXACT = 0 00038 GAUSSIAN = 1 00039 UNIFORM = 2 00040 PARTICLES = 3 00041 MIXTURE = 4 00042 DISCRETE = 5 00043 HYBRID = 6 00044 00045 __slots__ = ['type','dimensions','data','domain_size','values','probabilities','exact_value_str','exact_value_vec'] 00046 _slot_types = ['uint8','uint32','float64[]','int32','string[]','float64[]','string','float64[]'] 00047 00048 def __init__(self, *args, **kwds): 00049 """ 00050 Constructor. Any message fields that are implicitly/explicitly 00051 set to None will be assigned a default value. The recommend 00052 use is keyword arguments as this is more robust to future message 00053 changes. You cannot mix in-order arguments and keyword arguments. 00054 00055 The available fields are: 00056 type,dimensions,data,domain_size,values,probabilities,exact_value_str,exact_value_vec 00057 00058 @param args: complete set of field values, in .msg order 00059 @param kwds: use keyword arguments corresponding to message field names 00060 to set specific fields. 00061 """ 00062 if args or kwds: 00063 super(PDF, self).__init__(*args, **kwds) 00064 #message fields cannot be None, assign default values for those that are 00065 if self.type is None: 00066 self.type = 0 00067 if self.dimensions is None: 00068 self.dimensions = 0 00069 if self.data is None: 00070 self.data = [] 00071 if self.domain_size is None: 00072 self.domain_size = 0 00073 if self.values is None: 00074 self.values = [] 00075 if self.probabilities is None: 00076 self.probabilities = [] 00077 if self.exact_value_str is None: 00078 self.exact_value_str = '' 00079 if self.exact_value_vec is None: 00080 self.exact_value_vec = [] 00081 else: 00082 self.type = 0 00083 self.dimensions = 0 00084 self.data = [] 00085 self.domain_size = 0 00086 self.values = [] 00087 self.probabilities = [] 00088 self.exact_value_str = '' 00089 self.exact_value_vec = [] 00090 00091 def _get_types(self): 00092 """ 00093 internal API method 00094 """ 00095 return self._slot_types 00096 00097 def serialize(self, buff): 00098 """ 00099 serialize message into buffer 00100 @param buff: buffer 00101 @type buff: StringIO 00102 """ 00103 try: 00104 _x = self 00105 buff.write(_struct_BI.pack(_x.type, _x.dimensions)) 00106 length = len(self.data) 00107 buff.write(_struct_I.pack(length)) 00108 pattern = '<%sd'%length 00109 buff.write(struct.pack(pattern, *self.data)) 00110 buff.write(_struct_i.pack(self.domain_size)) 00111 length = len(self.values) 00112 buff.write(_struct_I.pack(length)) 00113 for val1 in self.values: 00114 length = len(val1) 00115 buff.write(struct.pack('<I%ss'%length, length, val1)) 00116 length = len(self.probabilities) 00117 buff.write(_struct_I.pack(length)) 00118 pattern = '<%sd'%length 00119 buff.write(struct.pack(pattern, *self.probabilities)) 00120 _x = self.exact_value_str 00121 length = len(_x) 00122 buff.write(struct.pack('<I%ss'%length, length, _x)) 00123 length = len(self.exact_value_vec) 00124 buff.write(_struct_I.pack(length)) 00125 pattern = '<%sd'%length 00126 buff.write(struct.pack(pattern, *self.exact_value_vec)) 00127 except struct.error as se: self._check_types(se) 00128 except TypeError as te: self._check_types(te) 00129 00130 def deserialize(self, str): 00131 """ 00132 unpack serialized message in str into this message instance 00133 @param str: byte array of serialized message 00134 @type str: str 00135 """ 00136 try: 00137 end = 0 00138 _x = self 00139 start = end 00140 end += 5 00141 (_x.type, _x.dimensions,) = _struct_BI.unpack(str[start:end]) 00142 start = end 00143 end += 4 00144 (length,) = _struct_I.unpack(str[start:end]) 00145 pattern = '<%sd'%length 00146 start = end 00147 end += struct.calcsize(pattern) 00148 self.data = struct.unpack(pattern, str[start:end]) 00149 start = end 00150 end += 4 00151 (self.domain_size,) = _struct_i.unpack(str[start:end]) 00152 start = end 00153 end += 4 00154 (length,) = _struct_I.unpack(str[start:end]) 00155 self.values = [] 00156 for i in range(0, length): 00157 start = end 00158 end += 4 00159 (length,) = _struct_I.unpack(str[start:end]) 00160 start = end 00161 end += length 00162 val1 = str[start:end] 00163 self.values.append(val1) 00164 start = end 00165 end += 4 00166 (length,) = _struct_I.unpack(str[start:end]) 00167 pattern = '<%sd'%length 00168 start = end 00169 end += struct.calcsize(pattern) 00170 self.probabilities = struct.unpack(pattern, str[start:end]) 00171 start = end 00172 end += 4 00173 (length,) = _struct_I.unpack(str[start:end]) 00174 start = end 00175 end += length 00176 self.exact_value_str = str[start:end] 00177 start = end 00178 end += 4 00179 (length,) = _struct_I.unpack(str[start:end]) 00180 pattern = '<%sd'%length 00181 start = end 00182 end += struct.calcsize(pattern) 00183 self.exact_value_vec = struct.unpack(pattern, str[start:end]) 00184 return self 00185 except struct.error as e: 00186 raise roslib.message.DeserializationError(e) #most likely buffer underfill 00187 00188 00189 def serialize_numpy(self, buff, numpy): 00190 """ 00191 serialize message with numpy array types into buffer 00192 @param buff: buffer 00193 @type buff: StringIO 00194 @param numpy: numpy python module 00195 @type numpy module 00196 """ 00197 try: 00198 _x = self 00199 buff.write(_struct_BI.pack(_x.type, _x.dimensions)) 00200 length = len(self.data) 00201 buff.write(_struct_I.pack(length)) 00202 pattern = '<%sd'%length 00203 buff.write(self.data.tostring()) 00204 buff.write(_struct_i.pack(self.domain_size)) 00205 length = len(self.values) 00206 buff.write(_struct_I.pack(length)) 00207 for val1 in self.values: 00208 length = len(val1) 00209 buff.write(struct.pack('<I%ss'%length, length, val1)) 00210 length = len(self.probabilities) 00211 buff.write(_struct_I.pack(length)) 00212 pattern = '<%sd'%length 00213 buff.write(self.probabilities.tostring()) 00214 _x = self.exact_value_str 00215 length = len(_x) 00216 buff.write(struct.pack('<I%ss'%length, length, _x)) 00217 length = len(self.exact_value_vec) 00218 buff.write(_struct_I.pack(length)) 00219 pattern = '<%sd'%length 00220 buff.write(self.exact_value_vec.tostring()) 00221 except struct.error as se: self._check_types(se) 00222 except TypeError as te: self._check_types(te) 00223 00224 def deserialize_numpy(self, str, numpy): 00225 """ 00226 unpack serialized message in str into this message instance using numpy for array types 00227 @param str: byte array of serialized message 00228 @type str: str 00229 @param numpy: numpy python module 00230 @type numpy: module 00231 """ 00232 try: 00233 end = 0 00234 _x = self 00235 start = end 00236 end += 5 00237 (_x.type, _x.dimensions,) = _struct_BI.unpack(str[start:end]) 00238 start = end 00239 end += 4 00240 (length,) = _struct_I.unpack(str[start:end]) 00241 pattern = '<%sd'%length 00242 start = end 00243 end += struct.calcsize(pattern) 00244 self.data = numpy.frombuffer(str[start:end], dtype=numpy.float64, count=length) 00245 start = end 00246 end += 4 00247 (self.domain_size,) = _struct_i.unpack(str[start:end]) 00248 start = end 00249 end += 4 00250 (length,) = _struct_I.unpack(str[start:end]) 00251 self.values = [] 00252 for i in range(0, length): 00253 start = end 00254 end += 4 00255 (length,) = _struct_I.unpack(str[start:end]) 00256 start = end 00257 end += length 00258 val1 = str[start:end] 00259 self.values.append(val1) 00260 start = end 00261 end += 4 00262 (length,) = _struct_I.unpack(str[start:end]) 00263 pattern = '<%sd'%length 00264 start = end 00265 end += struct.calcsize(pattern) 00266 self.probabilities = numpy.frombuffer(str[start:end], dtype=numpy.float64, count=length) 00267 start = end 00268 end += 4 00269 (length,) = _struct_I.unpack(str[start:end]) 00270 start = end 00271 end += length 00272 self.exact_value_str = str[start:end] 00273 start = end 00274 end += 4 00275 (length,) = _struct_I.unpack(str[start:end]) 00276 pattern = '<%sd'%length 00277 start = end 00278 end += struct.calcsize(pattern) 00279 self.exact_value_vec = numpy.frombuffer(str[start:end], dtype=numpy.float64, count=length) 00280 return self 00281 except struct.error as e: 00282 raise roslib.message.DeserializationError(e) #most likely buffer underfill 00283 00284 _struct_I = roslib.message.struct_I 00285 _struct_i = struct.Struct("<i") 00286 _struct_BI = struct.Struct("<BI")