$search
00001 """autogenerated by genmsg_py from LEDControl.msg. Do not edit.""" 00002 import roslib.message 00003 import struct 00004 00005 import wiimote.msg 00006 00007 class LEDControl(roslib.message.Message): 00008 _md5sum = "d0477eee2c164b8a9582a596f92c6f08" 00009 _type = "wiimote/LEDControl" 00010 _has_header = False #flag to mark the presence of a Header object 00011 _full_text = """# Message to request Wiimote LED operations. The Wiimote has four 00012 # LEDs. This message enables its user to turn each individual LED 00013 # on or off, and to define a blink pattern for each LEDs. 00014 # See TimedSwitch.msg for details. 00015 00016 TimedSwitch[] timed_switch_array 00017 00018 ================================================================================ 00019 MSG: wiimote/TimedSwitch 00020 # TimedSwitch allows sender to: 00021 # o turn a switch on, 00022 # o turn a switch off, and 00023 # o repeat an on/off pattern forever or for a 00024 # given number of times. 00025 # Fields (refer to definitions of constants in the definition body): 00026 # o switch_mode: 00027 # ON: turn on (num_cycles and pulse_pattern fields are ignored) 00028 # OFF: turn off (num_cycles and pulse_pattern fields are ignored) 00029 # NO_CHANGE: leave LED in its current state 00030 # REPEAT: repeat an on/off pattern for as long 00031 # as is indicated in the num_cycles field. The 00032 # pattern is defined in the pulse_pattern field. 00033 # 00034 # o num_cycles: 00035 # n>=0: run the pattern that is defined in pulse_pattern 00036 # n times. 00037 # n==FOREVER: run the pattern that is defined in pulse_pattern 00038 # until a new TimedSwitch message is sent. 00039 # 00040 # o pulse_pattern: 00041 # A series of time durations in fractions of a second. The 00042 # first number is the duration for having the switch on. 00043 # The second number is the duration for which the switch 00044 # is off. The third is an 'on' period again, etc. 00045 # A pattern is terminated with the end of the array. 00046 # 00047 # Example: [1,1] specifies an on-off sequence of 1 second. 00048 00049 int8 ON = 1 00050 int8 OFF = 0 00051 int8 NO_CHANGE = -2 00052 int8 REPEAT = -1 00053 int8 FOREVER = -1 00054 00055 int8 switch_mode 00056 int32 num_cycles 00057 float32[] pulse_pattern 00058 00059 """ 00060 __slots__ = ['timed_switch_array'] 00061 _slot_types = ['wiimote/TimedSwitch[]'] 00062 00063 def __init__(self, *args, **kwds): 00064 """ 00065 Constructor. Any message fields that are implicitly/explicitly 00066 set to None will be assigned a default value. The recommend 00067 use is keyword arguments as this is more robust to future message 00068 changes. You cannot mix in-order arguments and keyword arguments. 00069 00070 The available fields are: 00071 timed_switch_array 00072 00073 @param args: complete set of field values, in .msg order 00074 @param kwds: use keyword arguments corresponding to message field names 00075 to set specific fields. 00076 """ 00077 if args or kwds: 00078 super(LEDControl, self).__init__(*args, **kwds) 00079 #message fields cannot be None, assign default values for those that are 00080 if self.timed_switch_array is None: 00081 self.timed_switch_array = [] 00082 else: 00083 self.timed_switch_array = [] 00084 00085 def _get_types(self): 00086 """ 00087 internal API method 00088 """ 00089 return self._slot_types 00090 00091 def serialize(self, buff): 00092 """ 00093 serialize message into buffer 00094 @param buff: buffer 00095 @type buff: StringIO 00096 """ 00097 try: 00098 length = len(self.timed_switch_array) 00099 buff.write(_struct_I.pack(length)) 00100 for val1 in self.timed_switch_array: 00101 _x = val1 00102 buff.write(_struct_bi.pack(_x.switch_mode, _x.num_cycles)) 00103 length = len(val1.pulse_pattern) 00104 buff.write(_struct_I.pack(length)) 00105 pattern = '<%sf'%length 00106 buff.write(struct.pack(pattern, *val1.pulse_pattern)) 00107 except struct.error as se: self._check_types(se) 00108 except TypeError as te: self._check_types(te) 00109 00110 def deserialize(self, str): 00111 """ 00112 unpack serialized message in str into this message instance 00113 @param str: byte array of serialized message 00114 @type str: str 00115 """ 00116 try: 00117 end = 0 00118 start = end 00119 end += 4 00120 (length,) = _struct_I.unpack(str[start:end]) 00121 self.timed_switch_array = [] 00122 for i in range(0, length): 00123 val1 = wiimote.msg.TimedSwitch() 00124 _x = val1 00125 start = end 00126 end += 5 00127 (_x.switch_mode, _x.num_cycles,) = _struct_bi.unpack(str[start:end]) 00128 start = end 00129 end += 4 00130 (length,) = _struct_I.unpack(str[start:end]) 00131 pattern = '<%sf'%length 00132 start = end 00133 end += struct.calcsize(pattern) 00134 val1.pulse_pattern = struct.unpack(pattern, str[start:end]) 00135 self.timed_switch_array.append(val1) 00136 return self 00137 except struct.error as e: 00138 raise roslib.message.DeserializationError(e) #most likely buffer underfill 00139 00140 00141 def serialize_numpy(self, buff, numpy): 00142 """ 00143 serialize message with numpy array types into buffer 00144 @param buff: buffer 00145 @type buff: StringIO 00146 @param numpy: numpy python module 00147 @type numpy module 00148 """ 00149 try: 00150 length = len(self.timed_switch_array) 00151 buff.write(_struct_I.pack(length)) 00152 for val1 in self.timed_switch_array: 00153 _x = val1 00154 buff.write(_struct_bi.pack(_x.switch_mode, _x.num_cycles)) 00155 length = len(val1.pulse_pattern) 00156 buff.write(_struct_I.pack(length)) 00157 pattern = '<%sf'%length 00158 buff.write(val1.pulse_pattern.tostring()) 00159 except struct.error as se: self._check_types(se) 00160 except TypeError as te: self._check_types(te) 00161 00162 def deserialize_numpy(self, str, numpy): 00163 """ 00164 unpack serialized message in str into this message instance using numpy for array types 00165 @param str: byte array of serialized message 00166 @type str: str 00167 @param numpy: numpy python module 00168 @type numpy: module 00169 """ 00170 try: 00171 end = 0 00172 start = end 00173 end += 4 00174 (length,) = _struct_I.unpack(str[start:end]) 00175 self.timed_switch_array = [] 00176 for i in range(0, length): 00177 val1 = wiimote.msg.TimedSwitch() 00178 _x = val1 00179 start = end 00180 end += 5 00181 (_x.switch_mode, _x.num_cycles,) = _struct_bi.unpack(str[start:end]) 00182 start = end 00183 end += 4 00184 (length,) = _struct_I.unpack(str[start:end]) 00185 pattern = '<%sf'%length 00186 start = end 00187 end += struct.calcsize(pattern) 00188 val1.pulse_pattern = numpy.frombuffer(str[start:end], dtype=numpy.float32, count=length) 00189 self.timed_switch_array.append(val1) 00190 return self 00191 except struct.error as e: 00192 raise roslib.message.DeserializationError(e) #most likely buffer underfill 00193 00194 _struct_I = roslib.message.struct_I 00195 _struct_bi = struct.Struct("<bi")