$search
00001 """autogenerated by genmsg_py from Joy.msg. Do not edit.""" 00002 import roslib.message 00003 import struct 00004 00005 import std_msgs.msg 00006 00007 class Joy(roslib.message.Message): 00008 _md5sum = "5a9ea5f83505693b71e785041e67a8bb" 00009 _type = "sensor_msgs/Joy" 00010 _has_header = True #flag to mark the presence of a Header object 00011 _full_text = """# Reports the state of a joysticks axes and buttons. 00012 Header header # timestamp in the header is the time the data is received from the joystick 00013 float32[] axes # the axes measurements from a joystick 00014 int32[] buttons # the buttons measurements from a joystick 00015 00016 ================================================================================ 00017 MSG: std_msgs/Header 00018 # Standard metadata for higher-level stamped data types. 00019 # This is generally used to communicate timestamped data 00020 # in a particular coordinate frame. 00021 # 00022 # sequence ID: consecutively increasing ID 00023 uint32 seq 00024 #Two-integer timestamp that is expressed as: 00025 # * stamp.secs: seconds (stamp_secs) since epoch 00026 # * stamp.nsecs: nanoseconds since stamp_secs 00027 # time-handling sugar is provided by the client library 00028 time stamp 00029 #Frame this data is associated with 00030 # 0: no frame 00031 # 1: global frame 00032 string frame_id 00033 00034 """ 00035 __slots__ = ['header','axes','buttons'] 00036 _slot_types = ['Header','float32[]','int32[]'] 00037 00038 def __init__(self, *args, **kwds): 00039 """ 00040 Constructor. Any message fields that are implicitly/explicitly 00041 set to None will be assigned a default value. The recommend 00042 use is keyword arguments as this is more robust to future message 00043 changes. You cannot mix in-order arguments and keyword arguments. 00044 00045 The available fields are: 00046 header,axes,buttons 00047 00048 @param args: complete set of field values, in .msg order 00049 @param kwds: use keyword arguments corresponding to message field names 00050 to set specific fields. 00051 """ 00052 if args or kwds: 00053 super(Joy, self).__init__(*args, **kwds) 00054 #message fields cannot be None, assign default values for those that are 00055 if self.header is None: 00056 self.header = std_msgs.msg._Header.Header() 00057 if self.axes is None: 00058 self.axes = [] 00059 if self.buttons is None: 00060 self.buttons = [] 00061 else: 00062 self.header = std_msgs.msg._Header.Header() 00063 self.axes = [] 00064 self.buttons = [] 00065 00066 def _get_types(self): 00067 """ 00068 internal API method 00069 """ 00070 return self._slot_types 00071 00072 def serialize(self, buff): 00073 """ 00074 serialize message into buffer 00075 @param buff: buffer 00076 @type buff: StringIO 00077 """ 00078 try: 00079 _x = self 00080 buff.write(_struct_3I.pack(_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs)) 00081 _x = self.header.frame_id 00082 length = len(_x) 00083 buff.write(struct.pack('<I%ss'%length, length, _x)) 00084 length = len(self.axes) 00085 buff.write(_struct_I.pack(length)) 00086 pattern = '<%sf'%length 00087 buff.write(struct.pack(pattern, *self.axes)) 00088 length = len(self.buttons) 00089 buff.write(_struct_I.pack(length)) 00090 pattern = '<%si'%length 00091 buff.write(struct.pack(pattern, *self.buttons)) 00092 except struct.error as se: self._check_types(se) 00093 except TypeError as te: self._check_types(te) 00094 00095 def deserialize(self, str): 00096 """ 00097 unpack serialized message in str into this message instance 00098 @param str: byte array of serialized message 00099 @type str: str 00100 """ 00101 try: 00102 if self.header is None: 00103 self.header = std_msgs.msg._Header.Header() 00104 end = 0 00105 _x = self 00106 start = end 00107 end += 12 00108 (_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs,) = _struct_3I.unpack(str[start:end]) 00109 start = end 00110 end += 4 00111 (length,) = _struct_I.unpack(str[start:end]) 00112 start = end 00113 end += length 00114 self.header.frame_id = str[start:end] 00115 start = end 00116 end += 4 00117 (length,) = _struct_I.unpack(str[start:end]) 00118 pattern = '<%sf'%length 00119 start = end 00120 end += struct.calcsize(pattern) 00121 self.axes = struct.unpack(pattern, str[start:end]) 00122 start = end 00123 end += 4 00124 (length,) = _struct_I.unpack(str[start:end]) 00125 pattern = '<%si'%length 00126 start = end 00127 end += struct.calcsize(pattern) 00128 self.buttons = struct.unpack(pattern, str[start:end]) 00129 return self 00130 except struct.error as e: 00131 raise roslib.message.DeserializationError(e) #most likely buffer underfill 00132 00133 00134 def serialize_numpy(self, buff, numpy): 00135 """ 00136 serialize message with numpy array types into buffer 00137 @param buff: buffer 00138 @type buff: StringIO 00139 @param numpy: numpy python module 00140 @type numpy module 00141 """ 00142 try: 00143 _x = self 00144 buff.write(_struct_3I.pack(_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs)) 00145 _x = self.header.frame_id 00146 length = len(_x) 00147 buff.write(struct.pack('<I%ss'%length, length, _x)) 00148 length = len(self.axes) 00149 buff.write(_struct_I.pack(length)) 00150 pattern = '<%sf'%length 00151 buff.write(self.axes.tostring()) 00152 length = len(self.buttons) 00153 buff.write(_struct_I.pack(length)) 00154 pattern = '<%si'%length 00155 buff.write(self.buttons.tostring()) 00156 except struct.error as se: self._check_types(se) 00157 except TypeError as te: self._check_types(te) 00158 00159 def deserialize_numpy(self, str, numpy): 00160 """ 00161 unpack serialized message in str into this message instance using numpy for array types 00162 @param str: byte array of serialized message 00163 @type str: str 00164 @param numpy: numpy python module 00165 @type numpy: module 00166 """ 00167 try: 00168 if self.header is None: 00169 self.header = std_msgs.msg._Header.Header() 00170 end = 0 00171 _x = self 00172 start = end 00173 end += 12 00174 (_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs,) = _struct_3I.unpack(str[start:end]) 00175 start = end 00176 end += 4 00177 (length,) = _struct_I.unpack(str[start:end]) 00178 start = end 00179 end += length 00180 self.header.frame_id = str[start:end] 00181 start = end 00182 end += 4 00183 (length,) = _struct_I.unpack(str[start:end]) 00184 pattern = '<%sf'%length 00185 start = end 00186 end += struct.calcsize(pattern) 00187 self.axes = numpy.frombuffer(str[start:end], dtype=numpy.float32, count=length) 00188 start = end 00189 end += 4 00190 (length,) = _struct_I.unpack(str[start:end]) 00191 pattern = '<%si'%length 00192 start = end 00193 end += struct.calcsize(pattern) 00194 self.buttons = numpy.frombuffer(str[start:end], dtype=numpy.int32, count=length) 00195 return self 00196 except struct.error as e: 00197 raise roslib.message.DeserializationError(e) #most likely buffer underfill 00198 00199 _struct_I = roslib.message.struct_I 00200 _struct_3I = struct.Struct("<3I")