_RangeSensor.py
Go to the documentation of this file.
00001 """autogenerated by genpy from corobot_msgs/RangeSensor.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 std_msgs.msg
00008 
00009 class RangeSensor(genpy.Message):
00010   _md5sum = "c9d1786e32e87107225d5ffacf468032"
00011   _type = "corobot_msgs/RangeSensor"
00012   _has_header = True #flag to mark the presence of a Header object
00013   _full_text = """# Message used to transmit range data (infrared, ultrasounds...)
00014 
00015 Header header     # timestamp in the header is the time the distance was read
00016 
00017 # type enums
00018 uint8 ULTRASOUND=0
00019 uint8 INFRARED=1
00020 
00021 # The type of sensor represented by these data. The value can be ULTRASOUND or INFRARED.
00022 int8 type 
00023 
00024 #The number of sensors
00025 int8 numberSensors
00026 
00027 #The data for each sensor. The size of this array is the numberSensors variable.
00028 float32[] range
00029 
00030 ================================================================================
00031 MSG: std_msgs/Header
00032 # Standard metadata for higher-level stamped data types.
00033 # This is generally used to communicate timestamped data 
00034 # in a particular coordinate frame.
00035 # 
00036 # sequence ID: consecutively increasing ID 
00037 uint32 seq
00038 #Two-integer timestamp that is expressed as:
00039 # * stamp.secs: seconds (stamp_secs) since epoch
00040 # * stamp.nsecs: nanoseconds since stamp_secs
00041 # time-handling sugar is provided by the client library
00042 time stamp
00043 #Frame this data is associated with
00044 # 0: no frame
00045 # 1: global frame
00046 string frame_id
00047 
00048 """
00049   # Pseudo-constants
00050   ULTRASOUND = 0
00051   INFRARED = 1
00052 
00053   __slots__ = ['header','type','numberSensors','range']
00054   _slot_types = ['std_msgs/Header','int8','int8','float32[]']
00055 
00056   def __init__(self, *args, **kwds):
00057     """
00058     Constructor. Any message fields that are implicitly/explicitly
00059     set to None will be assigned a default value. The recommend
00060     use is keyword arguments as this is more robust to future message
00061     changes.  You cannot mix in-order arguments and keyword arguments.
00062 
00063     The available fields are:
00064        header,type,numberSensors,range
00065 
00066     :param args: complete set of field values, in .msg order
00067     :param kwds: use keyword arguments corresponding to message field names
00068     to set specific fields.
00069     """
00070     if args or kwds:
00071       super(RangeSensor, self).__init__(*args, **kwds)
00072       #message fields cannot be None, assign default values for those that are
00073       if self.header is None:
00074         self.header = std_msgs.msg.Header()
00075       if self.type is None:
00076         self.type = 0
00077       if self.numberSensors is None:
00078         self.numberSensors = 0
00079       if self.range is None:
00080         self.range = []
00081     else:
00082       self.header = std_msgs.msg.Header()
00083       self.type = 0
00084       self.numberSensors = 0
00085       self.range = []
00086 
00087   def _get_types(self):
00088     """
00089     internal API method
00090     """
00091     return self._slot_types
00092 
00093   def serialize(self, buff):
00094     """
00095     serialize message into buffer
00096     :param buff: buffer, ``StringIO``
00097     """
00098     try:
00099       _x = self
00100       buff.write(_struct_3I.pack(_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs))
00101       _x = self.header.frame_id
00102       length = len(_x)
00103       if python3 or type(_x) == unicode:
00104         _x = _x.encode('utf-8')
00105         length = len(_x)
00106       buff.write(struct.pack('<I%ss'%length, length, _x))
00107       _x = self
00108       buff.write(_struct_2b.pack(_x.type, _x.numberSensors))
00109       length = len(self.range)
00110       buff.write(_struct_I.pack(length))
00111       pattern = '<%sf'%length
00112       buff.write(struct.pack(pattern, *self.range))
00113     except struct.error as se: self._check_types(se)
00114     except TypeError as te: self._check_types(te)
00115 
00116   def deserialize(self, str):
00117     """
00118     unpack serialized message in str into this message instance
00119     :param str: byte array of serialized message, ``str``
00120     """
00121     try:
00122       if self.header is None:
00123         self.header = std_msgs.msg.Header()
00124       end = 0
00125       _x = self
00126       start = end
00127       end += 12
00128       (_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs,) = _struct_3I.unpack(str[start:end])
00129       start = end
00130       end += 4
00131       (length,) = _struct_I.unpack(str[start:end])
00132       start = end
00133       end += length
00134       if python3:
00135         self.header.frame_id = str[start:end].decode('utf-8')
00136       else:
00137         self.header.frame_id = str[start:end]
00138       _x = self
00139       start = end
00140       end += 2
00141       (_x.type, _x.numberSensors,) = _struct_2b.unpack(str[start:end])
00142       start = end
00143       end += 4
00144       (length,) = _struct_I.unpack(str[start:end])
00145       pattern = '<%sf'%length
00146       start = end
00147       end += struct.calcsize(pattern)
00148       self.range = struct.unpack(pattern, str[start:end])
00149       return self
00150     except struct.error as e:
00151       raise genpy.DeserializationError(e) #most likely buffer underfill
00152 
00153 
00154   def serialize_numpy(self, buff, numpy):
00155     """
00156     serialize message with numpy array types into buffer
00157     :param buff: buffer, ``StringIO``
00158     :param numpy: numpy python module
00159     """
00160     try:
00161       _x = self
00162       buff.write(_struct_3I.pack(_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs))
00163       _x = self.header.frame_id
00164       length = len(_x)
00165       if python3 or type(_x) == unicode:
00166         _x = _x.encode('utf-8')
00167         length = len(_x)
00168       buff.write(struct.pack('<I%ss'%length, length, _x))
00169       _x = self
00170       buff.write(_struct_2b.pack(_x.type, _x.numberSensors))
00171       length = len(self.range)
00172       buff.write(_struct_I.pack(length))
00173       pattern = '<%sf'%length
00174       buff.write(self.range.tostring())
00175     except struct.error as se: self._check_types(se)
00176     except TypeError as te: self._check_types(te)
00177 
00178   def deserialize_numpy(self, str, numpy):
00179     """
00180     unpack serialized message in str into this message instance using numpy for array types
00181     :param str: byte array of serialized message, ``str``
00182     :param numpy: numpy python module
00183     """
00184     try:
00185       if self.header is None:
00186         self.header = std_msgs.msg.Header()
00187       end = 0
00188       _x = self
00189       start = end
00190       end += 12
00191       (_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs,) = _struct_3I.unpack(str[start:end])
00192       start = end
00193       end += 4
00194       (length,) = _struct_I.unpack(str[start:end])
00195       start = end
00196       end += length
00197       if python3:
00198         self.header.frame_id = str[start:end].decode('utf-8')
00199       else:
00200         self.header.frame_id = str[start:end]
00201       _x = self
00202       start = end
00203       end += 2
00204       (_x.type, _x.numberSensors,) = _struct_2b.unpack(str[start:end])
00205       start = end
00206       end += 4
00207       (length,) = _struct_I.unpack(str[start:end])
00208       pattern = '<%sf'%length
00209       start = end
00210       end += struct.calcsize(pattern)
00211       self.range = numpy.frombuffer(str[start:end], dtype=numpy.float32, count=length)
00212       return self
00213     except struct.error as e:
00214       raise genpy.DeserializationError(e) #most likely buffer underfill
00215 
00216 _struct_I = genpy.struct_I
00217 _struct_3I = struct.Struct("<3I")
00218 _struct_2b = struct.Struct("<2b")


corobot_msgs
Author(s):
autogenerated on Sun Oct 5 2014 23:17:46