Go to the documentation of this file.00001 """autogenerated by genpy from clearpath_base/JoySwitch.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 JoySwitch(genpy.Message):
00009 _md5sum = "0b9e4d12a122fa671dc7b4bd8741705d"
00010 _type = "clearpath_base/JoySwitch"
00011 _has_header = False
00012 _full_text = """string robot_id
00013 uint8 attach
00014 string joystick
00015
00016 """
00017 __slots__ = ['robot_id','attach','joystick']
00018 _slot_types = ['string','uint8','string']
00019
00020 def __init__(self, *args, **kwds):
00021 """
00022 Constructor. Any message fields that are implicitly/explicitly
00023 set to None will be assigned a default value. The recommend
00024 use is keyword arguments as this is more robust to future message
00025 changes. You cannot mix in-order arguments and keyword arguments.
00026
00027 The available fields are:
00028 robot_id,attach,joystick
00029
00030 :param args: complete set of field values, in .msg order
00031 :param kwds: use keyword arguments corresponding to message field names
00032 to set specific fields.
00033 """
00034 if args or kwds:
00035 super(JoySwitch, self).__init__(*args, **kwds)
00036
00037 if self.robot_id is None:
00038 self.robot_id = ''
00039 if self.attach is None:
00040 self.attach = 0
00041 if self.joystick is None:
00042 self.joystick = ''
00043 else:
00044 self.robot_id = ''
00045 self.attach = 0
00046 self.joystick = ''
00047
00048 def _get_types(self):
00049 """
00050 internal API method
00051 """
00052 return self._slot_types
00053
00054 def serialize(self, buff):
00055 """
00056 serialize message into buffer
00057 :param buff: buffer, ``StringIO``
00058 """
00059 try:
00060 _x = self.robot_id
00061 length = len(_x)
00062 if python3 or type(_x) == unicode:
00063 _x = _x.encode('utf-8')
00064 length = len(_x)
00065 buff.write(struct.pack('<I%ss'%length, length, _x))
00066 buff.write(_struct_B.pack(self.attach))
00067 _x = self.joystick
00068 length = len(_x)
00069 if python3 or type(_x) == unicode:
00070 _x = _x.encode('utf-8')
00071 length = len(_x)
00072 buff.write(struct.pack('<I%ss'%length, length, _x))
00073 except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(_x))))
00074 except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(_x))))
00075
00076 def deserialize(self, str):
00077 """
00078 unpack serialized message in str into this message instance
00079 :param str: byte array of serialized message, ``str``
00080 """
00081 try:
00082 end = 0
00083 start = end
00084 end += 4
00085 (length,) = _struct_I.unpack(str[start:end])
00086 start = end
00087 end += length
00088 if python3:
00089 self.robot_id = str[start:end].decode('utf-8')
00090 else:
00091 self.robot_id = str[start:end]
00092 start = end
00093 end += 1
00094 (self.attach,) = _struct_B.unpack(str[start:end])
00095 start = end
00096 end += 4
00097 (length,) = _struct_I.unpack(str[start:end])
00098 start = end
00099 end += length
00100 if python3:
00101 self.joystick = str[start:end].decode('utf-8')
00102 else:
00103 self.joystick = str[start:end]
00104 return self
00105 except struct.error as e:
00106 raise genpy.DeserializationError(e)
00107
00108
00109 def serialize_numpy(self, buff, numpy):
00110 """
00111 serialize message with numpy array types into buffer
00112 :param buff: buffer, ``StringIO``
00113 :param numpy: numpy python module
00114 """
00115 try:
00116 _x = self.robot_id
00117 length = len(_x)
00118 if python3 or type(_x) == unicode:
00119 _x = _x.encode('utf-8')
00120 length = len(_x)
00121 buff.write(struct.pack('<I%ss'%length, length, _x))
00122 buff.write(_struct_B.pack(self.attach))
00123 _x = self.joystick
00124 length = len(_x)
00125 if python3 or type(_x) == unicode:
00126 _x = _x.encode('utf-8')
00127 length = len(_x)
00128 buff.write(struct.pack('<I%ss'%length, length, _x))
00129 except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(_x))))
00130 except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(_x))))
00131
00132 def deserialize_numpy(self, str, numpy):
00133 """
00134 unpack serialized message in str into this message instance using numpy for array types
00135 :param str: byte array of serialized message, ``str``
00136 :param numpy: numpy python module
00137 """
00138 try:
00139 end = 0
00140 start = end
00141 end += 4
00142 (length,) = _struct_I.unpack(str[start:end])
00143 start = end
00144 end += length
00145 if python3:
00146 self.robot_id = str[start:end].decode('utf-8')
00147 else:
00148 self.robot_id = str[start:end]
00149 start = end
00150 end += 1
00151 (self.attach,) = _struct_B.unpack(str[start:end])
00152 start = end
00153 end += 4
00154 (length,) = _struct_I.unpack(str[start:end])
00155 start = end
00156 end += length
00157 if python3:
00158 self.joystick = str[start:end].decode('utf-8')
00159 else:
00160 self.joystick = str[start:end]
00161 return self
00162 except struct.error as e:
00163 raise genpy.DeserializationError(e)
00164
00165 _struct_I = genpy.struct_I
00166 _struct_B = struct.Struct("<B")