_Joy.py
Go to the documentation of this file.
00001 """autogenerated by genpy from clearpath_base/Joy.msg. Do not edit."""
00002 import sys
00003 python3 = True if sys.hexversion > 0x03000000 else False
00004 import genpy
00005 import struct
00006 
00007 
00008 class Joy(genpy.Message):
00009   _md5sum = "e3ef016fcdf22397038b36036c66f7c8"
00010   _type = "clearpath_base/Joy"
00011   _has_header = False #flag to mark the presence of a Header object
00012   _full_text = """float32[] axes
00013 int32[] buttons
00014 
00015 """
00016   __slots__ = ['axes','buttons']
00017   _slot_types = ['float32[]','int32[]']
00018 
00019   def __init__(self, *args, **kwds):
00020     """
00021     Constructor. Any message fields that are implicitly/explicitly
00022     set to None will be assigned a default value. The recommend
00023     use is keyword arguments as this is more robust to future message
00024     changes.  You cannot mix in-order arguments and keyword arguments.
00025 
00026     The available fields are:
00027        axes,buttons
00028 
00029     :param args: complete set of field values, in .msg order
00030     :param kwds: use keyword arguments corresponding to message field names
00031     to set specific fields.
00032     """
00033     if args or kwds:
00034       super(Joy, self).__init__(*args, **kwds)
00035       #message fields cannot be None, assign default values for those that are
00036       if self.axes is None:
00037         self.axes = []
00038       if self.buttons is None:
00039         self.buttons = []
00040     else:
00041       self.axes = []
00042       self.buttons = []
00043 
00044   def _get_types(self):
00045     """
00046     internal API method
00047     """
00048     return self._slot_types
00049 
00050   def serialize(self, buff):
00051     """
00052     serialize message into buffer
00053     :param buff: buffer, ``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, ``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 as e:
00090       raise genpy.DeserializationError(e) #most likely buffer underfill
00091 
00092 
00093   def serialize_numpy(self, buff, numpy):
00094     """
00095     serialize message with numpy array types into buffer
00096     :param buff: buffer, ``StringIO``
00097     :param numpy: numpy python module
00098     """
00099     try:
00100       length = len(self.axes)
00101       buff.write(_struct_I.pack(length))
00102       pattern = '<%sf'%length
00103       buff.write(self.axes.tostring())
00104       length = len(self.buttons)
00105       buff.write(_struct_I.pack(length))
00106       pattern = '<%si'%length
00107       buff.write(self.buttons.tostring())
00108     except struct.error as se: self._check_types(se)
00109     except TypeError as te: self._check_types(te)
00110 
00111   def deserialize_numpy(self, str, numpy):
00112     """
00113     unpack serialized message in str into this message instance using numpy for array types
00114     :param str: byte array of serialized message, ``str``
00115     :param numpy: numpy python module
00116     """
00117     try:
00118       end = 0
00119       start = end
00120       end += 4
00121       (length,) = _struct_I.unpack(str[start:end])
00122       pattern = '<%sf'%length
00123       start = end
00124       end += struct.calcsize(pattern)
00125       self.axes = numpy.frombuffer(str[start:end], dtype=numpy.float32, count=length)
00126       start = end
00127       end += 4
00128       (length,) = _struct_I.unpack(str[start:end])
00129       pattern = '<%si'%length
00130       start = end
00131       end += struct.calcsize(pattern)
00132       self.buttons = numpy.frombuffer(str[start:end], dtype=numpy.int32, count=length)
00133       return self
00134     except struct.error as e:
00135       raise genpy.DeserializationError(e) #most likely buffer underfill
00136 
00137 _struct_I = genpy.struct_I


clearpath_base
Author(s): Mike Purvis
autogenerated on Sat Dec 28 2013 16:50:47