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