$search
00001 """autogenerated by genmsg_py from ContactState.msg. Do not edit.""" 00002 import roslib.message 00003 import struct 00004 00005 import geometry_msgs.msg 00006 00007 class ContactState(roslib.message.Message): 00008 _md5sum = "7f688fc24d90d16872fdc9ea8c6e45ab" 00009 _type = "gazebo_msgs/ContactState" 00010 _has_header = False #flag to mark the presence of a Header object 00011 _full_text = """string info # text info on this contact 00012 string geom1_name # name of contact geom1 00013 string geom2_name # name of contact geom2 00014 geometry_msgs/Wrench[] wrenches # list of forces/torques 00015 geometry_msgs/Wrench total_wrench # sum of forces/torques in every DOF 00016 geometry_msgs/Vector3[] contact_positions # list of contact position 00017 geometry_msgs/Vector3[] contact_normals # list of contact normals 00018 float64[] depths # list of penetration depths 00019 00020 ================================================================================ 00021 MSG: geometry_msgs/Wrench 00022 # This represents force in free space, seperated into 00023 # it's linear and angular parts. 00024 Vector3 force 00025 Vector3 torque 00026 00027 ================================================================================ 00028 MSG: geometry_msgs/Vector3 00029 # This represents a vector in free space. 00030 00031 float64 x 00032 float64 y 00033 float64 z 00034 """ 00035 __slots__ = ['info','geom1_name','geom2_name','wrenches','total_wrench','contact_positions','contact_normals','depths'] 00036 _slot_types = ['string','string','string','geometry_msgs/Wrench[]','geometry_msgs/Wrench','geometry_msgs/Vector3[]','geometry_msgs/Vector3[]','float64[]'] 00037 00038 def __init__(self, *args, **kwds): 00039 """ 00040 Constructor. Any message fields that are implicitly/explicitly 00041 set to None will be assigned a default value. The recommend 00042 use is keyword arguments as this is more robust to future message 00043 changes. You cannot mix in-order arguments and keyword arguments. 00044 00045 The available fields are: 00046 info,geom1_name,geom2_name,wrenches,total_wrench,contact_positions,contact_normals,depths 00047 00048 @param args: complete set of field values, in .msg order 00049 @param kwds: use keyword arguments corresponding to message field names 00050 to set specific fields. 00051 """ 00052 if args or kwds: 00053 super(ContactState, self).__init__(*args, **kwds) 00054 #message fields cannot be None, assign default values for those that are 00055 if self.info is None: 00056 self.info = '' 00057 if self.geom1_name is None: 00058 self.geom1_name = '' 00059 if self.geom2_name is None: 00060 self.geom2_name = '' 00061 if self.wrenches is None: 00062 self.wrenches = [] 00063 if self.total_wrench is None: 00064 self.total_wrench = geometry_msgs.msg.Wrench() 00065 if self.contact_positions is None: 00066 self.contact_positions = [] 00067 if self.contact_normals is None: 00068 self.contact_normals = [] 00069 if self.depths is None: 00070 self.depths = [] 00071 else: 00072 self.info = '' 00073 self.geom1_name = '' 00074 self.geom2_name = '' 00075 self.wrenches = [] 00076 self.total_wrench = geometry_msgs.msg.Wrench() 00077 self.contact_positions = [] 00078 self.contact_normals = [] 00079 self.depths = [] 00080 00081 def _get_types(self): 00082 """ 00083 internal API method 00084 """ 00085 return self._slot_types 00086 00087 def serialize(self, buff): 00088 """ 00089 serialize message into buffer 00090 @param buff: buffer 00091 @type buff: StringIO 00092 """ 00093 try: 00094 _x = self.info 00095 length = len(_x) 00096 buff.write(struct.pack('<I%ss'%length, length, _x)) 00097 _x = self.geom1_name 00098 length = len(_x) 00099 buff.write(struct.pack('<I%ss'%length, length, _x)) 00100 _x = self.geom2_name 00101 length = len(_x) 00102 buff.write(struct.pack('<I%ss'%length, length, _x)) 00103 length = len(self.wrenches) 00104 buff.write(_struct_I.pack(length)) 00105 for val1 in self.wrenches: 00106 _v1 = val1.force 00107 _x = _v1 00108 buff.write(_struct_3d.pack(_x.x, _x.y, _x.z)) 00109 _v2 = val1.torque 00110 _x = _v2 00111 buff.write(_struct_3d.pack(_x.x, _x.y, _x.z)) 00112 _x = self 00113 buff.write(_struct_6d.pack(_x.total_wrench.force.x, _x.total_wrench.force.y, _x.total_wrench.force.z, _x.total_wrench.torque.x, _x.total_wrench.torque.y, _x.total_wrench.torque.z)) 00114 length = len(self.contact_positions) 00115 buff.write(_struct_I.pack(length)) 00116 for val1 in self.contact_positions: 00117 _x = val1 00118 buff.write(_struct_3d.pack(_x.x, _x.y, _x.z)) 00119 length = len(self.contact_normals) 00120 buff.write(_struct_I.pack(length)) 00121 for val1 in self.contact_normals: 00122 _x = val1 00123 buff.write(_struct_3d.pack(_x.x, _x.y, _x.z)) 00124 length = len(self.depths) 00125 buff.write(_struct_I.pack(length)) 00126 pattern = '<%sd'%length 00127 buff.write(struct.pack(pattern, *self.depths)) 00128 except struct.error as se: self._check_types(se) 00129 except TypeError as te: self._check_types(te) 00130 00131 def deserialize(self, str): 00132 """ 00133 unpack serialized message in str into this message instance 00134 @param str: byte array of serialized message 00135 @type str: str 00136 """ 00137 try: 00138 if self.total_wrench is None: 00139 self.total_wrench = geometry_msgs.msg.Wrench() 00140 end = 0 00141 start = end 00142 end += 4 00143 (length,) = _struct_I.unpack(str[start:end]) 00144 start = end 00145 end += length 00146 self.info = str[start:end] 00147 start = end 00148 end += 4 00149 (length,) = _struct_I.unpack(str[start:end]) 00150 start = end 00151 end += length 00152 self.geom1_name = str[start:end] 00153 start = end 00154 end += 4 00155 (length,) = _struct_I.unpack(str[start:end]) 00156 start = end 00157 end += length 00158 self.geom2_name = str[start:end] 00159 start = end 00160 end += 4 00161 (length,) = _struct_I.unpack(str[start:end]) 00162 self.wrenches = [] 00163 for i in range(0, length): 00164 val1 = geometry_msgs.msg.Wrench() 00165 _v3 = val1.force 00166 _x = _v3 00167 start = end 00168 end += 24 00169 (_x.x, _x.y, _x.z,) = _struct_3d.unpack(str[start:end]) 00170 _v4 = val1.torque 00171 _x = _v4 00172 start = end 00173 end += 24 00174 (_x.x, _x.y, _x.z,) = _struct_3d.unpack(str[start:end]) 00175 self.wrenches.append(val1) 00176 _x = self 00177 start = end 00178 end += 48 00179 (_x.total_wrench.force.x, _x.total_wrench.force.y, _x.total_wrench.force.z, _x.total_wrench.torque.x, _x.total_wrench.torque.y, _x.total_wrench.torque.z,) = _struct_6d.unpack(str[start:end]) 00180 start = end 00181 end += 4 00182 (length,) = _struct_I.unpack(str[start:end]) 00183 self.contact_positions = [] 00184 for i in range(0, length): 00185 val1 = geometry_msgs.msg.Vector3() 00186 _x = val1 00187 start = end 00188 end += 24 00189 (_x.x, _x.y, _x.z,) = _struct_3d.unpack(str[start:end]) 00190 self.contact_positions.append(val1) 00191 start = end 00192 end += 4 00193 (length,) = _struct_I.unpack(str[start:end]) 00194 self.contact_normals = [] 00195 for i in range(0, length): 00196 val1 = geometry_msgs.msg.Vector3() 00197 _x = val1 00198 start = end 00199 end += 24 00200 (_x.x, _x.y, _x.z,) = _struct_3d.unpack(str[start:end]) 00201 self.contact_normals.append(val1) 00202 start = end 00203 end += 4 00204 (length,) = _struct_I.unpack(str[start:end]) 00205 pattern = '<%sd'%length 00206 start = end 00207 end += struct.calcsize(pattern) 00208 self.depths = struct.unpack(pattern, str[start:end]) 00209 return self 00210 except struct.error as e: 00211 raise roslib.message.DeserializationError(e) #most likely buffer underfill 00212 00213 00214 def serialize_numpy(self, buff, numpy): 00215 """ 00216 serialize message with numpy array types into buffer 00217 @param buff: buffer 00218 @type buff: StringIO 00219 @param numpy: numpy python module 00220 @type numpy module 00221 """ 00222 try: 00223 _x = self.info 00224 length = len(_x) 00225 buff.write(struct.pack('<I%ss'%length, length, _x)) 00226 _x = self.geom1_name 00227 length = len(_x) 00228 buff.write(struct.pack('<I%ss'%length, length, _x)) 00229 _x = self.geom2_name 00230 length = len(_x) 00231 buff.write(struct.pack('<I%ss'%length, length, _x)) 00232 length = len(self.wrenches) 00233 buff.write(_struct_I.pack(length)) 00234 for val1 in self.wrenches: 00235 _v5 = val1.force 00236 _x = _v5 00237 buff.write(_struct_3d.pack(_x.x, _x.y, _x.z)) 00238 _v6 = val1.torque 00239 _x = _v6 00240 buff.write(_struct_3d.pack(_x.x, _x.y, _x.z)) 00241 _x = self 00242 buff.write(_struct_6d.pack(_x.total_wrench.force.x, _x.total_wrench.force.y, _x.total_wrench.force.z, _x.total_wrench.torque.x, _x.total_wrench.torque.y, _x.total_wrench.torque.z)) 00243 length = len(self.contact_positions) 00244 buff.write(_struct_I.pack(length)) 00245 for val1 in self.contact_positions: 00246 _x = val1 00247 buff.write(_struct_3d.pack(_x.x, _x.y, _x.z)) 00248 length = len(self.contact_normals) 00249 buff.write(_struct_I.pack(length)) 00250 for val1 in self.contact_normals: 00251 _x = val1 00252 buff.write(_struct_3d.pack(_x.x, _x.y, _x.z)) 00253 length = len(self.depths) 00254 buff.write(_struct_I.pack(length)) 00255 pattern = '<%sd'%length 00256 buff.write(self.depths.tostring()) 00257 except struct.error as se: self._check_types(se) 00258 except TypeError as te: self._check_types(te) 00259 00260 def deserialize_numpy(self, str, numpy): 00261 """ 00262 unpack serialized message in str into this message instance using numpy for array types 00263 @param str: byte array of serialized message 00264 @type str: str 00265 @param numpy: numpy python module 00266 @type numpy: module 00267 """ 00268 try: 00269 if self.total_wrench is None: 00270 self.total_wrench = geometry_msgs.msg.Wrench() 00271 end = 0 00272 start = end 00273 end += 4 00274 (length,) = _struct_I.unpack(str[start:end]) 00275 start = end 00276 end += length 00277 self.info = str[start:end] 00278 start = end 00279 end += 4 00280 (length,) = _struct_I.unpack(str[start:end]) 00281 start = end 00282 end += length 00283 self.geom1_name = str[start:end] 00284 start = end 00285 end += 4 00286 (length,) = _struct_I.unpack(str[start:end]) 00287 start = end 00288 end += length 00289 self.geom2_name = str[start:end] 00290 start = end 00291 end += 4 00292 (length,) = _struct_I.unpack(str[start:end]) 00293 self.wrenches = [] 00294 for i in range(0, length): 00295 val1 = geometry_msgs.msg.Wrench() 00296 _v7 = val1.force 00297 _x = _v7 00298 start = end 00299 end += 24 00300 (_x.x, _x.y, _x.z,) = _struct_3d.unpack(str[start:end]) 00301 _v8 = val1.torque 00302 _x = _v8 00303 start = end 00304 end += 24 00305 (_x.x, _x.y, _x.z,) = _struct_3d.unpack(str[start:end]) 00306 self.wrenches.append(val1) 00307 _x = self 00308 start = end 00309 end += 48 00310 (_x.total_wrench.force.x, _x.total_wrench.force.y, _x.total_wrench.force.z, _x.total_wrench.torque.x, _x.total_wrench.torque.y, _x.total_wrench.torque.z,) = _struct_6d.unpack(str[start:end]) 00311 start = end 00312 end += 4 00313 (length,) = _struct_I.unpack(str[start:end]) 00314 self.contact_positions = [] 00315 for i in range(0, length): 00316 val1 = geometry_msgs.msg.Vector3() 00317 _x = val1 00318 start = end 00319 end += 24 00320 (_x.x, _x.y, _x.z,) = _struct_3d.unpack(str[start:end]) 00321 self.contact_positions.append(val1) 00322 start = end 00323 end += 4 00324 (length,) = _struct_I.unpack(str[start:end]) 00325 self.contact_normals = [] 00326 for i in range(0, length): 00327 val1 = geometry_msgs.msg.Vector3() 00328 _x = val1 00329 start = end 00330 end += 24 00331 (_x.x, _x.y, _x.z,) = _struct_3d.unpack(str[start:end]) 00332 self.contact_normals.append(val1) 00333 start = end 00334 end += 4 00335 (length,) = _struct_I.unpack(str[start:end]) 00336 pattern = '<%sd'%length 00337 start = end 00338 end += struct.calcsize(pattern) 00339 self.depths = numpy.frombuffer(str[start:end], dtype=numpy.float64, count=length) 00340 return self 00341 except struct.error as e: 00342 raise roslib.message.DeserializationError(e) #most likely buffer underfill 00343 00344 _struct_I = roslib.message.struct_I 00345 _struct_6d = struct.Struct("<6d") 00346 _struct_3d = struct.Struct("<3d")