serialization.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 
00003 import struct
00004 import rospy
00005 
00006 def pack_bool(value):
00007     return struct.pack('<?', value)
00008 
00009 def pack_char(value):
00010     return struct.pack('<c', value)
00011 
00012 def pack_int8(value):
00013     return struct.pack('<b', value)
00014 
00015 def pack_int16(value):
00016     return struct.pack('<h', value)
00017 
00018 def pack_int32(value):
00019     return struct.pack('<i', value)
00020 
00021 def pack_int64(value):
00022     return struct.pack('<q', value)
00023 
00024 def pack_uint8(value):
00025     return struct.pack('<B', value)
00026 
00027 def pack_uint16(value):
00028     return struct.pack('<H', value)
00029 
00030 def pack_uint32(value):
00031     return struct.pack('<I', value)
00032 
00033 def pack_uint64(value):
00034     return struct.pack('<Q', value)
00035 
00036 def pack_float(value):
00037     return struct.pack('<f', value)
00038 
00039 def pack_double(value):
00040     return struct.pack('<d', value)
00041 
00042 def pack_string(value):
00043     return pack_uint64(len(value)) + value
00044 
00045 
00046 
00047 def unpack(fmt, size, bytestream, offset = 0):
00048     return struct.unpack_from(fmt, bytestream, offset)[0], offset + size
00049 
00050 def unpack_bool(bytestream, offset = 0):
00051     return unpack('<?', 4, bytestream, offset)
00052 
00053 def unpack_char(bytestream, offset = 0):
00054     return unpack('<c', 1, bytestream, offset)
00055 
00056 def unpack_int8(bytestream, offset = 0):
00057     return unpack('<b', 1, bytestream, offset)
00058 
00059 def unpack_int16(bytestream, offset = 0):
00060     return unpack('<h', 2, bytestream, offset)
00061 
00062 def unpack_int32(bytestream, offset = 0):
00063     return unpack('<i', 4, bytestream, offset)
00064 
00065 def unpack_int64(bytestream, offset = 0):
00066     return unpack('<q', 8, bytestream, offset)
00067 
00068 def unpack_uint8(bytestream, offset = 0):
00069     return unpack('<B', 1, bytestream, offset)
00070 
00071 def unpack_uint16(bytestream, offset = 0):
00072     return unpack('<H', 2, bytestream, offset)
00073 
00074 def unpack_uint32(bytestream, offset = 0):
00075     return unpack('<I', 4, bytestream, offset)
00076 
00077 def unpack_uint64(bytestream, offset = 0):
00078     return unpack('<Q', 8, bytestream, offset)
00079 
00080 def unpack_float(bytestream, offset = 0):
00081     return unpack('<f', 4, bytestream, offset)
00082 
00083 def unpack_double(bytestream, offset = 0):
00084     return unpack('<d', 8, bytestream, offset)
00085 
00086 def unpack_string(bytestream, offset = 0):
00087     size, offset = unpack_uint64(bytestream, offset)
00088     value = "".join(struct.unpack_from('<' + str(size) + 'c', bytestream, offset))
00089     offset += size
00090     return value, offset
00091 


vigir_footstep_planning_msgs
Author(s): Alexander Stumpf
autogenerated on Thu Jun 6 2019 20:43:43