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 = "0810b2ddb2829d16562fb583d2db4993"
00009 _type = "gazebo_plugins/ContactState"
00010 _has_header = False
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/Vector3[] contact_positions # list of contact position
00016 geometry_msgs/Vector3[] contact_normals # list of contact normals
00017 float64[] depths # list of penetration depths
00018
00019 ================================================================================
00020 MSG: geometry_msgs/Wrench
00021 # This represents force in free space, seperated into
00022 # it's linear and angular parts.
00023 Vector3 force
00024 Vector3 torque
00025
00026 ================================================================================
00027 MSG: geometry_msgs/Vector3
00028 # This represents a vector in free space.
00029
00030 float64 x
00031 float64 y
00032 float64 z
00033 """
00034 __slots__ = ['info','geom1_name','geom2_name','wrenches','contact_positions','contact_normals','depths']
00035 _slot_types = ['string','string','string','geometry_msgs/Wrench[]','geometry_msgs/Vector3[]','geometry_msgs/Vector3[]','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 info,geom1_name,geom2_name,wrenches,contact_positions,contact_normals,depths
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(ContactState, self).__init__(*args, **kwds)
00053
00054 if self.info is None:
00055 self.info = ''
00056 if self.geom1_name is None:
00057 self.geom1_name = ''
00058 if self.geom2_name is None:
00059 self.geom2_name = ''
00060 if self.wrenches is None:
00061 self.wrenches = []
00062 if self.contact_positions is None:
00063 self.contact_positions = []
00064 if self.contact_normals is None:
00065 self.contact_normals = []
00066 if self.depths is None:
00067 self.depths = []
00068 else:
00069 self.info = ''
00070 self.geom1_name = ''
00071 self.geom2_name = ''
00072 self.wrenches = []
00073 self.contact_positions = []
00074 self.contact_normals = []
00075 self.depths = []
00076
00077 def _get_types(self):
00078 """
00079 internal API method
00080 """
00081 return self._slot_types
00082
00083 def serialize(self, buff):
00084 """
00085 serialize message into buffer
00086 @param buff: buffer
00087 @type buff: StringIO
00088 """
00089 try:
00090 _x = self.info
00091 length = len(_x)
00092 buff.write(struct.pack('<I%ss'%length, length, _x))
00093 _x = self.geom1_name
00094 length = len(_x)
00095 buff.write(struct.pack('<I%ss'%length, length, _x))
00096 _x = self.geom2_name
00097 length = len(_x)
00098 buff.write(struct.pack('<I%ss'%length, length, _x))
00099 length = len(self.wrenches)
00100 buff.write(_struct_I.pack(length))
00101 for val1 in self.wrenches:
00102 _v1 = val1.force
00103 _x = _v1
00104 buff.write(_struct_3d.pack(_x.x, _x.y, _x.z))
00105 _v2 = val1.torque
00106 _x = _v2
00107 buff.write(_struct_3d.pack(_x.x, _x.y, _x.z))
00108 length = len(self.contact_positions)
00109 buff.write(_struct_I.pack(length))
00110 for val1 in self.contact_positions:
00111 _x = val1
00112 buff.write(_struct_3d.pack(_x.x, _x.y, _x.z))
00113 length = len(self.contact_normals)
00114 buff.write(_struct_I.pack(length))
00115 for val1 in self.contact_normals:
00116 _x = val1
00117 buff.write(_struct_3d.pack(_x.x, _x.y, _x.z))
00118 length = len(self.depths)
00119 buff.write(_struct_I.pack(length))
00120 pattern = '<%sd'%length
00121 buff.write(struct.pack(pattern, *self.depths))
00122 except struct.error, se: self._check_types(se)
00123 except TypeError, te: self._check_types(te)
00124
00125 def deserialize(self, str):
00126 """
00127 unpack serialized message in str into this message instance
00128 @param str: byte array of serialized message
00129 @type str: str
00130 """
00131 try:
00132 end = 0
00133 start = end
00134 end += 4
00135 (length,) = _struct_I.unpack(str[start:end])
00136 start = end
00137 end += length
00138 self.info = str[start:end]
00139 start = end
00140 end += 4
00141 (length,) = _struct_I.unpack(str[start:end])
00142 start = end
00143 end += length
00144 self.geom1_name = str[start:end]
00145 start = end
00146 end += 4
00147 (length,) = _struct_I.unpack(str[start:end])
00148 start = end
00149 end += length
00150 self.geom2_name = str[start:end]
00151 start = end
00152 end += 4
00153 (length,) = _struct_I.unpack(str[start:end])
00154 self.wrenches = []
00155 for i in xrange(0, length):
00156 val1 = geometry_msgs.msg.Wrench()
00157 _v3 = val1.force
00158 _x = _v3
00159 start = end
00160 end += 24
00161 (_x.x, _x.y, _x.z,) = _struct_3d.unpack(str[start:end])
00162 _v4 = val1.torque
00163 _x = _v4
00164 start = end
00165 end += 24
00166 (_x.x, _x.y, _x.z,) = _struct_3d.unpack(str[start:end])
00167 self.wrenches.append(val1)
00168 start = end
00169 end += 4
00170 (length,) = _struct_I.unpack(str[start:end])
00171 self.contact_positions = []
00172 for i in xrange(0, length):
00173 val1 = geometry_msgs.msg.Vector3()
00174 _x = val1
00175 start = end
00176 end += 24
00177 (_x.x, _x.y, _x.z,) = _struct_3d.unpack(str[start:end])
00178 self.contact_positions.append(val1)
00179 start = end
00180 end += 4
00181 (length,) = _struct_I.unpack(str[start:end])
00182 self.contact_normals = []
00183 for i in xrange(0, length):
00184 val1 = geometry_msgs.msg.Vector3()
00185 _x = val1
00186 start = end
00187 end += 24
00188 (_x.x, _x.y, _x.z,) = _struct_3d.unpack(str[start:end])
00189 self.contact_normals.append(val1)
00190 start = end
00191 end += 4
00192 (length,) = _struct_I.unpack(str[start:end])
00193 pattern = '<%sd'%length
00194 start = end
00195 end += struct.calcsize(pattern)
00196 self.depths = struct.unpack(pattern, str[start:end])
00197 return self
00198 except struct.error, e:
00199 raise roslib.message.DeserializationError(e)
00200
00201
00202 def serialize_numpy(self, buff, numpy):
00203 """
00204 serialize message with numpy array types into buffer
00205 @param buff: buffer
00206 @type buff: StringIO
00207 @param numpy: numpy python module
00208 @type numpy module
00209 """
00210 try:
00211 _x = self.info
00212 length = len(_x)
00213 buff.write(struct.pack('<I%ss'%length, length, _x))
00214 _x = self.geom1_name
00215 length = len(_x)
00216 buff.write(struct.pack('<I%ss'%length, length, _x))
00217 _x = self.geom2_name
00218 length = len(_x)
00219 buff.write(struct.pack('<I%ss'%length, length, _x))
00220 length = len(self.wrenches)
00221 buff.write(_struct_I.pack(length))
00222 for val1 in self.wrenches:
00223 _v5 = val1.force
00224 _x = _v5
00225 buff.write(_struct_3d.pack(_x.x, _x.y, _x.z))
00226 _v6 = val1.torque
00227 _x = _v6
00228 buff.write(_struct_3d.pack(_x.x, _x.y, _x.z))
00229 length = len(self.contact_positions)
00230 buff.write(_struct_I.pack(length))
00231 for val1 in self.contact_positions:
00232 _x = val1
00233 buff.write(_struct_3d.pack(_x.x, _x.y, _x.z))
00234 length = len(self.contact_normals)
00235 buff.write(_struct_I.pack(length))
00236 for val1 in self.contact_normals:
00237 _x = val1
00238 buff.write(_struct_3d.pack(_x.x, _x.y, _x.z))
00239 length = len(self.depths)
00240 buff.write(_struct_I.pack(length))
00241 pattern = '<%sd'%length
00242 buff.write(self.depths.tostring())
00243 except struct.error, se: self._check_types(se)
00244 except TypeError, te: self._check_types(te)
00245
00246 def deserialize_numpy(self, str, numpy):
00247 """
00248 unpack serialized message in str into this message instance using numpy for array types
00249 @param str: byte array of serialized message
00250 @type str: str
00251 @param numpy: numpy python module
00252 @type numpy: module
00253 """
00254 try:
00255 end = 0
00256 start = end
00257 end += 4
00258 (length,) = _struct_I.unpack(str[start:end])
00259 start = end
00260 end += length
00261 self.info = str[start:end]
00262 start = end
00263 end += 4
00264 (length,) = _struct_I.unpack(str[start:end])
00265 start = end
00266 end += length
00267 self.geom1_name = str[start:end]
00268 start = end
00269 end += 4
00270 (length,) = _struct_I.unpack(str[start:end])
00271 start = end
00272 end += length
00273 self.geom2_name = str[start:end]
00274 start = end
00275 end += 4
00276 (length,) = _struct_I.unpack(str[start:end])
00277 self.wrenches = []
00278 for i in xrange(0, length):
00279 val1 = geometry_msgs.msg.Wrench()
00280 _v7 = val1.force
00281 _x = _v7
00282 start = end
00283 end += 24
00284 (_x.x, _x.y, _x.z,) = _struct_3d.unpack(str[start:end])
00285 _v8 = val1.torque
00286 _x = _v8
00287 start = end
00288 end += 24
00289 (_x.x, _x.y, _x.z,) = _struct_3d.unpack(str[start:end])
00290 self.wrenches.append(val1)
00291 start = end
00292 end += 4
00293 (length,) = _struct_I.unpack(str[start:end])
00294 self.contact_positions = []
00295 for i in xrange(0, length):
00296 val1 = geometry_msgs.msg.Vector3()
00297 _x = val1
00298 start = end
00299 end += 24
00300 (_x.x, _x.y, _x.z,) = _struct_3d.unpack(str[start:end])
00301 self.contact_positions.append(val1)
00302 start = end
00303 end += 4
00304 (length,) = _struct_I.unpack(str[start:end])
00305 self.contact_normals = []
00306 for i in xrange(0, length):
00307 val1 = geometry_msgs.msg.Vector3()
00308 _x = val1
00309 start = end
00310 end += 24
00311 (_x.x, _x.y, _x.z,) = _struct_3d.unpack(str[start:end])
00312 self.contact_normals.append(val1)
00313 start = end
00314 end += 4
00315 (length,) = _struct_I.unpack(str[start:end])
00316 pattern = '<%sd'%length
00317 start = end
00318 end += struct.calcsize(pattern)
00319 self.depths = numpy.frombuffer(str[start:end], dtype=numpy.float64, count=length)
00320 return self
00321 except struct.error, e:
00322 raise roslib.message.DeserializationError(e)
00323
00324 _struct_I = roslib.message.struct_I
00325 _struct_3d = struct.Struct("<3d")