_command.py
Go to the documentation of this file.
00001 """autogenerated by genpy from sr_robot_msgs/command.msg. Do not edit."""
00002 import sys
00003 python3 = True if sys.hexversion > 0x03000000 else False
00004 import genpy
00005 import struct
00006 
00007 import sr_robot_msgs.msg
00008 
00009 class command(genpy.Message):
00010   _md5sum = "2c927cc3decc25060b43219a05beb823"
00011   _type = "sr_robot_msgs/command"
00012   _has_header = False #flag to mark the presence of a Header object
00013   _full_text = """# sendupdate is 1
00014 # contrlr is 2
00015 int8 command_type
00016 
00017 sendupdate sendupdate_command
00018 contrlr contrlr_command
00019 
00020 ================================================================================
00021 MSG: sr_robot_msgs/sendupdate
00022 int8 sendupdate_length
00023 joint[] sendupdate_list
00024 
00025 
00026 ================================================================================
00027 MSG: sr_robot_msgs/joint
00028 string  joint_name
00029 float64 joint_position
00030 float64 joint_target
00031 float64 joint_torque
00032 float64 joint_temperature
00033 float64 joint_current
00034 string  error_flag
00035 
00036 ================================================================================
00037 MSG: sr_robot_msgs/contrlr
00038 # the contrlr name (e.g. smart_motor_ff2)
00039 string   contrlr_name
00040 
00041 # specify here a list of parameter_name:value
00042 # e.g. p:10 sets the p value of the controller to 10
00043 # the possible parameters are:
00044 #int16  p
00045 #int16  i
00046 #int16  d
00047 #int16  imax
00048 #int16  target
00049 #int16  sensor
00050 #int16  valve 
00051 #int16  deadband
00052 #int16  offset
00053 #int16  shift
00054 #int16  max
00055 #
00056 ## parameters for the motors
00057 #int16  motor_maxforce
00058 #int16  motor_safeforce
00059 #int16  force_p
00060 #int16  force_i
00061 #int16  force_d
00062 #int16  force_imax
00063 #int16  force_out_shift
00064 #int16  force_deadband
00065 #int16  force_offset
00066 #int16  sensor_imax
00067 #int16  sensor_deadband
00068 #int16  sensor_offset
00069 #int16  max_temperature
00070 #int16  max_current
00071 
00072 string[] list_of_parameters
00073 
00074 # the size of the list_of_parameters you are sending
00075 uint8    length_of_list
00076 
00077 
00078 
00079 """
00080   __slots__ = ['command_type','sendupdate_command','contrlr_command']
00081   _slot_types = ['int8','sr_robot_msgs/sendupdate','sr_robot_msgs/contrlr']
00082 
00083   def __init__(self, *args, **kwds):
00084     """
00085     Constructor. Any message fields that are implicitly/explicitly
00086     set to None will be assigned a default value. The recommend
00087     use is keyword arguments as this is more robust to future message
00088     changes.  You cannot mix in-order arguments and keyword arguments.
00089 
00090     The available fields are:
00091        command_type,sendupdate_command,contrlr_command
00092 
00093     :param args: complete set of field values, in .msg order
00094     :param kwds: use keyword arguments corresponding to message field names
00095     to set specific fields.
00096     """
00097     if args or kwds:
00098       super(command, self).__init__(*args, **kwds)
00099       #message fields cannot be None, assign default values for those that are
00100       if self.command_type is None:
00101         self.command_type = 0
00102       if self.sendupdate_command is None:
00103         self.sendupdate_command = sr_robot_msgs.msg.sendupdate()
00104       if self.contrlr_command is None:
00105         self.contrlr_command = sr_robot_msgs.msg.contrlr()
00106     else:
00107       self.command_type = 0
00108       self.sendupdate_command = sr_robot_msgs.msg.sendupdate()
00109       self.contrlr_command = sr_robot_msgs.msg.contrlr()
00110 
00111   def _get_types(self):
00112     """
00113     internal API method
00114     """
00115     return self._slot_types
00116 
00117   def serialize(self, buff):
00118     """
00119     serialize message into buffer
00120     :param buff: buffer, ``StringIO``
00121     """
00122     try:
00123       _x = self
00124       buff.write(_struct_2b.pack(_x.command_type, _x.sendupdate_command.sendupdate_length))
00125       length = len(self.sendupdate_command.sendupdate_list)
00126       buff.write(_struct_I.pack(length))
00127       for val1 in self.sendupdate_command.sendupdate_list:
00128         _x = val1.joint_name
00129         length = len(_x)
00130         if python3 or type(_x) == unicode:
00131           _x = _x.encode('utf-8')
00132           length = len(_x)
00133         buff.write(struct.pack('<I%ss'%length, length, _x))
00134         _x = val1
00135         buff.write(_struct_5d.pack(_x.joint_position, _x.joint_target, _x.joint_torque, _x.joint_temperature, _x.joint_current))
00136         _x = val1.error_flag
00137         length = len(_x)
00138         if python3 or type(_x) == unicode:
00139           _x = _x.encode('utf-8')
00140           length = len(_x)
00141         buff.write(struct.pack('<I%ss'%length, length, _x))
00142       _x = self.contrlr_command.contrlr_name
00143       length = len(_x)
00144       if python3 or type(_x) == unicode:
00145         _x = _x.encode('utf-8')
00146         length = len(_x)
00147       buff.write(struct.pack('<I%ss'%length, length, _x))
00148       length = len(self.contrlr_command.list_of_parameters)
00149       buff.write(_struct_I.pack(length))
00150       for val1 in self.contrlr_command.list_of_parameters:
00151         length = len(val1)
00152         if python3 or type(val1) == unicode:
00153           val1 = val1.encode('utf-8')
00154           length = len(val1)
00155         buff.write(struct.pack('<I%ss'%length, length, val1))
00156       buff.write(_struct_B.pack(self.contrlr_command.length_of_list))
00157     except struct.error as se: self._check_types(se)
00158     except TypeError as te: self._check_types(te)
00159 
00160   def deserialize(self, str):
00161     """
00162     unpack serialized message in str into this message instance
00163     :param str: byte array of serialized message, ``str``
00164     """
00165     try:
00166       if self.sendupdate_command is None:
00167         self.sendupdate_command = sr_robot_msgs.msg.sendupdate()
00168       if self.contrlr_command is None:
00169         self.contrlr_command = sr_robot_msgs.msg.contrlr()
00170       end = 0
00171       _x = self
00172       start = end
00173       end += 2
00174       (_x.command_type, _x.sendupdate_command.sendupdate_length,) = _struct_2b.unpack(str[start:end])
00175       start = end
00176       end += 4
00177       (length,) = _struct_I.unpack(str[start:end])
00178       self.sendupdate_command.sendupdate_list = []
00179       for i in range(0, length):
00180         val1 = sr_robot_msgs.msg.joint()
00181         start = end
00182         end += 4
00183         (length,) = _struct_I.unpack(str[start:end])
00184         start = end
00185         end += length
00186         if python3:
00187           val1.joint_name = str[start:end].decode('utf-8')
00188         else:
00189           val1.joint_name = str[start:end]
00190         _x = val1
00191         start = end
00192         end += 40
00193         (_x.joint_position, _x.joint_target, _x.joint_torque, _x.joint_temperature, _x.joint_current,) = _struct_5d.unpack(str[start:end])
00194         start = end
00195         end += 4
00196         (length,) = _struct_I.unpack(str[start:end])
00197         start = end
00198         end += length
00199         if python3:
00200           val1.error_flag = str[start:end].decode('utf-8')
00201         else:
00202           val1.error_flag = str[start:end]
00203         self.sendupdate_command.sendupdate_list.append(val1)
00204       start = end
00205       end += 4
00206       (length,) = _struct_I.unpack(str[start:end])
00207       start = end
00208       end += length
00209       if python3:
00210         self.contrlr_command.contrlr_name = str[start:end].decode('utf-8')
00211       else:
00212         self.contrlr_command.contrlr_name = str[start:end]
00213       start = end
00214       end += 4
00215       (length,) = _struct_I.unpack(str[start:end])
00216       self.contrlr_command.list_of_parameters = []
00217       for i in range(0, length):
00218         start = end
00219         end += 4
00220         (length,) = _struct_I.unpack(str[start:end])
00221         start = end
00222         end += length
00223         if python3:
00224           val1 = str[start:end].decode('utf-8')
00225         else:
00226           val1 = str[start:end]
00227         self.contrlr_command.list_of_parameters.append(val1)
00228       start = end
00229       end += 1
00230       (self.contrlr_command.length_of_list,) = _struct_B.unpack(str[start:end])
00231       return self
00232     except struct.error as e:
00233       raise genpy.DeserializationError(e) #most likely buffer underfill
00234 
00235 
00236   def serialize_numpy(self, buff, numpy):
00237     """
00238     serialize message with numpy array types into buffer
00239     :param buff: buffer, ``StringIO``
00240     :param numpy: numpy python module
00241     """
00242     try:
00243       _x = self
00244       buff.write(_struct_2b.pack(_x.command_type, _x.sendupdate_command.sendupdate_length))
00245       length = len(self.sendupdate_command.sendupdate_list)
00246       buff.write(_struct_I.pack(length))
00247       for val1 in self.sendupdate_command.sendupdate_list:
00248         _x = val1.joint_name
00249         length = len(_x)
00250         if python3 or type(_x) == unicode:
00251           _x = _x.encode('utf-8')
00252           length = len(_x)
00253         buff.write(struct.pack('<I%ss'%length, length, _x))
00254         _x = val1
00255         buff.write(_struct_5d.pack(_x.joint_position, _x.joint_target, _x.joint_torque, _x.joint_temperature, _x.joint_current))
00256         _x = val1.error_flag
00257         length = len(_x)
00258         if python3 or type(_x) == unicode:
00259           _x = _x.encode('utf-8')
00260           length = len(_x)
00261         buff.write(struct.pack('<I%ss'%length, length, _x))
00262       _x = self.contrlr_command.contrlr_name
00263       length = len(_x)
00264       if python3 or type(_x) == unicode:
00265         _x = _x.encode('utf-8')
00266         length = len(_x)
00267       buff.write(struct.pack('<I%ss'%length, length, _x))
00268       length = len(self.contrlr_command.list_of_parameters)
00269       buff.write(_struct_I.pack(length))
00270       for val1 in self.contrlr_command.list_of_parameters:
00271         length = len(val1)
00272         if python3 or type(val1) == unicode:
00273           val1 = val1.encode('utf-8')
00274           length = len(val1)
00275         buff.write(struct.pack('<I%ss'%length, length, val1))
00276       buff.write(_struct_B.pack(self.contrlr_command.length_of_list))
00277     except struct.error as se: self._check_types(se)
00278     except TypeError as te: self._check_types(te)
00279 
00280   def deserialize_numpy(self, str, numpy):
00281     """
00282     unpack serialized message in str into this message instance using numpy for array types
00283     :param str: byte array of serialized message, ``str``
00284     :param numpy: numpy python module
00285     """
00286     try:
00287       if self.sendupdate_command is None:
00288         self.sendupdate_command = sr_robot_msgs.msg.sendupdate()
00289       if self.contrlr_command is None:
00290         self.contrlr_command = sr_robot_msgs.msg.contrlr()
00291       end = 0
00292       _x = self
00293       start = end
00294       end += 2
00295       (_x.command_type, _x.sendupdate_command.sendupdate_length,) = _struct_2b.unpack(str[start:end])
00296       start = end
00297       end += 4
00298       (length,) = _struct_I.unpack(str[start:end])
00299       self.sendupdate_command.sendupdate_list = []
00300       for i in range(0, length):
00301         val1 = sr_robot_msgs.msg.joint()
00302         start = end
00303         end += 4
00304         (length,) = _struct_I.unpack(str[start:end])
00305         start = end
00306         end += length
00307         if python3:
00308           val1.joint_name = str[start:end].decode('utf-8')
00309         else:
00310           val1.joint_name = str[start:end]
00311         _x = val1
00312         start = end
00313         end += 40
00314         (_x.joint_position, _x.joint_target, _x.joint_torque, _x.joint_temperature, _x.joint_current,) = _struct_5d.unpack(str[start:end])
00315         start = end
00316         end += 4
00317         (length,) = _struct_I.unpack(str[start:end])
00318         start = end
00319         end += length
00320         if python3:
00321           val1.error_flag = str[start:end].decode('utf-8')
00322         else:
00323           val1.error_flag = str[start:end]
00324         self.sendupdate_command.sendupdate_list.append(val1)
00325       start = end
00326       end += 4
00327       (length,) = _struct_I.unpack(str[start:end])
00328       start = end
00329       end += length
00330       if python3:
00331         self.contrlr_command.contrlr_name = str[start:end].decode('utf-8')
00332       else:
00333         self.contrlr_command.contrlr_name = str[start:end]
00334       start = end
00335       end += 4
00336       (length,) = _struct_I.unpack(str[start:end])
00337       self.contrlr_command.list_of_parameters = []
00338       for i in range(0, length):
00339         start = end
00340         end += 4
00341         (length,) = _struct_I.unpack(str[start:end])
00342         start = end
00343         end += length
00344         if python3:
00345           val1 = str[start:end].decode('utf-8')
00346         else:
00347           val1 = str[start:end]
00348         self.contrlr_command.list_of_parameters.append(val1)
00349       start = end
00350       end += 1
00351       (self.contrlr_command.length_of_list,) = _struct_B.unpack(str[start:end])
00352       return self
00353     except struct.error as e:
00354       raise genpy.DeserializationError(e) #most likely buffer underfill
00355 
00356 _struct_I = genpy.struct_I
00357 _struct_5d = struct.Struct("<5d")
00358 _struct_B = struct.Struct("<B")
00359 _struct_2b = struct.Struct("<2b")


sr_robot_msgs
Author(s): Ugo Cupcic/ugo@shadowrobot.com
autogenerated on Fri Jan 3 2014 12:01:40