00001 """autogenerated by genmsg_py from Joy.msg. Do not edit."""
00002 import roslib.message
00003 import struct
00004
00005
00006 class Joy(roslib.message.Message):
00007 _md5sum = "e3ef016fcdf22397038b36036c66f7c8"
00008 _type = "clearpath_base/Joy"
00009 _has_header = False
00010 _full_text = """float32[] axes
00011 int32[] buttons
00012
00013 """
00014 __slots__ = ['axes','buttons']
00015 _slot_types = ['float32[]','int32[]']
00016
00017 def __init__(self, *args, **kwds):
00018 """
00019 Constructor. Any message fields that are implicitly/explicitly
00020 set to None will be assigned a default value. The recommend
00021 use is keyword arguments as this is more robust to future message
00022 changes. You cannot mix in-order arguments and keyword arguments.
00023
00024 The available fields are:
00025 axes,buttons
00026
00027 @param args: complete set of field values, in .msg order
00028 @param kwds: use keyword arguments corresponding to message field names
00029 to set specific fields.
00030 """
00031 if args or kwds:
00032 super(Joy, self).__init__(*args, **kwds)
00033
00034 if self.axes is None:
00035 self.axes = []
00036 if self.buttons is None:
00037 self.buttons = []
00038 else:
00039 self.axes = []
00040 self.buttons = []
00041
00042 def _get_types(self):
00043 """
00044 internal API method
00045 """
00046 return self._slot_types
00047
00048 def serialize(self, buff):
00049 """
00050 serialize message into buffer
00051 @param buff: buffer
00052 @type buff: StringIO
00053 """
00054 try:
00055 length = len(self.axes)
00056 buff.write(_struct_I.pack(length))
00057 pattern = '<%sf'%length
00058 buff.write(struct.pack(pattern, *self.axes))
00059 length = len(self.buttons)
00060 buff.write(_struct_I.pack(length))
00061 pattern = '<%si'%length
00062 buff.write(struct.pack(pattern, *self.buttons))
00063 except struct.error, se: self._check_types(se)
00064 except TypeError, te: self._check_types(te)
00065
00066 def deserialize(self, str):
00067 """
00068 unpack serialized message in str into this message instance
00069 @param str: byte array of serialized message
00070 @type str: str
00071 """
00072 try:
00073 end = 0
00074 start = end
00075 end += 4
00076 (length,) = _struct_I.unpack(str[start:end])
00077 pattern = '<%sf'%length
00078 start = end
00079 end += struct.calcsize(pattern)
00080 self.axes = struct.unpack(pattern, str[start:end])
00081 start = end
00082 end += 4
00083 (length,) = _struct_I.unpack(str[start:end])
00084 pattern = '<%si'%length
00085 start = end
00086 end += struct.calcsize(pattern)
00087 self.buttons = struct.unpack(pattern, str[start:end])
00088 return self
00089 except struct.error, e:
00090 raise roslib.message.DeserializationError(e)
00091
00092
00093 def serialize_numpy(self, buff, numpy):
00094 """
00095 serialize message with numpy array types into buffer
00096 @param buff: buffer
00097 @type buff: StringIO
00098 @param numpy: numpy python module
00099 @type numpy module
00100 """
00101 try:
00102 length = len(self.axes)
00103 buff.write(_struct_I.pack(length))
00104 pattern = '<%sf'%length
00105 buff.write(self.axes.tostring())
00106 length = len(self.buttons)
00107 buff.write(_struct_I.pack(length))
00108 pattern = '<%si'%length
00109 buff.write(self.buttons.tostring())
00110 except struct.error, se: self._check_types(se)
00111 except TypeError, te: self._check_types(te)
00112
00113 def deserialize_numpy(self, str, numpy):
00114 """
00115 unpack serialized message in str into this message instance using numpy for array types
00116 @param str: byte array of serialized message
00117 @type str: str
00118 @param numpy: numpy python module
00119 @type numpy: module
00120 """
00121 try:
00122 end = 0
00123 start = end
00124 end += 4
00125 (length,) = _struct_I.unpack(str[start:end])
00126 pattern = '<%sf'%length
00127 start = end
00128 end += struct.calcsize(pattern)
00129 self.axes = numpy.frombuffer(str[start:end], dtype=numpy.float32, count=length)
00130 start = end
00131 end += 4
00132 (length,) = _struct_I.unpack(str[start:end])
00133 pattern = '<%si'%length
00134 start = end
00135 end += struct.calcsize(pattern)
00136 self.buttons = numpy.frombuffer(str[start:end], dtype=numpy.int32, count=length)
00137 return self
00138 except struct.error, e:
00139 raise roslib.message.DeserializationError(e)
00140
00141 _struct_I = roslib.message.struct_I