def serialize(self, buff): """ serialize message into buffer :param buff: buffer, ``StringIO`` """ try: _x = self.agent_one length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode("utf-8") length = len(_x) buff.write(struct.pack("<I%ss" % length, length, _x)) _x = self.agent_two length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode("utf-8") length = len(_x) buff.write(struct.pack("<I%ss" % length, length, _x)) _x = self buff.write( _struct_6d.pack(_x.rotationx, _x.rotationy, _x.angle, _x.referencex, _x.referencey, _x.evaluation) ) except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(_x)))) except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(_x))))
def _struct_check_length(self, fmt, offset): if offset < 0: raise struct.error('can not (un)pack at a negative offset') fmt_size = struct.calcsize(fmt) if fmt_size > len(self) - offset: raise struct.error('(un)pack requires a buffer of at least %d bytes' % fmt_size)
def _count(format): """ Count the number of variables needed to pack a given format. """ if format[:1] in b"@=<>!": format = format[1:] count = 0 q = b"" for index in range(len(format)): char = format[index:index+1] if char.isdigit(): q += char continue elif char in b" \t\r\n": if q: raise error("bad char in struct format") continue elif char in b"ps": count += 1 q = b"" elif char in b"xcbB?hHiIlLqQfdP": count += int(q or 1) q = b"" else: raise error("bad char in struct format") return count
def fromstr(self, data): try: vals = self.unpack(data) ind = self._pack.index('id') if vals[ind] != self.id: raise struct.error("Packet id %s does not match my id %s" % (vals[ind], self.id)) if len(vals) == len(self._pack): for var in self._pack: setattr(self, var, vals[self._pack.index(var)]) return vals else: raise struct.error("Data indexes do not match pack indexes.") except (struct.error) as e: raise
def serialize_numpy(self, buff, numpy): """ serialize message with numpy array types into buffer :param buff: buffer, ``StringIO`` :param numpy: numpy python module """ try: _x = self.source length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss'%length, length, _x)) _x = self.type length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss'%length, length, _x)) _x = self.data length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss'%length, length, _x)) except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(_x)))) except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(_x))))
def serialize(self, buff): """ serialize message into buffer :param buff: buffer, ``StringIO`` """ try: _x = self buff.write(_struct_3I.pack(_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs)) _x = self.header.frame_id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) if python3: buff.write(struct.pack('<I%sB'%length, length, *_x)) else: buff.write(struct.pack('<I%ss'%length, length, _x)) _x = self buff.write(_struct_2I.pack(_x.goal_id.stamp.secs, _x.goal_id.stamp.nsecs)) _x = self.goal_id.id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) if python3: buff.write(struct.pack('<I%sB'%length, length, *_x)) else: buff.write(struct.pack('<I%ss'%length, length, _x)) buff.write(_struct_i.pack(self.goal.samples)) except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(locals().get('_x', self))))) except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(locals().get('_x', self)))))
def serialize_numpy(self, buff, numpy): """ serialize message with numpy array types into buffer :param buff: buffer, ``StringIO`` :param numpy: numpy python module """ try: length = len(self.results) buff.write(_struct_I.pack(length)) for val1 in self.results: _x = val1.key length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) if python3: buff.write(struct.pack('<I%sB'%length, length, *_x)) else: buff.write(struct.pack('<I%ss'%length, length, _x)) length = len(val1.values) buff.write(_struct_I.pack(length)) for val2 in val1.values: length = len(val2) if python3 or type(val2) == unicode: val2 = val2.encode('utf-8') length = len(val2) if python3: buff.write(struct.pack('<I%sB'%length, length, *val2)) else: buff.write(struct.pack('<I%ss'%length, length, val2)) except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(locals().get('_x', self))))) except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(locals().get('_x', self)))))
def serialize(self, buff): """ serialize message into buffer :param buff: buffer, ``StringIO`` """ try: _x = self.caller_id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) if python3: buff.write(struct.pack('<I%sB'%length, length, *_x)) else: buff.write(struct.pack('<I%ss'%length, length, _x)) _x = self.orig_caller_id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) if python3: buff.write(struct.pack('<I%sB'%length, length, *_x)) else: buff.write(struct.pack('<I%ss'%length, length, _x)) _x = self.data length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) if python3: buff.write(struct.pack('<I%sB'%length, length, *_x)) else: buff.write(struct.pack('<I%ss'%length, length, _x)) except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(_x)))) except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(_x))))
def serialize_numpy(self, buff, numpy): """ serialize message with numpy array types into buffer :param buff: buffer, ``StringIO`` :param numpy: numpy python module """ try: _x = self buff.write(_struct_if.pack(_x.a, _x.b)) _x = self.c length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) if python3: buff.write(struct.pack('<I%sB'%length, length, *_x)) else: buff.write(struct.pack('<I%ss'%length, length, _x)) buff.write(self.d.tostring()) length = len(self.e) buff.write(_struct_I.pack(length)) pattern = '<%sd'%length buff.write(self.e.tostring()) except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(_x)))) except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(_x))))
def serialize_numpy(self, buff, numpy): """ serialize message with numpy array types into buffer :param buff: buffer, ``StringIO`` :param numpy: numpy python module """ try: _x = self buff.write(_struct_3I.pack(_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs)) _x = self.header.frame_id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) if python3: buff.write(struct.pack('<I%sB'%length, length, *_x)) else: buff.write(struct.pack('<I%ss'%length, length, _x)) length = len(self.readings) buff.write(_struct_I.pack(length)) for val1 in self.readings: _x = val1 buff.write(_struct_2f.pack(_x.angle, _x.distance)) except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(locals().get('_x', self))))) except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(locals().get('_x', self)))))
def serialize(self, buff): """ serialize message into buffer :param buff: buffer, ``StringIO`` """ try: _x = self buff.write(_struct_3I.pack(_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs)) _x = self.header.frame_id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss'%length, length, _x)) _x = self buff.write(_struct_2I.pack(_x.status.goal_id.stamp.secs, _x.status.goal_id.stamp.nsecs)) _x = self.status.goal_id.id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss'%length, length, _x)) buff.write(_struct_B.pack(self.status.status)) _x = self.status.text length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss'%length, length, _x)) _x = self buff.write(_struct_2i.pack(_x.feedback.errorx, _x.feedback.errory)) except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(_x)))) except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(_x))))
def serialize(self, buff): """ serialize message into buffer :param buff: buffer, ``StringIO`` """ try: _x = self buff.write(_struct_3I.pack(_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs)) _x = self.header.frame_id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) if python3: buff.write(struct.pack('<I%sB'%length, length, *_x)) else: buff.write(struct.pack('<I%ss'%length, length, _x)) _x = self buff.write(_struct_6B.pack(_x.len, _x.seq, _x.sysid, _x.compid, _x.msgid, _x.fromlcm)) length = len(self.payload64) buff.write(_struct_I.pack(length)) pattern = '<%sQ'%length buff.write(struct.pack(pattern, *self.payload64)) except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(_x)))) except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(_x))))
def serialize_numpy(self, buff, numpy): """ serialize message with numpy array types into buffer :param buff: buffer, ``StringIO`` :param numpy: numpy python module """ try: length = len(self.x) buff.write(_struct_I.pack(length)) pattern = '<%sf'%length buff.write(self.x.tostring()) length = len(self.y) buff.write(_struct_I.pack(length)) pattern = '<%sf'%length buff.write(self.y.tostring()) length = len(self.z) buff.write(_struct_I.pack(length)) pattern = '<%sf'%length buff.write(self.z.tostring()) length = len(self.labels) buff.write(_struct_I.pack(length)) pattern = '<%si'%length buff.write(self.labels.tostring()) except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(_x)))) except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(_x))))
def serialize(self, buff): """ serialize message into buffer :param buff: buffer, ``StringIO`` """ try: length = len(self.roles) buff.write(_struct_I.pack(length)) for val1 in self.roles: length = len(val1) if python3 or type(val1) == unicode: val1 = val1.encode('utf-8') length = len(val1) if python3: buff.write(struct.pack('<I%sB'%length, length, *val1)) else: buff.write(struct.pack('<I%ss'%length, length, val1)) _x = self.uri length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) if python3: buff.write(struct.pack('<I%sB'%length, length, *_x)) else: buff.write(struct.pack('<I%ss'%length, length, _x)) except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(_x)))) except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(_x))))
def serialize_numpy(self, buff, numpy): """ serialize message with numpy array types into buffer :param buff: buffer, ``StringIO`` :param numpy: numpy python module """ try: _x = self.id.uuid # - if encoded as a list instead, serialize as bytes instead of string if type(_x) in [list, tuple]: buff.write(_struct_16B.pack(*_x)) else: buff.write(_struct_16s.pack(_x)) _x = self.keyword length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) if python3: buff.write(struct.pack('<I%sB'%length, length, *_x)) else: buff.write(struct.pack('<I%ss'%length, length, _x)) buff.write(_struct_B.pack(self.action)) except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(_x)))) except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(_x))))
def serialize(self, buff): """ serialize message into buffer :param buff: buffer, ``StringIO`` """ try: _x = self buff.write(_struct_3I.pack(_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs)) _x = self.header.frame_id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) if python3: buff.write(struct.pack('<I%sB'%length, length, *_x)) else: buff.write(struct.pack('<I%ss'%length, length, _x)) _x = self.ssid length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) if python3: buff.write(struct.pack('<I%sB'%length, length, *_x)) else: buff.write(struct.pack('<I%ss'%length, length, _x)) _x = self buff.write(_struct_h2B.pack(_x.rssi, _x.band, _x.channel)) except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(_x)))) except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(_x))))
def serialize_numpy(self, buff, numpy): """ serialize message with numpy array types into buffer :param buff: buffer, ``StringIO`` :param numpy: numpy python module """ try: length = len(self.layout.dim) buff.write(_struct_I.pack(length)) for val1 in self.layout.dim: _x = val1.label length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss'%length, length, _x)) _x = val1 buff.write(_get_struct_2I().pack(_x.size, _x.stride)) buff.write(_get_struct_I().pack(self.layout.data_offset)) length = len(self.data) buff.write(_struct_I.pack(length)) pattern = '<%sH'%length buff.write(self.data.tostring()) except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(locals().get('_x', self))))) except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(locals().get('_x', self)))))
def serialize_numpy(self, buff, numpy): """ serialize message with numpy array types into buffer :param buff: buffer, ``StringIO`` :param numpy: numpy python module """ try: _x = self buff.write(_struct_3I.pack(_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs)) _x = self.header.frame_id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) if python3: buff.write(struct.pack('<I%sB'%length, length, *_x)) else: buff.write(struct.pack('<I%ss'%length, length, _x)) _x = self.ns length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) if python3: buff.write(struct.pack('<I%sB'%length, length, *_x)) else: buff.write(struct.pack('<I%ss'%length, length, _x)) _x = self buff.write(_struct_3i10d4f2iB.pack(_x.id, _x.type, _x.action, _x.pose.position.x, _x.pose.position.y, _x.pose.position.z, _x.pose.orientation.x, _x.pose.orientation.y, _x.pose.orientation.z, _x.pose.orientation.w, _x.scale.x, _x.scale.y, _x.scale.z, _x.color.r, _x.color.g, _x.color.b, _x.color.a, _x.lifetime.secs, _x.lifetime.nsecs, _x.frame_locked)) length = len(self.points) buff.write(_struct_I.pack(length)) for val1 in self.points: _x = val1 buff.write(_struct_3d.pack(_x.x, _x.y, _x.z)) length = len(self.colors) buff.write(_struct_I.pack(length)) for val1 in self.colors: _x = val1 buff.write(_struct_4f.pack(_x.r, _x.g, _x.b, _x.a)) _x = self.text length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) if python3: buff.write(struct.pack('<I%sB'%length, length, *_x)) else: buff.write(struct.pack('<I%ss'%length, length, _x)) _x = self.mesh_resource length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) if python3: buff.write(struct.pack('<I%sB'%length, length, *_x)) else: buff.write(struct.pack('<I%ss'%length, length, _x)) buff.write(_struct_B.pack(self.mesh_use_embedded_materials)) except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(_x)))) except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(_x))))
def serialize_numpy(self, buff, numpy): """ serialize message with numpy array types into buffer :param buff: buffer, ``StringIO`` :param numpy: numpy python module """ try: _x = self buff.write(_struct_3I.pack(_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs)) _x = self.header.frame_id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) if python3: buff.write(struct.pack('<I%sB'%length, length, *_x)) else: buff.write(struct.pack('<I%ss'%length, length, _x)) length = len(self.edges) buff.write(_struct_I.pack(length)) for val1 in self.edges: _x = val1 buff.write(_struct_2q.pack(_x.idA, _x.idB)) _v7 = val1.poseATB _v8 = _v7.position _x = _v8 buff.write(_struct_3d.pack(_x.x, _x.y, _x.z)) _v9 = _v7.orientation _x = _v9 buff.write(_struct_4d.pack(_x.x, _x.y, _x.z, _x.w)) except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(_x)))) except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(_x))))
def serialize_numpy(self, buff, numpy): """ serialize message with numpy array types into buffer :param buff: buffer, ``StringIO`` :param numpy: numpy python module """ try: _x = self buff.write(_struct_3I.pack(_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs)) _x = self.header.frame_id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode("utf-8") length = len(_x) buff.write(struct.pack("<I%ss" % length, length, _x)) _x = self buff.write( _struct_5fi2B.pack( _x.voltage, _x.rate, _x.charge, _x.capacity, _x.design_capacity, _x.percentage, _x.charge_state, _x.present, ) ) except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(_x)))) except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(_x))))
def serialize_numpy(self, buff, numpy): """ serialize message with numpy array types into buffer :param buff: buffer, ``StringIO`` :param numpy: numpy python module """ try: _x = self buff.write(_struct_3I.pack(_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs)) _x = self.header.frame_id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss'%length, length, _x)) _x = self buff.write(_struct_2I.pack(_x.status.goal_id.stamp.secs, _x.status.goal_id.stamp.nsecs)) _x = self.status.goal_id.id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss'%length, length, _x)) buff.write(_struct_B.pack(self.status.status)) _x = self.status.text length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss'%length, length, _x)) buff.write(_struct_f.pack(self.feedback.percent_complete)) except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(_x)))) except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(_x))))
def serialize_numpy(self, buff, numpy): """ serialize message with numpy array types into buffer :param buff: buffer, ``StringIO`` :param numpy: numpy python module """ try: buff.write(_struct_b.pack(self.workspace_region_shape.type)) length = len(self.workspace_region_shape.dimensions) buff.write(_struct_I.pack(length)) pattern = '<%sd'%length buff.write(self.workspace_region_shape.dimensions.tostring()) length = len(self.workspace_region_shape.triangles) buff.write(_struct_I.pack(length)) pattern = '<%si'%length buff.write(self.workspace_region_shape.triangles.tostring()) length = len(self.workspace_region_shape.vertices) buff.write(_struct_I.pack(length)) for val1 in self.workspace_region_shape.vertices: _x = val1 buff.write(_struct_3d.pack(_x.x, _x.y, _x.z)) _x = self buff.write(_struct_3I.pack(_x.workspace_region_pose.header.seq, _x.workspace_region_pose.header.stamp.secs, _x.workspace_region_pose.header.stamp.nsecs)) _x = self.workspace_region_pose.header.frame_id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss'%length, length, _x)) _x = self buff.write(_struct_7d.pack(_x.workspace_region_pose.pose.position.x, _x.workspace_region_pose.pose.position.y, _x.workspace_region_pose.pose.position.z, _x.workspace_region_pose.pose.orientation.x, _x.workspace_region_pose.pose.orientation.y, _x.workspace_region_pose.pose.orientation.z, _x.workspace_region_pose.pose.orientation.w)) except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(_x)))) except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(_x))))
def serialize(self, buff): """ serialize message into buffer :param buff: buffer, ``StringIO`` """ try: _x = self buff.write(_struct_3I.pack(_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs)) _x = self.header.frame_id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) if python3: buff.write(struct.pack('<I%sB'%length, length, *_x)) else: buff.write(struct.pack('<I%ss'%length, length, _x)) buff.write(_struct_f.pack(self.processing_time)) length = len(self.keyframes) buff.write(_struct_I.pack(length)) pattern = '<%si'%length buff.write(struct.pack(pattern, *self.keyframes)) _x = self buff.write(_struct_3i.pack(_x.num_matches, _x.tracking_quality, _x.stage)) except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(_x)))) except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(_x))))
def serialize_numpy(self, buff, numpy): """ serialize message with numpy array types into buffer :param buff: buffer, ``StringIO`` :param numpy: numpy python module """ try: length = len(self.digital_inputs) buff.write(_struct_I.pack(length)) pattern = '<%sB'%length buff.write(self.digital_inputs.tostring()) length = len(self.digital_outputs) buff.write(_struct_I.pack(length)) pattern = '<%sB'%length buff.write(self.digital_outputs.tostring()) length = len(self.analog_inputs) buff.write(_struct_I.pack(length)) pattern = '<%sf'%length buff.write(self.analog_inputs.tostring()) length = len(self.analog_outputs) buff.write(_struct_I.pack(length)) pattern = '<%sf'%length buff.write(self.analog_outputs.tostring()) except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(locals().get('_x', self))))) except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(locals().get('_x', self)))))
def serialize(self, buff): """ serialize message into buffer :param buff: buffer, ``StringIO`` """ try: _x = self buff.write(_struct_3I.pack(_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs)) _x = self.header.frame_id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) if python3: buff.write(struct.pack('<I%sB'%length, length, *_x)) else: buff.write(struct.pack('<I%ss'%length, length, _x)) length = len(self.flow) buff.write(_struct_I.pack(length)) for val1 in self.flow: _v1 = val1.point _x = _v1 buff.write(_struct_2d.pack(_x.x, _x.y)) _v2 = val1.velocity _x = _v2 buff.write(_struct_2d.pack(_x.x, _x.y)) except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(_x)))) except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(_x))))
def serialize_numpy(self, buff, numpy): """ serialize message with numpy array types into buffer :param buff: buffer, ``StringIO`` :param numpy: numpy python module """ try: _x = self buff.write(_struct_3I.pack(_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs)) _x = self.header.frame_id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) if python3: buff.write(struct.pack('<I%sB'%length, length, *_x)) else: buff.write(struct.pack('<I%ss'%length, length, _x)) _x = self buff.write(_struct_2I.pack(_x.goal_id.stamp.secs, _x.goal_id.stamp.nsecs)) _x = self.goal_id.id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) if python3: buff.write(struct.pack('<I%sB'%length, length, *_x)) else: buff.write(struct.pack('<I%ss'%length, length, _x)) _x = self buff.write(_struct_B6fib.pack(_x.goal.mode.mode, _x.goal.mode.color.r, _x.goal.mode.color.g, _x.goal.mode.color.b, _x.goal.mode.color.a, _x.goal.mode.frequency, _x.goal.mode.timeout, _x.goal.mode.pulses, _x.goal.mode.priority)) except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(_x)))) except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(_x))))
def serialize_numpy(self, buff, numpy): """ serialize message with numpy array types into buffer :param buff: buffer, ``StringIO`` :param numpy: numpy python module """ try: _x = self buff.write(_struct_H3I.pack(_x.vehicle_id, _x.state.header.seq, _x.state.header.stamp.secs, _x.state.header.stamp.nsecs)) _x = self.state.header.frame_id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) if python3: buff.write(struct.pack('<I%sB'%length, length, *_x)) else: buff.write(struct.pack('<I%ss'%length, length, _x)) _x = self.state.child_frame_id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) if python3: buff.write(struct.pack('<I%sB'%length, length, *_x)) else: buff.write(struct.pack('<I%ss'%length, length, _x)) _x = self buff.write(_struct_4d2B4d.pack(_x.state.pose.pose.position.lat, _x.state.pose.pose.position.lon, _x.state.pose.pose.position.alt, _x.state.pose.pose.position.rel_alt, _x.state.pose.pose.position.using_alt, _x.state.pose.pose.position.using_rel_alt, _x.state.pose.pose.orientation.x, _x.state.pose.pose.orientation.y, _x.state.pose.pose.orientation.z, _x.state.pose.pose.orientation.w)) buff.write(self.state.pose.covariance.tostring()) _x = self buff.write(_struct_6d.pack(_x.state.twist.twist.linear.x, _x.state.twist.twist.linear.y, _x.state.twist.twist.linear.z, _x.state.twist.twist.angular.x, _x.state.twist.twist.angular.y, _x.state.twist.twist.angular.z)) buff.write(self.state.twist.covariance.tostring()) except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(locals().get('_x', self))))) except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(locals().get('_x', self)))))
def serialize(self, buff): """ serialize message into buffer :param buff: buffer, ``StringIO`` """ try: _x = self.resource_name length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) if python3: buff.write(struct.pack('<I%sB'%length, length, *_x)) else: buff.write(struct.pack('<I%ss'%length, length, _x)) _x = self.format length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) if python3: buff.write(struct.pack('<I%sB'%length, length, *_x)) else: buff.write(struct.pack('<I%ss'%length, length, _x)) _x = self.data length = len(_x) # - if encoded as a list instead, serialize as bytes instead of string if type(_x) in [list, tuple]: buff.write(struct.pack('<I%sB'%length, length, *_x)) else: buff.write(struct.pack('<I%ss'%length, length, _x)) except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(_x)))) except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(_x))))
def serialize(self, buff): """ serialize message into buffer :param buff: buffer, ``StringIO`` """ try: _x = self buff.write(_struct_3I.pack(_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs)) _x = self.header.frame_id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) if python3: buff.write(struct.pack('<I%sB'%length, length, *_x)) else: buff.write(struct.pack('<I%ss'%length, length, _x)) length = len(self.acceleration) buff.write(_struct_I.pack(length)) pattern = '<%sd'%length buff.write(struct.pack(pattern, *self.acceleration)) length = len(self.orientation) buff.write(_struct_I.pack(length)) pattern = '<%sd'%length buff.write(struct.pack(pattern, *self.orientation)) length = len(self.stamp) buff.write(_struct_I.pack(length)) for val1 in self.stamp: _x = val1 buff.write(_struct_2I.pack(_x.secs, _x.nsecs)) except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(_x)))) except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(_x))))
def serialize_numpy(self, buff, numpy): """ serialize message with numpy array types into buffer :param buff: buffer, ``StringIO`` :param numpy: numpy python module """ try: _x = self buff.write(_struct_3I.pack(_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs)) _x = self.header.frame_id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) if python3: buff.write(struct.pack('<I%sB'%length, length, *_x)) else: buff.write(struct.pack('<I%ss'%length, length, _x)) length = len(self.data) buff.write(_struct_I.pack(length)) pattern = '<%sI'%length buff.write(self.data.tostring()) _x = self buff.write(_struct_3f3d3I.pack(_x.origin.x, _x.origin.y, _x.origin.z, _x.resolutions.x, _x.resolutions.y, _x.resolutions.z, _x.size_x, _x.size_y, _x.size_z)) except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(locals().get('_x', self))))) except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(locals().get('_x', self)))))
def serialize(self, buff): """ serialize message into buffer :param buff: buffer, ``StringIO`` """ try: length = len(self.layout.dim) buff.write(_struct_I.pack(length)) for val1 in self.layout.dim: _x = val1.label length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) if python3: buff.write(struct.pack('<I%sB' % length, length, *_x)) else: buff.write(struct.pack('<I%ss' % length, length, _x)) _x = val1 buff.write(_struct_2I.pack(_x.size, _x.stride)) buff.write(_struct_I.pack(self.layout.data_offset)) _x = self.data length = len(_x) # - if encoded as a list instead, serialize as bytes instead of string if type(_x) in [list, tuple]: buff.write(struct.pack('<I%sB' % length, length, *_x)) else: buff.write(struct.pack('<I%ss' % length, length, _x)) except struct.error as se: self._check_types( struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(_x)))) except TypeError as te: self._check_types( ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(_x))))
def serialize_numpy(self, buff, numpy): """ serialize message with numpy array types into buffer :param buff: buffer, ``StringIO`` :param numpy: numpy python module """ try: buff.write(_get_struct_B().pack(self.isEnabled)) _x = self.uid length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss' % length, length, _x)) buff.write(_get_struct_B().pack(self.data.tuneGravitySpring)) except struct.error as se: self._check_types( struct.error( "%s: '%s' when writing '%s'" % (type(se), str(se), str(locals().get('_x', self))))) except TypeError as te: self._check_types( ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(locals().get('_x', self)))))
def serialize(self, buff): """ serialize message into buffer :param buff: buffer, ``StringIO`` """ try: _x = self buff.write(_get_struct_3I().pack(_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs)) _x = self.header.frame_id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss'%length, length, _x)) length = len(self.position) buff.write(_struct_I.pack(length)) pattern = '<%sd'%length buff.write(struct.pack(pattern, *self.position)) length = len(self.effort) buff.write(_struct_I.pack(length)) pattern = '<%sd'%length buff.write(struct.pack(pattern, *self.effort)) except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(locals().get('_x', self))))) except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(locals().get('_x', self)))))
def serialize(self, buff): """ serialize message into buffer :param buff: buffer, ``StringIO`` """ try: _x = self.service length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) if python3: buff.write(struct.pack('<I%sB' % length, length, *_x)) else: buff.write(struct.pack('<I%ss' % length, length, _x)) except struct.error as se: self._check_types( struct.error( "%s: '%s' when writing '%s'" % (type(se), str(se), str(locals().get('_x', self))))) except TypeError as te: self._check_types( ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(locals().get('_x', self)))))
def serialize_numpy(self, buff, numpy): """ serialize message with numpy array types into buffer :param buff: buffer, ``StringIO`` :param numpy: numpy python module """ try: _x = self buff.write( _struct_3I.pack(_x.footprint.header.seq, _x.footprint.header.stamp.secs, _x.footprint.header.stamp.nsecs)) _x = self.footprint.header.frame_id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) if python3: buff.write(struct.pack('<I%sB' % length, length, *_x)) else: buff.write(struct.pack('<I%ss' % length, length, _x)) length = len(self.footprint.polygon.points) buff.write(_struct_I.pack(length)) for val1 in self.footprint.polygon.points: _x = val1 buff.write(_struct_3f.pack(_x.x, _x.y, _x.z)) buff.write(_struct_B.pack(self.success.data)) except struct.error as se: self._check_types( struct.error( "%s: '%s' when writing '%s'" % (type(se), str(se), str(locals().get('_x', self))))) except TypeError as te: self._check_types( ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(locals().get('_x', self)))))
def serialize_numpy(self, buff, numpy): """ serialize message with numpy array types into buffer :param buff: buffer, ``StringIO`` :param numpy: numpy python module """ try: _x = self buff.write(_get_struct_3I().pack(_x.action_goal.header.seq, _x.action_goal.header.stamp.secs, _x.action_goal.header.stamp.nsecs)) _x = self.action_goal.header.frame_id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.Struct('<I%ss'%length).pack(length, _x)) _x = self buff.write(_get_struct_2I().pack(_x.action_goal.goal_id.stamp.secs, _x.action_goal.goal_id.stamp.nsecs)) _x = self.action_goal.goal_id.id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.Struct('<I%ss'%length).pack(length, _x)) _x = self buff.write(_get_struct_2f3I().pack(_x.action_goal.goal.turn_distance, _x.action_goal.goal.forward_distance, _x.action_result.header.seq, _x.action_result.header.stamp.secs, _x.action_result.header.stamp.nsecs)) _x = self.action_result.header.frame_id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.Struct('<I%ss'%length).pack(length, _x)) _x = self buff.write(_get_struct_2I().pack(_x.action_result.status.goal_id.stamp.secs, _x.action_result.status.goal_id.stamp.nsecs)) _x = self.action_result.status.goal_id.id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.Struct('<I%ss'%length).pack(length, _x)) _x = self.action_result.status.status buff.write(_get_struct_B().pack(_x)) _x = self.action_result.status.text length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.Struct('<I%ss'%length).pack(length, _x)) _x = self buff.write(_get_struct_2f3I().pack(_x.action_result.result.turn_distance, _x.action_result.result.forward_distance, _x.action_feedback.header.seq, _x.action_feedback.header.stamp.secs, _x.action_feedback.header.stamp.nsecs)) _x = self.action_feedback.header.frame_id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.Struct('<I%ss'%length).pack(length, _x)) _x = self buff.write(_get_struct_2I().pack(_x.action_feedback.status.goal_id.stamp.secs, _x.action_feedback.status.goal_id.stamp.nsecs)) _x = self.action_feedback.status.goal_id.id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.Struct('<I%ss'%length).pack(length, _x)) _x = self.action_feedback.status.status buff.write(_get_struct_B().pack(_x)) _x = self.action_feedback.status.text length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.Struct('<I%ss'%length).pack(length, _x)) _x = self buff.write(_get_struct_2f().pack(_x.action_feedback.feedback.turn_distance, _x.action_feedback.feedback.forward_distance)) except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(locals().get('_x', self))))) except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(locals().get('_x', self)))))
def serialize_numpy(self, buff, numpy): """ serialize message with numpy array types into buffer :param buff: buffer, ``StringIO`` :param numpy: numpy python module """ try: _x = self buff.write(_get_struct_3I().pack( _x.action_goal.header.seq, _x.action_goal.header.stamp.secs, _x.action_goal.header.stamp.nsecs)) _x = self.action_goal.header.frame_id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.Struct('<I%ss' % length).pack(length, _x)) _x = self buff.write(_get_struct_2I().pack( _x.action_goal.goal_id.stamp.secs, _x.action_goal.goal_id.stamp.nsecs)) _x = self.action_goal.goal_id.id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.Struct('<I%ss' % length).pack(length, _x)) buff.write(self.action_goal.goal.jp_right_relate.tostring()) buff.write(self.action_goal.goal.jp_left_relate.tostring()) _x = self.action_goal.goal.jp_linear buff.write(_get_struct_f().pack(_x)) buff.write(self.action_goal.goal.jp_head.tostring()) _x = self.action_goal.goal.duration buff.write(_get_struct_f().pack(_x)) buff.write(self.action_goal.goal.r_max_force.tostring()) buff.write(self.action_goal.goal.l_max_force.tostring()) _x = self buff.write(_get_struct_3I().pack( _x.action_result.header.seq, _x.action_result.header.stamp.secs, _x.action_result.header.stamp.nsecs)) _x = self.action_result.header.frame_id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.Struct('<I%ss' % length).pack(length, _x)) _x = self buff.write(_get_struct_2I().pack( _x.action_result.status.goal_id.stamp.secs, _x.action_result.status.goal_id.stamp.nsecs)) _x = self.action_result.status.goal_id.id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.Struct('<I%ss' % length).pack(length, _x)) _x = self.action_result.status.status buff.write(_get_struct_B().pack(_x)) _x = self.action_result.status.text length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.Struct('<I%ss' % length).pack(length, _x)) _x = self buff.write(_get_struct_B3I().pack( _x.action_result.result.success, _x.action_feedback.header.seq, _x.action_feedback.header.stamp.secs, _x.action_feedback.header.stamp.nsecs)) _x = self.action_feedback.header.frame_id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.Struct('<I%ss' % length).pack(length, _x)) _x = self buff.write(_get_struct_2I().pack( _x.action_feedback.status.goal_id.stamp.secs, _x.action_feedback.status.goal_id.stamp.nsecs)) _x = self.action_feedback.status.goal_id.id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.Struct('<I%ss' % length).pack(length, _x)) _x = self.action_feedback.status.status buff.write(_get_struct_B().pack(_x)) _x = self.action_feedback.status.text length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.Struct('<I%ss' % length).pack(length, _x)) _x = self.action_feedback.feedback.NotImplemented buff.write(_get_struct_B().pack(_x)) except struct.error as se: self._check_types( struct.error( "%s: '%s' when writing '%s'" % (type(se), str(se), str(locals().get('_x', self))))) except TypeError as te: self._check_types( ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(locals().get('_x', self)))))
def serialize_numpy(self, buff, numpy): """ serialize message with numpy array types into buffer :param buff: buffer, ``StringIO`` :param numpy: numpy python module """ try: _x = self buff.write(_get_struct_3I().pack(_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs)) _x = self.header.frame_id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.Struct('<I%ss'%length).pack(length, _x)) length = len(self.results) buff.write(_struct_I.pack(length)) for val1 in self.results: _x = val1.id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.Struct('<I%ss'%length).pack(length, _x)) _x = val1.score buff.write(_get_struct_d().pack(_x)) _v9 = val1.pose _v10 = _v9.pose _v11 = _v10.position _x = _v11 buff.write(_get_struct_3d().pack(_x.x, _x.y, _x.z)) _v12 = _v10.orientation _x = _v12 buff.write(_get_struct_4d().pack(_x.x, _x.y, _x.z, _x.w)) buff.write(_v9.covariance.tostring()) _x = self buff.write(_get_struct_10d3I().pack(_x.bbox.center.position.x, _x.bbox.center.position.y, _x.bbox.center.position.z, _x.bbox.center.orientation.x, _x.bbox.center.orientation.y, _x.bbox.center.orientation.z, _x.bbox.center.orientation.w, _x.bbox.size.x, _x.bbox.size.y, _x.bbox.size.z, _x.source_cloud.header.seq, _x.source_cloud.header.stamp.secs, _x.source_cloud.header.stamp.nsecs)) _x = self.source_cloud.header.frame_id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.Struct('<I%ss'%length).pack(length, _x)) _x = self buff.write(_get_struct_2I().pack(_x.source_cloud.height, _x.source_cloud.width)) length = len(self.source_cloud.fields) buff.write(_struct_I.pack(length)) for val1 in self.source_cloud.fields: _x = val1.name length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.Struct('<I%ss'%length).pack(length, _x)) _x = val1 buff.write(_get_struct_IBI().pack(_x.offset, _x.datatype, _x.count)) _x = self buff.write(_get_struct_B2I().pack(_x.source_cloud.is_bigendian, _x.source_cloud.point_step, _x.source_cloud.row_step)) _x = self.source_cloud.data length = len(_x) # - if encoded as a list instead, serialize as bytes instead of string if type(_x) in [list, tuple]: buff.write(struct.Struct('<I%sB'%length).pack(length, *_x)) else: buff.write(struct.Struct('<I%ss'%length).pack(length, _x)) _x = self buff.write(_get_struct_2B().pack(_x.source_cloud.is_dense, _x.is_tracking)) _x = self.tracking_id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.Struct('<I%ss'%length).pack(length, _x)) except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(locals().get('_x', self))))) except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(locals().get('_x', self)))))
def serialize_numpy(self, buff, numpy): """ serialize message with numpy array types into buffer :param buff: buffer, ``StringIO`` :param numpy: numpy python module """ try: _x = self buff.write( _struct_3I.pack(_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs)) _x = self.header.frame_id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) if python3: buff.write(struct.pack('<I%sB' % length, length, *_x)) else: buff.write(struct.pack('<I%ss' % length, length, _x)) _x = self buff.write( _struct_2I.pack(_x.status.goal_id.stamp.secs, _x.status.goal_id.stamp.nsecs)) _x = self.status.goal_id.id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) if python3: buff.write(struct.pack('<I%sB' % length, length, *_x)) else: buff.write(struct.pack('<I%ss' % length, length, _x)) buff.write(_struct_B.pack(self.status.status)) _x = self.status.text length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) if python3: buff.write(struct.pack('<I%sB' % length, length, *_x)) else: buff.write(struct.pack('<I%ss' % length, length, _x)) _x = self buff.write( _struct_3I.pack(_x.result.transform.header.seq, _x.result.transform.header.stamp.secs, _x.result.transform.header.stamp.nsecs)) _x = self.result.transform.header.frame_id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) if python3: buff.write(struct.pack('<I%sB' % length, length, *_x)) else: buff.write(struct.pack('<I%ss' % length, length, _x)) _x = self.result.transform.child_frame_id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) if python3: buff.write(struct.pack('<I%sB' % length, length, *_x)) else: buff.write(struct.pack('<I%ss' % length, length, _x)) _x = self buff.write( _struct_7dB.pack(_x.result.transform.transform.translation.x, _x.result.transform.transform.translation.y, _x.result.transform.transform.translation.z, _x.result.transform.transform.rotation.x, _x.result.transform.transform.rotation.y, _x.result.transform.transform.rotation.z, _x.result.transform.transform.rotation.w, _x.result.error.error)) _x = self.result.error.error_string length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) if python3: buff.write(struct.pack('<I%sB' % length, length, *_x)) else: buff.write(struct.pack('<I%ss' % length, length, _x)) except struct.error as se: self._check_types( struct.error( "%s: '%s' when writing '%s'" % (type(se), str(se), str(locals().get('_x', self))))) except TypeError as te: self._check_types( ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(locals().get('_x', self)))))
def serialize_numpy(self, buff, numpy): """ serialize message with numpy array types into buffer :param buff: buffer, ``StringIO`` :param numpy: numpy python module """ try: _x = self.object_name length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) if python3: buff.write(struct.pack('<I%sB' % length, length, *_x)) else: buff.write(struct.pack('<I%ss' % length, length, _x)) _x = self buff.write( _struct_B3I.pack(_x.reset_image_counter, _x.pose.header.seq, _x.pose.header.stamp.secs, _x.pose.header.stamp.nsecs)) _x = self.pose.header.frame_id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) if python3: buff.write(struct.pack('<I%sB' % length, length, *_x)) else: buff.write(struct.pack('<I%ss' % length, length, _x)) _x = self buff.write( _struct_7d.pack( _x.pose.pose.position.x, _x.pose.pose.position.y, _x.pose.pose.position.z, _x.pose.pose.orientation.x, _x.pose.pose.orientation.y, _x.pose.pose.orientation.z, _x.pose.pose.orientation.w)) length = len(self.sdh_joints) buff.write(_struct_I.pack(length)) for val1 in self.sdh_joints: _v11 = val1.header buff.write(_struct_I.pack(_v11.seq)) _v12 = _v11.stamp _x = _v12 buff.write(_struct_2I.pack(_x.secs, _x.nsecs)) _x = _v11.frame_id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) if python3: buff.write(struct.pack('<I%sB' % length, length, *_x)) else: buff.write(struct.pack('<I%ss' % length, length, _x)) _v13 = val1.pose _v14 = _v13.position _x = _v14 buff.write(_struct_3d.pack(_x.x, _x.y, _x.z)) _v15 = _v13.orientation _x = _v15 buff.write(_struct_4d.pack(_x.x, _x.y, _x.z, _x.w)) except struct.error as se: self._check_types( struct.error( "%s: '%s' when writing '%s'" % (type(se), str(se), str(locals().get('_x', self))))) except TypeError as te: self._check_types( ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(locals().get('_x', self)))))
def serialize_numpy(self, buff, numpy): """ serialize message with numpy array types into buffer :param buff: buffer, ``StringIO`` :param numpy: numpy python module """ try: length = len(self.groups) buff.write(_struct_I.pack(length)) for val1 in self.groups: _x = val1.name length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss'%length, length, _x)) _x = val1.type length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss'%length, length, _x)) length = len(val1.parameters) buff.write(_struct_I.pack(length)) for val2 in val1.parameters: _x = val2.name length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss'%length, length, _x)) _x = val2.type length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss'%length, length, _x)) buff.write(_get_struct_I().pack(val2.level)) _x = val2.description length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss'%length, length, _x)) _x = val2.edit_method length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss'%length, length, _x)) _x = val1 buff.write(_get_struct_2i().pack(_x.parent, _x.id)) length = len(self.max.bools) buff.write(_struct_I.pack(length)) for val1 in self.max.bools: _x = val1.name length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss'%length, length, _x)) buff.write(_get_struct_B().pack(val1.value)) length = len(self.max.ints) buff.write(_struct_I.pack(length)) for val1 in self.max.ints: _x = val1.name length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss'%length, length, _x)) buff.write(_get_struct_i().pack(val1.value)) length = len(self.max.strs) buff.write(_struct_I.pack(length)) for val1 in self.max.strs: _x = val1.name length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss'%length, length, _x)) _x = val1.value length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss'%length, length, _x)) length = len(self.max.doubles) buff.write(_struct_I.pack(length)) for val1 in self.max.doubles: _x = val1.name length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss'%length, length, _x)) buff.write(_get_struct_d().pack(val1.value)) length = len(self.max.groups) buff.write(_struct_I.pack(length)) for val1 in self.max.groups: _x = val1.name length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss'%length, length, _x)) _x = val1 buff.write(_get_struct_B2i().pack(_x.state, _x.id, _x.parent)) length = len(self.min.bools) buff.write(_struct_I.pack(length)) for val1 in self.min.bools: _x = val1.name length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss'%length, length, _x)) buff.write(_get_struct_B().pack(val1.value)) length = len(self.min.ints) buff.write(_struct_I.pack(length)) for val1 in self.min.ints: _x = val1.name length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss'%length, length, _x)) buff.write(_get_struct_i().pack(val1.value)) length = len(self.min.strs) buff.write(_struct_I.pack(length)) for val1 in self.min.strs: _x = val1.name length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss'%length, length, _x)) _x = val1.value length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss'%length, length, _x)) length = len(self.min.doubles) buff.write(_struct_I.pack(length)) for val1 in self.min.doubles: _x = val1.name length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss'%length, length, _x)) buff.write(_get_struct_d().pack(val1.value)) length = len(self.min.groups) buff.write(_struct_I.pack(length)) for val1 in self.min.groups: _x = val1.name length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss'%length, length, _x)) _x = val1 buff.write(_get_struct_B2i().pack(_x.state, _x.id, _x.parent)) length = len(self.dflt.bools) buff.write(_struct_I.pack(length)) for val1 in self.dflt.bools: _x = val1.name length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss'%length, length, _x)) buff.write(_get_struct_B().pack(val1.value)) length = len(self.dflt.ints) buff.write(_struct_I.pack(length)) for val1 in self.dflt.ints: _x = val1.name length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss'%length, length, _x)) buff.write(_get_struct_i().pack(val1.value)) length = len(self.dflt.strs) buff.write(_struct_I.pack(length)) for val1 in self.dflt.strs: _x = val1.name length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss'%length, length, _x)) _x = val1.value length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss'%length, length, _x)) length = len(self.dflt.doubles) buff.write(_struct_I.pack(length)) for val1 in self.dflt.doubles: _x = val1.name length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss'%length, length, _x)) buff.write(_get_struct_d().pack(val1.value)) length = len(self.dflt.groups) buff.write(_struct_I.pack(length)) for val1 in self.dflt.groups: _x = val1.name length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss'%length, length, _x)) _x = val1 buff.write(_get_struct_B2i().pack(_x.state, _x.id, _x.parent)) except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(locals().get('_x', self))))) except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(locals().get('_x', self)))))
def serialize(self, buff): """ serialize message into buffer :param buff: buffer, ``StringIO`` """ try: _x = self buff.write(_get_struct_3I().pack(_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs)) _x = self.header.frame_id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss' % length, length, _x)) length = len(self.detections) buff.write(_struct_I.pack(length)) for val1 in self.detections: _v1 = val1.header buff.write(_get_struct_I().pack(_v1.seq)) _v2 = _v1.stamp _x = _v2 buff.write(_get_struct_2I().pack(_x.secs, _x.nsecs)) _x = _v1.frame_id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss' % length, length, _x)) length = len(val1.results) buff.write(_struct_I.pack(length)) for val2 in val1.results: _x = val2 buff.write(_get_struct_qd().pack(_x.id, _x.score)) _v3 = val2.pose _v4 = _v3.pose _v5 = _v4.position _x = _v5 buff.write(_get_struct_3d().pack(_x.x, _x.y, _x.z)) _v6 = _v4.orientation _x = _v6 buff.write(_get_struct_4d().pack(_x.x, _x.y, _x.z, _x.w)) buff.write(_get_struct_36d().pack(*_v3.covariance)) _v7 = val1.bbox _v8 = _v7.center _x = _v8 buff.write(_get_struct_3d().pack(_x.x, _x.y, _x.theta)) _x = _v7 buff.write(_get_struct_2d().pack(_x.size_x, _x.size_y)) _v9 = val1.source_img _v10 = _v9.header buff.write(_get_struct_I().pack(_v10.seq)) _v11 = _v10.stamp _x = _v11 buff.write(_get_struct_2I().pack(_x.secs, _x.nsecs)) _x = _v10.frame_id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss' % length, length, _x)) _x = _v9 buff.write(_get_struct_2I().pack(_x.height, _x.width)) _x = _v9.encoding length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss' % length, length, _x)) _x = _v9 buff.write(_get_struct_BI().pack(_x.is_bigendian, _x.step)) _x = _v9.data length = len(_x) # - if encoded as a list instead, serialize as bytes instead of string if type(_x) in [list, tuple]: buff.write(struct.pack('<I%sB' % length, length, *_x)) else: buff.write(struct.pack('<I%ss' % length, length, _x)) except struct.error as se: self._check_types( struct.error( "%s: '%s' when writing '%s'" % (type(se), str(se), str(locals().get('_x', self))))) except TypeError as te: self._check_types( ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(locals().get('_x', self)))))
def serialize_numpy(self, buff, numpy): """ serialize message with numpy array types into buffer :param buff: buffer, ``StringIO`` :param numpy: numpy python module """ try: _x = self buff.write(_get_struct_3I().pack(_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs)) _x = self.header.frame_id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss' % length, length, _x)) _x = self buff.write(_get_struct_3i7d().pack( _x.refId, _x.loopClosureId, _x.proximityDetectionId, _x.loopClosureTransform.translation.x, _x.loopClosureTransform.translation.y, _x.loopClosureTransform.translation.z, _x.loopClosureTransform.rotation.x, _x.loopClosureTransform.rotation.y, _x.loopClosureTransform.rotation.z, _x.loopClosureTransform.rotation.w)) length = len(self.posteriorKeys) buff.write(_struct_I.pack(length)) pattern = '<%si' % length buff.write(self.posteriorKeys.tostring()) length = len(self.posteriorValues) buff.write(_struct_I.pack(length)) pattern = '<%sf' % length buff.write(self.posteriorValues.tostring()) length = len(self.likelihoodKeys) buff.write(_struct_I.pack(length)) pattern = '<%si' % length buff.write(self.likelihoodKeys.tostring()) length = len(self.likelihoodValues) buff.write(_struct_I.pack(length)) pattern = '<%sf' % length buff.write(self.likelihoodValues.tostring()) length = len(self.rawLikelihoodKeys) buff.write(_struct_I.pack(length)) pattern = '<%si' % length buff.write(self.rawLikelihoodKeys.tostring()) length = len(self.rawLikelihoodValues) buff.write(_struct_I.pack(length)) pattern = '<%sf' % length buff.write(self.rawLikelihoodValues.tostring()) length = len(self.weightsKeys) buff.write(_struct_I.pack(length)) pattern = '<%si' % length buff.write(self.weightsKeys.tostring()) length = len(self.weightsValues) buff.write(_struct_I.pack(length)) pattern = '<%si' % length buff.write(self.weightsValues.tostring()) length = len(self.labelsKeys) buff.write(_struct_I.pack(length)) pattern = '<%si' % length buff.write(self.labelsKeys.tostring()) length = len(self.labelsValues) buff.write(_struct_I.pack(length)) for val1 in self.labelsValues: length = len(val1) if python3 or type(val1) == unicode: val1 = val1.encode('utf-8') length = len(val1) buff.write(struct.pack('<I%ss' % length, length, val1)) length = len(self.statsKeys) buff.write(_struct_I.pack(length)) for val1 in self.statsKeys: length = len(val1) if python3 or type(val1) == unicode: val1 = val1.encode('utf-8') length = len(val1) buff.write(struct.pack('<I%ss' % length, length, val1)) length = len(self.statsValues) buff.write(_struct_I.pack(length)) pattern = '<%sf' % length buff.write(self.statsValues.tostring()) length = len(self.localPath) buff.write(_struct_I.pack(length)) pattern = '<%si' % length buff.write(self.localPath.tostring()) buff.write(_get_struct_i().pack(self.currentGoalId)) except struct.error as se: self._check_types( struct.error( "%s: '%s' when writing '%s'" % (type(se), str(se), str(locals().get('_x', self))))) except TypeError as te: self._check_types( ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(locals().get('_x', self)))))
def serialize_numpy(self, buff, numpy): """ serialize message with numpy array types into buffer :param buff: buffer, ``StringIO`` :param numpy: numpy python module """ try: _x = self.label length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss'%length, length, _x)) length = len(self.joint_names) buff.write(_struct_I.pack(length)) for val1 in self.joint_names: length = len(val1) if python3 or type(val1) == unicode: val1 = val1.encode('utf-8') length = len(val1) buff.write(struct.pack('<I%ss'%length, length, val1)) length = len(self.waypoints) buff.write(_struct_I.pack(length)) for val1 in self.waypoints: length = len(val1.joint_positions) buff.write(_struct_I.pack(length)) pattern = '<%sd'%length buff.write(val1.joint_positions.tostring()) _x = val1.active_endpoint length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss'%length, length, _x)) _v15 = val1.pose _v16 = _v15.header buff.write(_get_struct_I().pack(_v16.seq)) _v17 = _v16.stamp _x = _v17 buff.write(_get_struct_2I().pack(_x.secs, _x.nsecs)) _x = _v16.frame_id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss'%length, length, _x)) _v18 = _v15.pose _v19 = _v18.position _x = _v19 buff.write(_get_struct_3d().pack(_x.x, _x.y, _x.z)) _v20 = _v18.orientation _x = _v20 buff.write(_get_struct_4d().pack(_x.x, _x.y, _x.z, _x.w)) _v21 = val1.options _x = _v21.label length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss'%length, length, _x)) buff.write(_get_struct_d().pack(_v21.max_joint_speed_ratio)) length = len(_v21.joint_tolerances) buff.write(_struct_I.pack(length)) pattern = '<%sd'%length buff.write(_v21.joint_tolerances.tostring()) length = len(_v21.max_joint_accel) buff.write(_struct_I.pack(length)) pattern = '<%sd'%length buff.write(_v21.max_joint_accel.tostring()) _x = _v21 buff.write(_get_struct_5d().pack(_x.max_linear_speed, _x.max_linear_accel, _x.max_rotational_speed, _x.max_rotational_accel, _x.corner_distance)) _x = self.trajectory_options.interpolation_type length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss'%length, length, _x)) _x = self buff.write(_get_struct_B3I().pack(_x.trajectory_options.interaction_control, _x.trajectory_options.interaction_params.header.seq, _x.trajectory_options.interaction_params.header.stamp.secs, _x.trajectory_options.interaction_params.header.stamp.nsecs)) _x = self.trajectory_options.interaction_params.header.frame_id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss'%length, length, _x)) buff.write(_get_struct_B().pack(self.trajectory_options.interaction_params.interaction_control_active)) length = len(self.trajectory_options.interaction_params.K_impedance) buff.write(_struct_I.pack(length)) pattern = '<%sd'%length buff.write(self.trajectory_options.interaction_params.K_impedance.tostring()) length = len(self.trajectory_options.interaction_params.max_impedance) buff.write(_struct_I.pack(length)) pattern = '<%sB'%length buff.write(self.trajectory_options.interaction_params.max_impedance.tostring()) length = len(self.trajectory_options.interaction_params.D_impedance) buff.write(_struct_I.pack(length)) pattern = '<%sd'%length buff.write(self.trajectory_options.interaction_params.D_impedance.tostring()) length = len(self.trajectory_options.interaction_params.K_nullspace) buff.write(_struct_I.pack(length)) pattern = '<%sd'%length buff.write(self.trajectory_options.interaction_params.K_nullspace.tostring()) length = len(self.trajectory_options.interaction_params.force_command) buff.write(_struct_I.pack(length)) pattern = '<%sd'%length buff.write(self.trajectory_options.interaction_params.force_command.tostring()) _x = self buff.write(_get_struct_7d().pack(_x.trajectory_options.interaction_params.interaction_frame.position.x, _x.trajectory_options.interaction_params.interaction_frame.position.y, _x.trajectory_options.interaction_params.interaction_frame.position.z, _x.trajectory_options.interaction_params.interaction_frame.orientation.x, _x.trajectory_options.interaction_params.interaction_frame.orientation.y, _x.trajectory_options.interaction_params.interaction_frame.orientation.z, _x.trajectory_options.interaction_params.interaction_frame.orientation.w)) _x = self.trajectory_options.interaction_params.endpoint_name length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss'%length, length, _x)) _x = self buff.write(_get_struct_3B().pack(_x.trajectory_options.interaction_params.in_endpoint_frame, _x.trajectory_options.interaction_params.disable_damping_in_force_control, _x.trajectory_options.interaction_params.disable_reference_resetting)) _x = self.trajectory_options.interaction_params.interaction_control_mode length = len(_x) # - if encoded as a list instead, serialize as bytes instead of string if type(_x) in [list, tuple]: buff.write(struct.pack('<I%sB'%length, length, *_x)) else: buff.write(struct.pack('<I%ss'%length, length, _x)) _x = self buff.write(_get_struct_4BdBdBd().pack(_x.trajectory_options.interaction_params.rotations_for_constrained_zeroG, _x.trajectory_options.nso_start_offset_allowed, _x.trajectory_options.nso_check_end_offset, _x.trajectory_options.tracking_options.use_min_time_rate, _x.trajectory_options.tracking_options.min_time_rate, _x.trajectory_options.tracking_options.use_max_time_rate, _x.trajectory_options.tracking_options.max_time_rate, _x.trajectory_options.tracking_options.use_time_rate_accel, _x.trajectory_options.tracking_options.time_rate_accel)) length = len(self.trajectory_options.tracking_options.goal_joint_tolerance) buff.write(_struct_I.pack(length)) pattern = '<%sd'%length buff.write(self.trajectory_options.tracking_options.goal_joint_tolerance.tostring()) _x = self buff.write(_get_struct_Bd2Id().pack(_x.trajectory_options.tracking_options.use_goal_time_tolerance, _x.trajectory_options.tracking_options.goal_time_tolerance, _x.trajectory_options.end_time.secs, _x.trajectory_options.end_time.nsecs, _x.trajectory_options.path_interpolation_step)) except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(locals().get('_x', self))))) except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(locals().get('_x', self)))))
def serialize_numpy(self, buff, numpy): """ serialize message with numpy array types into buffer :param buff: buffer, ``StringIO`` :param numpy: numpy python module """ try: _x = self buff.write(_get_struct_3I().pack(_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs)) _x = self.header.frame_id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss' % length, length, _x)) length = len(self.detections) buff.write(_struct_I.pack(length)) for val1 in self.detections: _v23 = val1.header buff.write(_get_struct_I().pack(_v23.seq)) _v24 = _v23.stamp _x = _v24 buff.write(_get_struct_2I().pack(_x.secs, _x.nsecs)) _x = _v23.frame_id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss' % length, length, _x)) length = len(val1.results) buff.write(_struct_I.pack(length)) for val2 in val1.results: _x = val2 buff.write(_get_struct_qd().pack(_x.id, _x.score)) _v25 = val2.pose _v26 = _v25.pose _v27 = _v26.position _x = _v27 buff.write(_get_struct_3d().pack(_x.x, _x.y, _x.z)) _v28 = _v26.orientation _x = _v28 buff.write(_get_struct_4d().pack(_x.x, _x.y, _x.z, _x.w)) buff.write(_v25.covariance.tostring()) _v29 = val1.bbox _v30 = _v29.center _x = _v30 buff.write(_get_struct_3d().pack(_x.x, _x.y, _x.theta)) _x = _v29 buff.write(_get_struct_2d().pack(_x.size_x, _x.size_y)) _v31 = val1.source_img _v32 = _v31.header buff.write(_get_struct_I().pack(_v32.seq)) _v33 = _v32.stamp _x = _v33 buff.write(_get_struct_2I().pack(_x.secs, _x.nsecs)) _x = _v32.frame_id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss' % length, length, _x)) _x = _v31 buff.write(_get_struct_2I().pack(_x.height, _x.width)) _x = _v31.encoding length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss' % length, length, _x)) _x = _v31 buff.write(_get_struct_BI().pack(_x.is_bigendian, _x.step)) _x = _v31.data length = len(_x) # - if encoded as a list instead, serialize as bytes instead of string if type(_x) in [list, tuple]: buff.write(struct.pack('<I%sB' % length, length, *_x)) else: buff.write(struct.pack('<I%ss' % length, length, _x)) except struct.error as se: self._check_types( struct.error( "%s: '%s' when writing '%s'" % (type(se), str(se), str(locals().get('_x', self))))) except TypeError as te: self._check_types( ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(locals().get('_x', self)))))
def serialize_numpy(self, buff, numpy): """ serialize message with numpy array types into buffer :param buff: buffer, ``StringIO`` :param numpy: numpy python module """ try: _x = self buff.write(_get_struct_3I().pack( _x.action_goal.header.seq, _x.action_goal.header.stamp.secs, _x.action_goal.header.stamp.nsecs)) _x = self.action_goal.header.frame_id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss' % length, length, _x)) _x = self buff.write(_get_struct_2I().pack( _x.action_goal.goal_id.stamp.secs, _x.action_goal.goal_id.stamp.nsecs)) _x = self.action_goal.goal_id.id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss' % length, length, _x)) length = len(self.action_goal.goal.devices) buff.write(_struct_I.pack(length)) pattern = '<%sI' % length buff.write(self.action_goal.goal.devices.tostring()) _x = self buff.write(_get_struct_B4f2i8f2iB8f4i20fB().pack( _x.action_goal.goal.params.effectType, _x.action_goal.goal.params.fixed_color.color.r, _x.action_goal.goal.params.fixed_color.color.g, _x.action_goal.goal.params.fixed_color.color.b, _x.action_goal.goal.params.fixed_color.color.a, _x.action_goal.goal.params.rainbow.transition_duration.secs, _x.action_goal.goal.params.rainbow.transition_duration.nsecs, _x.action_goal.goal.params.fade.first_color.r, _x.action_goal.goal.params.fade.first_color.g, _x.action_goal.goal.params.fade.first_color.b, _x.action_goal.goal.params.fade.first_color.a, _x.action_goal.goal.params.fade.second_color.r, _x.action_goal.goal.params.fade.second_color.g, _x.action_goal.goal.params.fade.second_color.b, _x.action_goal.goal.params.fade.second_color.a, _x.action_goal.goal.params.fade.transition_duration.secs, _x.action_goal.goal.params.fade.transition_duration.nsecs, _x.action_goal.goal.params.fade.reverse_fade, _x.action_goal.goal.params.blink.first_color.r, _x.action_goal.goal.params.blink.first_color.g, _x.action_goal.goal.params.blink.first_color.b, _x.action_goal.goal.params.blink.first_color.a, _x.action_goal.goal.params.blink.second_color.r, _x.action_goal.goal.params.blink.second_color.g, _x.action_goal.goal.params.blink.second_color.b, _x.action_goal.goal.params.blink.second_color.a, _x.action_goal.goal.params.blink.first_color_duration.secs, _x.action_goal.goal.params.blink.first_color_duration.nsecs, _x.action_goal.goal.params.blink.second_color_duration.secs, _x.action_goal.goal.params.blink.second_color_duration.nsecs, _x.action_goal.goal.params.progress.first_color.r, _x.action_goal.goal.params.progress.first_color.g, _x.action_goal.goal.params.progress.first_color.b, _x.action_goal.goal.params.progress.first_color.a, _x.action_goal.goal.params.progress.second_color.r, _x.action_goal.goal.params.progress.second_color.g, _x.action_goal.goal.params.progress.second_color.b, _x.action_goal.goal.params.progress.second_color.a, _x.action_goal.goal.params.progress.percentage, _x.action_goal.goal.params.progress.led_offset, _x.action_goal.goal.params.flow.first_color.r, _x.action_goal.goal.params.flow.first_color.g, _x.action_goal.goal.params.flow.first_color.b, _x.action_goal.goal.params.flow.first_color.a, _x.action_goal.goal.params.flow.second_color.r, _x.action_goal.goal.params.flow.second_color.g, _x.action_goal.goal.params.flow.second_color.b, _x.action_goal.goal.params.flow.second_color.a, _x.action_goal.goal.params.flow.percentage, _x.action_goal.goal.params.flow.velocity, _x.action_goal.goal.params.preprogrammed.preprogrammed_id)) _x = self.action_goal.goal.params.effect_via_topic.topic_name length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss' % length, length, _x)) length = len(self.action_goal.goal.params.data_array.data) buff.write(_struct_I.pack(length)) for val1 in self.action_goal.goal.params.data_array.data: _x = val1 buff.write(_get_struct_4f().pack(_x.r, _x.g, _x.b, _x.a)) _x = self buff.write(_get_struct_2iB3I().pack( _x.action_goal.goal.effectDuration.secs, _x.action_goal.goal.effectDuration.nsecs, _x.action_goal.goal.priority, _x.action_result.header.seq, _x.action_result.header.stamp.secs, _x.action_result.header.stamp.nsecs)) _x = self.action_result.header.frame_id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss' % length, length, _x)) _x = self buff.write(_get_struct_2I().pack( _x.action_result.status.goal_id.stamp.secs, _x.action_result.status.goal_id.stamp.nsecs)) _x = self.action_result.status.goal_id.id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss' % length, length, _x)) buff.write(_get_struct_B().pack(self.action_result.status.status)) _x = self.action_result.status.text length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss' % length, length, _x)) _x = self buff.write(_get_struct_3I().pack( _x.action_feedback.header.seq, _x.action_feedback.header.stamp.secs, _x.action_feedback.header.stamp.nsecs)) _x = self.action_feedback.header.frame_id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss' % length, length, _x)) _x = self buff.write(_get_struct_2I().pack( _x.action_feedback.status.goal_id.stamp.secs, _x.action_feedback.status.goal_id.stamp.nsecs)) _x = self.action_feedback.status.goal_id.id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss' % length, length, _x)) buff.write(_get_struct_B().pack( self.action_feedback.status.status)) _x = self.action_feedback.status.text length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss' % length, length, _x)) except struct.error as se: self._check_types( struct.error( "%s: '%s' when writing '%s'" % (type(se), str(se), str(locals().get('_x', self))))) except TypeError as te: self._check_types( ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(locals().get('_x', self)))))
def serialize(self, buff): """ serialize message into buffer :param buff: buffer, ``StringIO`` """ try: _x = self buff.write(_struct_3I.pack(_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs)) _x = self.header.frame_id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) if python3: buff.write(struct.pack('<I%sB'%length, length, *_x)) else: buff.write(struct.pack('<I%ss'%length, length, _x)) length = len(self.objects) buff.write(_struct_I.pack(length)) for val1 in self.objects: _v1 = val1.header buff.write(_struct_I.pack(_v1.seq)) _v2 = _v1.stamp _x = _v2 buff.write(_struct_2I.pack(_x.secs, _x.nsecs)) _x = _v1.frame_id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) if python3: buff.write(struct.pack('<I%sB'%length, length, *_x)) else: buff.write(struct.pack('<I%ss'%length, length, _x)) _v3 = val1.type _x = _v3.key length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) if python3: buff.write(struct.pack('<I%sB'%length, length, *_x)) else: buff.write(struct.pack('<I%ss'%length, length, _x)) _x = _v3.db length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) if python3: buff.write(struct.pack('<I%sB'%length, length, *_x)) else: buff.write(struct.pack('<I%ss'%length, length, _x)) buff.write(_struct_f.pack(val1.confidence)) length = len(val1.point_clouds) buff.write(_struct_I.pack(length)) for val2 in val1.point_clouds: _v4 = val2.header buff.write(_struct_I.pack(_v4.seq)) _v5 = _v4.stamp _x = _v5 buff.write(_struct_2I.pack(_x.secs, _x.nsecs)) _x = _v4.frame_id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) if python3: buff.write(struct.pack('<I%sB'%length, length, *_x)) else: buff.write(struct.pack('<I%ss'%length, length, _x)) _x = val2 buff.write(_struct_2I.pack(_x.height, _x.width)) length = len(val2.fields) buff.write(_struct_I.pack(length)) for val3 in val2.fields: _x = val3.name length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) if python3: buff.write(struct.pack('<I%sB'%length, length, *_x)) else: buff.write(struct.pack('<I%ss'%length, length, _x)) _x = val3 buff.write(_struct_IBI.pack(_x.offset, _x.datatype, _x.count)) _x = val2 buff.write(_struct_B2I.pack(_x.is_bigendian, _x.point_step, _x.row_step)) _x = val2.data length = len(_x) # - if encoded as a list instead, serialize as bytes instead of string if type(_x) in [list, tuple]: buff.write(struct.pack('<I%sB'%length, length, *_x)) else: buff.write(struct.pack('<I%ss'%length, length, _x)) buff.write(_struct_B.pack(val2.is_dense)) _v6 = val1.bounding_mesh length = len(_v6.triangles) buff.write(_struct_I.pack(length)) for val3 in _v6.triangles: buff.write(_struct_3I.pack(*val3.vertex_indices)) length = len(_v6.vertices) buff.write(_struct_I.pack(length)) for val3 in _v6.vertices: _x = val3 buff.write(_struct_3d.pack(_x.x, _x.y, _x.z)) length = len(val1.bounding_contours) buff.write(_struct_I.pack(length)) for val2 in val1.bounding_contours: _x = val2 buff.write(_struct_3d.pack(_x.x, _x.y, _x.z)) _v7 = val1.pose _v8 = _v7.header buff.write(_struct_I.pack(_v8.seq)) _v9 = _v8.stamp _x = _v9 buff.write(_struct_2I.pack(_x.secs, _x.nsecs)) _x = _v8.frame_id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) if python3: buff.write(struct.pack('<I%sB'%length, length, *_x)) else: buff.write(struct.pack('<I%ss'%length, length, _x)) _v10 = _v7.pose _v11 = _v10.pose _v12 = _v11.position _x = _v12 buff.write(_struct_3d.pack(_x.x, _x.y, _x.z)) _v13 = _v11.orientation _x = _v13 buff.write(_struct_4d.pack(_x.x, _x.y, _x.z, _x.w)) buff.write(_struct_36d.pack(*_v10.covariance)) length = len(self.cooccurrence) buff.write(_struct_I.pack(length)) pattern = '<%sf'%length buff.write(struct.pack(pattern, *self.cooccurrence)) except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(locals().get('_x', self))))) except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(locals().get('_x', self)))))
def serialize(self, buff): """ serialize message into buffer :param buff: buffer, ``StringIO`` """ try: _x = self buff.write(_struct_3I.pack(_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs)) _x = self.header.frame_id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) if python3: buff.write(struct.pack('<I%sB'%length, length, *_x)) else: buff.write(struct.pack('<I%ss'%length, length, _x)) _x = self buff.write(_struct_3I.pack(_x.sentences.header.seq, _x.sentences.header.stamp.secs, _x.sentences.header.stamp.nsecs)) _x = self.sentences.header.frame_id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) if python3: buff.write(struct.pack('<I%sB'%length, length, *_x)) else: buff.write(struct.pack('<I%ss'%length, length, _x)) buff.write(_struct_f.pack(self.sentences.direction)) length = len(self.sentences.sentences) buff.write(_struct_I.pack(length)) for val1 in self.sentences.sentences: length = len(val1) if python3 or type(val1) == unicode: val1 = val1.encode('utf-8') length = len(val1) if python3: buff.write(struct.pack('<I%sB'%length, length, *val1)) else: buff.write(struct.pack('<I%ss'%length, length, val1)) _x = self.sentences.scores length = len(_x) # - if encoded as a list instead, serialize as bytes instead of string if type(_x) in [list, tuple]: buff.write(struct.pack('<I%sB'%length, length, *_x)) else: buff.write(struct.pack('<I%ss'%length, length, _x)) length = len(self.results) buff.write(_struct_I.pack(length)) for val1 in self.results: _v1 = val1.header buff.write(_struct_I.pack(_v1.seq)) _v2 = _v1.stamp _x = _v2 buff.write(_struct_2I.pack(_x.secs, _x.nsecs)) _x = _v1.frame_id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) if python3: buff.write(struct.pack('<I%sB'%length, length, *_x)) else: buff.write(struct.pack('<I%ss'%length, length, _x)) _x = val1.sentence length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) if python3: buff.write(struct.pack('<I%sB'%length, length, *_x)) else: buff.write(struct.pack('<I%ss'%length, length, _x)) _x = val1.sentence_id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) if python3: buff.write(struct.pack('<I%sB'%length, length, *_x)) else: buff.write(struct.pack('<I%ss'%length, length, _x)) length = len(val1.noun_id) buff.write(_struct_I.pack(length)) for val2 in val1.noun_id: length = len(val2) if python3 or type(val2) == unicode: val2 = val2.encode('utf-8') length = len(val2) if python3: buff.write(struct.pack('<I%sB'%length, length, *val2)) else: buff.write(struct.pack('<I%ss'%length, length, val2)) length = len(val1.noun_str) buff.write(_struct_I.pack(length)) for val2 in val1.noun_str: length = len(val2) if python3 or type(val2) == unicode: val2 = val2.encode('utf-8') length = len(val2) if python3: buff.write(struct.pack('<I%sB'%length, length, *val2)) else: buff.write(struct.pack('<I%ss'%length, length, val2)) buff.write(_struct_f.pack(val1.score)) except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(locals().get('_x', self))))) except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(locals().get('_x', self)))))
def serialize_numpy(self, buff, numpy): """ serialize message with numpy array types into buffer :param buff: buffer, ``StringIO`` :param numpy: numpy python module """ try: length = len(self.intData.layout.dim) buff.write(_struct_I.pack(length)) for val1 in self.intData.layout.dim: _x = val1.label length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) if python3: buff.write(struct.pack('<I%sB'%length, length, *_x)) else: buff.write(struct.pack('<I%ss'%length, length, _x)) _x = val1 buff.write(_struct_2I.pack(_x.size, _x.stride)) buff.write(_struct_I.pack(self.intData.layout.data_offset)) length = len(self.intData.data) buff.write(_struct_I.pack(length)) pattern = '<%si'%length buff.write(self.intData.data.tostring()) length = len(self.floatData.layout.dim) buff.write(_struct_I.pack(length)) for val1 in self.floatData.layout.dim: _x = val1.label length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) if python3: buff.write(struct.pack('<I%sB'%length, length, *_x)) else: buff.write(struct.pack('<I%ss'%length, length, _x)) _x = val1 buff.write(_struct_2I.pack(_x.size, _x.stride)) buff.write(_struct_I.pack(self.floatData.layout.data_offset)) length = len(self.floatData.data) buff.write(_struct_I.pack(length)) pattern = '<%sf'%length buff.write(self.floatData.data.tostring()) _x = self.stringData.data length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) if python3: buff.write(struct.pack('<I%sB'%length, length, *_x)) else: buff.write(struct.pack('<I%ss'%length, length, _x)) _x = self.bufferData.data length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) if python3: buff.write(struct.pack('<I%sB'%length, length, *_x)) else: buff.write(struct.pack('<I%ss'%length, length, _x)) except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(_x)))) except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(_x))))
def serialize_numpy(self, buff, numpy): """ serialize message with numpy array types into buffer :param buff: buffer, ``StringIO`` :param numpy: numpy python module """ try: _x = self buff.write(_get_struct_3I().pack(_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs)) _x = self.header.frame_id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss'%length, length, _x)) _x = self buff.write(_get_struct_2I().pack(_x.status.goal_id.stamp.secs, _x.status.goal_id.stamp.nsecs)) _x = self.status.goal_id.id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss'%length, length, _x)) buff.write(_get_struct_B().pack(self.status.status)) _x = self.status.text length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss'%length, length, _x)) _x = self buff.write(_get_struct_B3I().pack(_x.feedback.state_reached, _x.feedback.fixation_point.header.seq, _x.feedback.fixation_point.header.stamp.secs, _x.feedback.fixation_point.header.stamp.nsecs)) _x = self.feedback.fixation_point.header.frame_id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss'%length, length, _x)) _x = self buff.write(_get_struct_5d3I().pack(_x.feedback.fixation_point.point.x, _x.feedback.fixation_point.point.y, _x.feedback.fixation_point.point.z, _x.feedback.fixation_point_error, _x.feedback.velocity_error, _x.feedback.joint_states.header.seq, _x.feedback.joint_states.header.stamp.secs, _x.feedback.joint_states.header.stamp.nsecs)) _x = self.feedback.joint_states.header.frame_id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss'%length, length, _x)) length = len(self.feedback.joint_states.name) buff.write(_struct_I.pack(length)) for val1 in self.feedback.joint_states.name: length = len(val1) if python3 or type(val1) == unicode: val1 = val1.encode('utf-8') length = len(val1) buff.write(struct.pack('<I%ss'%length, length, val1)) length = len(self.feedback.joint_states.position) buff.write(_struct_I.pack(length)) pattern = '<%sd'%length buff.write(self.feedback.joint_states.position.tostring()) length = len(self.feedback.joint_states.velocity) buff.write(_struct_I.pack(length)) pattern = '<%sd'%length buff.write(self.feedback.joint_states.velocity.tostring()) length = len(self.feedback.joint_states.effort) buff.write(_struct_I.pack(length)) pattern = '<%sd'%length buff.write(self.feedback.joint_states.effort.tostring()) except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(locals().get('_x', self))))) except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(locals().get('_x', self)))))
def serialize_numpy(self, buff, numpy): """ serialize message with numpy array types into buffer :param buff: buffer, ``StringIO`` :param numpy: numpy python module """ try: _x = self buff.write(_get_struct_3I().pack(_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs)) _x = self.header.frame_id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss' % length, length, _x)) _x = self.pano_id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss' % length, length, _x)) _x = self buff.write(_get_struct_3d().pack(_x.latitude, _x.longitude, _x.heading)) _x = self.geo_tag length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss' % length, length, _x)) _x = self buff.write(_get_struct_3I().pack(_x.image.header.seq, _x.image.header.stamp.secs, _x.image.header.stamp.nsecs)) _x = self.image.header.frame_id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss' % length, length, _x)) _x = self buff.write(_get_struct_2I().pack(_x.image.height, _x.image.width)) _x = self.image.encoding length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss' % length, length, _x)) _x = self buff.write(_get_struct_BI().pack(_x.image.is_bigendian, _x.image.step)) _x = self.image.data length = len(_x) # - if encoded as a list instead, serialize as bytes instead of string if type(_x) in [list, tuple]: buff.write(struct.pack('<I%sB' % length, length, *_x)) else: buff.write(struct.pack('<I%ss' % length, length, _x)) except struct.error as se: self._check_types( struct.error( "%s: '%s' when writing '%s'" % (type(se), str(se), str(locals().get('_x', self))))) except TypeError as te: self._check_types( ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(locals().get('_x', self)))))
def serialize_numpy(self, buff, numpy): """ serialize message with numpy array types into buffer :param buff: buffer, ``StringIO`` :param numpy: numpy python module """ try: _x = self buff.write(_get_struct_2f().pack(_x.warehouse_configuration.width, _x.warehouse_configuration.height)) length = len(self.warehouse_configuration.trays) buff.write(_struct_I.pack(length)) for val1 in self.warehouse_configuration.trays: buff.write(_get_struct_I().pack(val1.id)) _x = val1.type length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss'%length, length, _x)) _x = val1 buff.write(_get_struct_4fI().pack(_x.x, _x.y, _x.orientation, _x.max_load, _x.package_type)) length = len(self.warehouse_configuration.walls) buff.write(_struct_I.pack(length)) for val1 in self.warehouse_configuration.walls: _x = val1 buff.write(_get_struct_3f().pack(_x.x, _x.y, _x.orientation)) _x = self buff.write(_get_struct_4f3I().pack(_x.warehouse_configuration.tray_geometry.width, _x.warehouse_configuration.tray_geometry.height, _x.warehouse_configuration.wall_geometry.width, _x.warehouse_configuration.wall_geometry.height, _x.warehouse_configuration.occupancy_map.header.seq, _x.warehouse_configuration.occupancy_map.header.stamp.secs, _x.warehouse_configuration.occupancy_map.header.stamp.nsecs)) _x = self.warehouse_configuration.occupancy_map.header.frame_id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss'%length, length, _x)) _x = self buff.write(_get_struct_2If2I7d().pack(_x.warehouse_configuration.occupancy_map.info.map_load_time.secs, _x.warehouse_configuration.occupancy_map.info.map_load_time.nsecs, _x.warehouse_configuration.occupancy_map.info.resolution, _x.warehouse_configuration.occupancy_map.info.width, _x.warehouse_configuration.occupancy_map.info.height, _x.warehouse_configuration.occupancy_map.info.origin.position.x, _x.warehouse_configuration.occupancy_map.info.origin.position.y, _x.warehouse_configuration.occupancy_map.info.origin.position.z, _x.warehouse_configuration.occupancy_map.info.origin.orientation.x, _x.warehouse_configuration.occupancy_map.info.origin.orientation.y, _x.warehouse_configuration.occupancy_map.info.origin.orientation.z, _x.warehouse_configuration.occupancy_map.info.origin.orientation.w)) length = len(self.warehouse_configuration.occupancy_map.data) buff.write(_struct_I.pack(length)) pattern = '<%sb'%length buff.write(self.warehouse_configuration.occupancy_map.data.tostring()) _x = self buff.write(_get_struct_3f().pack(_x.warehouse_configuration.package_pool.drop_location.x, _x.warehouse_configuration.package_pool.drop_location.y, _x.warehouse_configuration.package_pool.drop_location.z)) for val1 in self.warehouse_configuration.package_pool.stacking_area: _x = val1 buff.write(_get_struct_3f().pack(_x.x, _x.y, _x.z)) length = len(self.warehouse_configuration.robots) buff.write(_struct_I.pack(length)) for val1 in self.warehouse_configuration.robots: _x = val1.id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss'%length, length, _x)) _x = val1.type length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss'%length, length, _x)) length = len(self.warehouse_configuration.idle_positions) buff.write(_struct_I.pack(length)) for val1 in self.warehouse_configuration.idle_positions: _x = val1.id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss'%length, length, _x)) _v3 = val1.pose _x = _v3 buff.write(_get_struct_3d().pack(_x.x, _x.y, _x.theta)) length = len(self.robot_configurations) buff.write(_struct_I.pack(length)) for val1 in self.robot_configurations: _x = val1.type_name length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss'%length, length, _x)) _x = val1 buff.write(_get_struct_7f().pack(_x.charging_rate, _x.discharging_rate, _x.min_linear_vel, _x.max_linear_vel, _x.max_angular_vel, _x.radius, _x.max_load)) length = len(self.package_configurations) buff.write(_struct_I.pack(length)) for val1 in self.package_configurations: _x = val1 buff.write(_get_struct_I3f().pack(_x.id, _x.width, _x.height, _x.weight)) except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(locals().get('_x', self))))) except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(locals().get('_x', self)))))
def serialize(self, buff): """ serialize message into buffer :param buff: buffer, ``StringIO`` """ try: _x = self.masteruri length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss' % length, length, _x)) length = len(self.nodes) buff.write(_struct_I.pack(length)) for val1 in self.nodes: length = len(val1) if python3 or type(val1) == unicode: val1 = val1.encode('utf-8') length = len(val1) buff.write(struct.pack('<I%ss' % length, length, val1)) length = len(self.publisher) buff.write(_struct_I.pack(length)) for val1 in self.publisher: _x = val1.topic length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss' % length, length, _x)) _x = val1.node length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss' % length, length, _x)) _x = val1.nodeuri length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss' % length, length, _x)) length = len(self.subscriber) buff.write(_struct_I.pack(length)) for val1 in self.subscriber: _x = val1.topic length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss' % length, length, _x)) _x = val1.node length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss' % length, length, _x)) _x = val1.nodeuri length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss' % length, length, _x)) length = len(self.services) buff.write(_struct_I.pack(length)) for val1 in self.services: _x = val1.service length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss' % length, length, _x)) _x = val1.serviceuri length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss' % length, length, _x)) _x = val1.node length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss' % length, length, _x)) _x = val1.nodeuri length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss' % length, length, _x)) except struct.error as se: self._check_types( struct.error( "%s: '%s' when writing '%s'" % (type(se), str(se), str(locals().get('_x', self))))) except TypeError as te: self._check_types( ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(locals().get('_x', self)))))
def serialize_numpy(self, buff, numpy): """ serialize message with numpy array types into buffer :param buff: buffer, ``StringIO`` :param numpy: numpy python module """ try: _x = self buff.write(_struct_3I.pack(_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs)) _x = self.header.frame_id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) if python3: buff.write(struct.pack('<I%sB'%length, length, *_x)) else: buff.write(struct.pack('<I%ss'%length, length, _x)) length = len(self.x) buff.write(_struct_I.pack(length)) pattern = '<%si'%length buff.write(self.x.tostring()) length = len(self.y) buff.write(_struct_I.pack(length)) pattern = '<%si'%length buff.write(self.y.tostring()) length = len(self.width) buff.write(_struct_I.pack(length)) pattern = '<%si'%length buff.write(self.width.tostring()) length = len(self.height) buff.write(_struct_I.pack(length)) pattern = '<%si'%length buff.write(self.height.tostring()) length = len(self.image) buff.write(_struct_I.pack(length)) for val1 in self.image: _v5 = val1.header buff.write(_struct_I.pack(_v5.seq)) _v6 = _v5.stamp _x = _v6 buff.write(_struct_2I.pack(_x.secs, _x.nsecs)) _x = _v5.frame_id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) if python3: buff.write(struct.pack('<I%sB'%length, length, *_x)) else: buff.write(struct.pack('<I%ss'%length, length, _x)) _x = val1 buff.write(_struct_2I.pack(_x.height, _x.width)) _x = val1.encoding length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) if python3: buff.write(struct.pack('<I%sB'%length, length, *_x)) else: buff.write(struct.pack('<I%ss'%length, length, _x)) _x = val1 buff.write(_struct_BI.pack(_x.is_bigendian, _x.step)) _x = val1.data length = len(_x) # - if encoded as a list instead, serialize as bytes instead of string if type(_x) in [list, tuple]: buff.write(struct.pack('<I%sB'%length, length, *_x)) else: buff.write(struct.pack('<I%ss'%length, length, _x)) except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(_x)))) except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(_x))))
def serialize(self, buff): """ serialize message into buffer :param buff: buffer, ``StringIO`` """ try: length = len(self.bools) buff.write(_struct_I.pack(length)) for val1 in self.bools: _x = val1.name length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.Struct('<I%ss' % length).pack(length, _x)) _x = val1.value buff.write(_get_struct_B().pack(_x)) length = len(self.ints) buff.write(_struct_I.pack(length)) for val1 in self.ints: _x = val1.name length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.Struct('<I%ss' % length).pack(length, _x)) _x = val1.value buff.write(_get_struct_i().pack(_x)) length = len(self.strs) buff.write(_struct_I.pack(length)) for val1 in self.strs: _x = val1.name length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.Struct('<I%ss' % length).pack(length, _x)) _x = val1.value length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.Struct('<I%ss' % length).pack(length, _x)) length = len(self.doubles) buff.write(_struct_I.pack(length)) for val1 in self.doubles: _x = val1.name length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.Struct('<I%ss' % length).pack(length, _x)) _x = val1.value buff.write(_get_struct_d().pack(_x)) length = len(self.groups) buff.write(_struct_I.pack(length)) for val1 in self.groups: _x = val1.name length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.Struct('<I%ss' % length).pack(length, _x)) _x = val1 buff.write(_get_struct_B2i().pack(_x.state, _x.id, _x.parent)) except struct.error as se: self._check_types( struct.error( "%s: '%s' when writing '%s'" % (type(se), str(se), str(locals().get('_x', self))))) except TypeError as te: self._check_types( ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(locals().get('_x', self)))))
def serialize_numpy(self, buff, numpy): """ serialize message with numpy array types into buffer :param buff: buffer, ``StringIO`` :param numpy: numpy python module """ try: _x = self buff.write(_get_struct_3I().pack(_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs)) _x = self.header.frame_id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss'%length, length, _x)) length = len(self.names) buff.write(_struct_I.pack(length)) for val1 in self.names: length = len(val1) if python3 or type(val1) == unicode: val1 = val1.encode('utf-8') length = len(val1) buff.write(struct.pack('<I%ss'%length, length, val1)) length = len(self.states) buff.write(_struct_I.pack(length)) for val1 in self.states: _v23 = val1.header buff.write(_get_struct_I().pack(_v23.seq)) _v24 = _v23.stamp _x = _v24 buff.write(_get_struct_2I().pack(_x.secs, _x.nsecs)) _x = _v23.frame_id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.pack('<I%ss'%length, length, _x)) _v25 = val1.pose _v26 = _v25.position _x = _v26 buff.write(_get_struct_3d().pack(_x.x, _x.y, _x.z)) _v27 = _v25.orientation _x = _v27 buff.write(_get_struct_4d().pack(_x.x, _x.y, _x.z, _x.w)) _v28 = val1.twist _v29 = _v28.linear _x = _v29 buff.write(_get_struct_3d().pack(_x.x, _x.y, _x.z)) _v30 = _v28.angular _x = _v30 buff.write(_get_struct_3d().pack(_x.x, _x.y, _x.z)) _v31 = val1.wrench _v32 = _v31.force _x = _v32 buff.write(_get_struct_3d().pack(_x.x, _x.y, _x.z)) _v33 = _v31.torque _x = _v33 buff.write(_get_struct_3d().pack(_x.x, _x.y, _x.z)) buff.write(_get_struct_B().pack(val1.valid)) except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(locals().get('_x', self))))) except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(locals().get('_x', self)))))
def test_float__dumps__exception_translation(pack_mock): """:class:`struct.error` must be translated.""" pack_mock.side_effect = struct.error("Some error happened") with pytest.raises(errors.SerializationError): numeric.Float32().to_bytes(1234)
def serialize(self, buff): """ serialize message into buffer :param buff: buffer, ``StringIO`` """ try: _x = self buff.write(_get_struct_3I().pack(_x.action_goal.header.seq, _x.action_goal.header.stamp.secs, _x.action_goal.header.stamp.nsecs)) _x = self.action_goal.header.frame_id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.Struct('<I%ss'%length).pack(length, _x)) _x = self buff.write(_get_struct_2I().pack(_x.action_goal.goal_id.stamp.secs, _x.action_goal.goal_id.stamp.nsecs)) _x = self.action_goal.goal_id.id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.Struct('<I%ss'%length).pack(length, _x)) _x = self.action_goal.goal.request_type buff.write(_get_struct_B().pack(_x)) _x = self.action_goal.goal.msg length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.Struct('<I%ss'%length).pack(length, _x)) _x = self buff.write(_get_struct_3I().pack(_x.action_result.header.seq, _x.action_result.header.stamp.secs, _x.action_result.header.stamp.nsecs)) _x = self.action_result.header.frame_id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.Struct('<I%ss'%length).pack(length, _x)) _x = self buff.write(_get_struct_2I().pack(_x.action_result.status.goal_id.stamp.secs, _x.action_result.status.goal_id.stamp.nsecs)) _x = self.action_result.status.goal_id.id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.Struct('<I%ss'%length).pack(length, _x)) _x = self.action_result.status.status buff.write(_get_struct_B().pack(_x)) _x = self.action_result.status.text length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.Struct('<I%ss'%length).pack(length, _x)) _x = self.action_result.result.result_code buff.write(_get_struct_B().pack(_x)) _x = self.action_result.result.data length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.Struct('<I%ss'%length).pack(length, _x)) _x = self buff.write(_get_struct_3I().pack(_x.action_feedback.header.seq, _x.action_feedback.header.stamp.secs, _x.action_feedback.header.stamp.nsecs)) _x = self.action_feedback.header.frame_id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.Struct('<I%ss'%length).pack(length, _x)) _x = self buff.write(_get_struct_2I().pack(_x.action_feedback.status.goal_id.stamp.secs, _x.action_feedback.status.goal_id.stamp.nsecs)) _x = self.action_feedback.status.goal_id.id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.Struct('<I%ss'%length).pack(length, _x)) _x = self.action_feedback.status.status buff.write(_get_struct_B().pack(_x)) _x = self.action_feedback.status.text length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) buff.write(struct.Struct('<I%ss'%length).pack(length, _x)) except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(locals().get('_x', self))))) except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(locals().get('_x', self)))))
def serialize_numpy(self, buff, numpy): """ serialize message with numpy array types into buffer :param buff: buffer, ``StringIO`` :param numpy: numpy python module """ try: _x = self buff.write( _struct_3I.pack(_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs)) _x = self.header.frame_id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) if python3: buff.write(struct.pack('<I%sB' % length, length, *_x)) else: buff.write(struct.pack('<I%ss' % length, length, _x)) _x = self buff.write( _struct_2I.pack(_x.goal_id.stamp.secs, _x.goal_id.stamp.nsecs)) _x = self.goal_id.id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) if python3: buff.write(struct.pack('<I%sB' % length, length, *_x)) else: buff.write(struct.pack('<I%ss' % length, length, _x)) _x = self buff.write( _struct_B3I.pack(_x.goal.use_start_pose, _x.goal.start_pose.header.seq, _x.goal.start_pose.header.stamp.secs, _x.goal.start_pose.header.stamp.nsecs)) _x = self.goal.start_pose.header.frame_id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) if python3: buff.write(struct.pack('<I%sB' % length, length, *_x)) else: buff.write(struct.pack('<I%ss' % length, length, _x)) _x = self buff.write( _struct_7d3I.pack(_x.goal.start_pose.pose.position.x, _x.goal.start_pose.pose.position.y, _x.goal.start_pose.pose.position.z, _x.goal.start_pose.pose.orientation.x, _x.goal.start_pose.pose.orientation.y, _x.goal.start_pose.pose.orientation.z, _x.goal.start_pose.pose.orientation.w, _x.goal.target_pose.header.seq, _x.goal.target_pose.header.stamp.secs, _x.goal.target_pose.header.stamp.nsecs)) _x = self.goal.target_pose.header.frame_id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) if python3: buff.write(struct.pack('<I%sB' % length, length, *_x)) else: buff.write(struct.pack('<I%ss' % length, length, _x)) _x = self buff.write( _struct_8d.pack(_x.goal.target_pose.pose.position.x, _x.goal.target_pose.pose.position.y, _x.goal.target_pose.pose.position.z, _x.goal.target_pose.pose.orientation.x, _x.goal.target_pose.pose.orientation.y, _x.goal.target_pose.pose.orientation.z, _x.goal.target_pose.pose.orientation.w, _x.goal.tolerance)) _x = self.goal.planner length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) if python3: buff.write(struct.pack('<I%sB' % length, length, *_x)) else: buff.write(struct.pack('<I%ss' % length, length, _x)) except struct.error as se: self._check_types( struct.error( "%s: '%s' when writing '%s'" % (type(se), str(se), str(locals().get('_x', self))))) except TypeError as te: self._check_types( ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(locals().get('_x', self)))))
def serialize_numpy(self, buff, numpy): """ serialize message with numpy array types into buffer :param buff: buffer, ``StringIO`` :param numpy: numpy python module """ try: _x = self buff.write(_struct_3I.pack(_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs)) _x = self.header.frame_id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) if python3: buff.write(struct.pack('<I%sB'%length, length, *_x)) else: buff.write(struct.pack('<I%ss'%length, length, _x)) length = len(self.objects) buff.write(_struct_I.pack(length)) for val1 in self.objects: _v27 = val1.header buff.write(_struct_I.pack(_v27.seq)) _v28 = _v27.stamp _x = _v28 buff.write(_struct_2I.pack(_x.secs, _x.nsecs)) _x = _v27.frame_id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) if python3: buff.write(struct.pack('<I%sB'%length, length, *_x)) else: buff.write(struct.pack('<I%ss'%length, length, _x)) _v29 = val1.type _x = _v29.key length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) if python3: buff.write(struct.pack('<I%sB'%length, length, *_x)) else: buff.write(struct.pack('<I%ss'%length, length, _x)) _x = _v29.db length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) if python3: buff.write(struct.pack('<I%sB'%length, length, *_x)) else: buff.write(struct.pack('<I%ss'%length, length, _x)) buff.write(_struct_f.pack(val1.confidence)) length = len(val1.point_clouds) buff.write(_struct_I.pack(length)) for val2 in val1.point_clouds: _v30 = val2.header buff.write(_struct_I.pack(_v30.seq)) _v31 = _v30.stamp _x = _v31 buff.write(_struct_2I.pack(_x.secs, _x.nsecs)) _x = _v30.frame_id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) if python3: buff.write(struct.pack('<I%sB'%length, length, *_x)) else: buff.write(struct.pack('<I%ss'%length, length, _x)) _x = val2 buff.write(_struct_2I.pack(_x.height, _x.width)) length = len(val2.fields) buff.write(_struct_I.pack(length)) for val3 in val2.fields: _x = val3.name length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) if python3: buff.write(struct.pack('<I%sB'%length, length, *_x)) else: buff.write(struct.pack('<I%ss'%length, length, _x)) _x = val3 buff.write(_struct_IBI.pack(_x.offset, _x.datatype, _x.count)) _x = val2 buff.write(_struct_B2I.pack(_x.is_bigendian, _x.point_step, _x.row_step)) _x = val2.data length = len(_x) # - if encoded as a list instead, serialize as bytes instead of string if type(_x) in [list, tuple]: buff.write(struct.pack('<I%sB'%length, length, *_x)) else: buff.write(struct.pack('<I%ss'%length, length, _x)) buff.write(_struct_B.pack(val2.is_dense)) _v32 = val1.bounding_mesh length = len(_v32.triangles) buff.write(_struct_I.pack(length)) for val3 in _v32.triangles: buff.write(val3.vertex_indices.tostring()) length = len(_v32.vertices) buff.write(_struct_I.pack(length)) for val3 in _v32.vertices: _x = val3 buff.write(_struct_3d.pack(_x.x, _x.y, _x.z)) length = len(val1.bounding_contours) buff.write(_struct_I.pack(length)) for val2 in val1.bounding_contours: _x = val2 buff.write(_struct_3d.pack(_x.x, _x.y, _x.z)) _v33 = val1.pose _v34 = _v33.header buff.write(_struct_I.pack(_v34.seq)) _v35 = _v34.stamp _x = _v35 buff.write(_struct_2I.pack(_x.secs, _x.nsecs)) _x = _v34.frame_id length = len(_x) if python3 or type(_x) == unicode: _x = _x.encode('utf-8') length = len(_x) if python3: buff.write(struct.pack('<I%sB'%length, length, *_x)) else: buff.write(struct.pack('<I%ss'%length, length, _x)) _v36 = _v33.pose _v37 = _v36.pose _v38 = _v37.position _x = _v38 buff.write(_struct_3d.pack(_x.x, _x.y, _x.z)) _v39 = _v37.orientation _x = _v39 buff.write(_struct_4d.pack(_x.x, _x.y, _x.z, _x.w)) buff.write(_v36.covariance.tostring()) length = len(self.cooccurrence) buff.write(_struct_I.pack(length)) pattern = '<%sf'%length buff.write(self.cooccurrence.tostring()) except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(locals().get('_x', self))))) except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(locals().get('_x', self)))))