serialization.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 import struct
4 import rospy
5 
6 def pack_bool(value):
7  return struct.pack('<?', value)
8 
9 def pack_char(value):
10  return struct.pack('<c', value)
11 
12 def pack_int8(value):
13  return struct.pack('<b', value)
14 
15 def pack_int16(value):
16  return struct.pack('<h', value)
17 
18 def pack_int32(value):
19  return struct.pack('<i', value)
20 
21 def pack_int64(value):
22  return struct.pack('<q', value)
23 
24 def pack_uint8(value):
25  return struct.pack('<B', value)
26 
27 def pack_uint16(value):
28  return struct.pack('<H', value)
29 
30 def pack_uint32(value):
31  return struct.pack('<I', value)
32 
33 def pack_uint64(value):
34  return struct.pack('<Q', value)
35 
36 def pack_float(value):
37  return struct.pack('<f', value)
38 
39 def pack_double(value):
40  return struct.pack('<d', value)
41 
42 def pack_string(value):
43  return pack_uint64(len(value)) + value
44 
45 
46 
47 def unpack(fmt, size, bytestream, offset = 0):
48  return struct.unpack_from(fmt, bytestream, offset)[0], offset + size
49 
50 def unpack_bool(bytestream, offset = 0):
51  return unpack('<?', 4, bytestream, offset)
52 
53 def unpack_char(bytestream, offset = 0):
54  return unpack('<c', 1, bytestream, offset)
55 
56 def unpack_int8(bytestream, offset = 0):
57  return unpack('<b', 1, bytestream, offset)
58 
59 def unpack_int16(bytestream, offset = 0):
60  return unpack('<h', 2, bytestream, offset)
61 
62 def unpack_int32(bytestream, offset = 0):
63  return unpack('<i', 4, bytestream, offset)
64 
65 def unpack_int64(bytestream, offset = 0):
66  return unpack('<q', 8, bytestream, offset)
67 
68 def unpack_uint8(bytestream, offset = 0):
69  return unpack('<B', 1, bytestream, offset)
70 
71 def unpack_uint16(bytestream, offset = 0):
72  return unpack('<H', 2, bytestream, offset)
73 
74 def unpack_uint32(bytestream, offset = 0):
75  return unpack('<I', 4, bytestream, offset)
76 
77 def unpack_uint64(bytestream, offset = 0):
78  return unpack('<Q', 8, bytestream, offset)
79 
80 def unpack_float(bytestream, offset = 0):
81  return unpack('<f', 4, bytestream, offset)
82 
83 def unpack_double(bytestream, offset = 0):
84  return unpack('<d', 8, bytestream, offset)
85 
86 def unpack_string(bytestream, offset = 0):
87  size, offset = unpack_uint64(bytestream, offset)
88  value = "".join(struct.unpack_from('<' + str(size) + 'c', bytestream, offset))
89  offset += size
90  return value, offset
91 
def unpack_double(bytestream, offset=0)
def unpack_string(bytestream, offset=0)
def unpack_uint16(bytestream, offset=0)
def unpack(fmt, size, bytestream, offset=0)
def unpack_int32(bytestream, offset=0)
def unpack_int8(bytestream, offset=0)
def unpack_bool(bytestream, offset=0)
def unpack_int16(bytestream, offset=0)
def unpack_uint8(bytestream, offset=0)
def unpack_int64(bytestream, offset=0)
def unpack_float(bytestream, offset=0)
def unpack_uint64(bytestream, offset=0)
def unpack_uint32(bytestream, offset=0)
def unpack_char(bytestream, offset=0)


vigir_footstep_planning_msgs
Author(s): Alexander Stumpf
autogenerated on Mon Jun 10 2019 15:45:25