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