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