00001 """autogenerated by genmsg_py from PowerState.msg. Do not edit."""
00002 import roslib.message
00003 import struct
00004
00005 import roslib.rostime
00006 import std_msgs.msg
00007
00008 class PowerState(roslib.message.Message):
00009 _md5sum = "e6fa46a387cad0b7a80959a21587a6c9"
00010 _type = "pr2_msgs/PowerState"
00011 _has_header = True
00012 _full_text = """# This message communicates the state of the PR2's power system.
00013 Header header
00014 float64 power_consumption ## Watts
00015 duration time_remaining ## estimated time to empty or full
00016 string prediction_method ## how time_remaining is being calculated
00017 int8 relative_capacity ## percent of capacity
00018 int8 AC_present ## number of packs detecting AC power, > 0 means plugged in
00019
00020 ================================================================================
00021 MSG: std_msgs/Header
00022 # Standard metadata for higher-level stamped data types.
00023 # This is generally used to communicate timestamped data
00024 # in a particular coordinate frame.
00025 #
00026 # sequence ID: consecutively increasing ID
00027 uint32 seq
00028 #Two-integer timestamp that is expressed as:
00029 # * stamp.secs: seconds (stamp_secs) since epoch
00030 # * stamp.nsecs: nanoseconds since stamp_secs
00031 # time-handling sugar is provided by the client library
00032 time stamp
00033 #Frame this data is associated with
00034 # 0: no frame
00035 # 1: global frame
00036 string frame_id
00037
00038 """
00039 __slots__ = ['header','power_consumption','time_remaining','prediction_method','relative_capacity','AC_present']
00040 _slot_types = ['Header','float64','duration','string','int8','int8']
00041
00042 def __init__(self, *args, **kwds):
00043 """
00044 Constructor. Any message fields that are implicitly/explicitly
00045 set to None will be assigned a default value. The recommend
00046 use is keyword arguments as this is more robust to future message
00047 changes. You cannot mix in-order arguments and keyword arguments.
00048
00049 The available fields are:
00050 header,power_consumption,time_remaining,prediction_method,relative_capacity,AC_present
00051
00052 @param args: complete set of field values, in .msg order
00053 @param kwds: use keyword arguments corresponding to message field names
00054 to set specific fields.
00055 """
00056 if args or kwds:
00057 super(PowerState, self).__init__(*args, **kwds)
00058
00059 if self.header is None:
00060 self.header = std_msgs.msg._Header.Header()
00061 if self.power_consumption is None:
00062 self.power_consumption = 0.
00063 if self.time_remaining is None:
00064 self.time_remaining = roslib.rostime.Duration()
00065 if self.prediction_method is None:
00066 self.prediction_method = ''
00067 if self.relative_capacity is None:
00068 self.relative_capacity = 0
00069 if self.AC_present is None:
00070 self.AC_present = 0
00071 else:
00072 self.header = std_msgs.msg._Header.Header()
00073 self.power_consumption = 0.
00074 self.time_remaining = roslib.rostime.Duration()
00075 self.prediction_method = ''
00076 self.relative_capacity = 0
00077 self.AC_present = 0
00078
00079 def _get_types(self):
00080 """
00081 internal API method
00082 """
00083 return self._slot_types
00084
00085 def serialize(self, buff):
00086 """
00087 serialize message into buffer
00088 @param buff: buffer
00089 @type buff: StringIO
00090 """
00091 try:
00092 _x = self
00093 buff.write(_struct_3I.pack(_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs))
00094 _x = self.header.frame_id
00095 length = len(_x)
00096 buff.write(struct.pack('<I%ss'%length, length, _x))
00097 _x = self
00098 buff.write(_struct_d2i.pack(_x.power_consumption, _x.time_remaining.secs, _x.time_remaining.nsecs))
00099 _x = self.prediction_method
00100 length = len(_x)
00101 buff.write(struct.pack('<I%ss'%length, length, _x))
00102 _x = self
00103 buff.write(_struct_2b.pack(_x.relative_capacity, _x.AC_present))
00104 except struct.error, se: self._check_types(se)
00105 except TypeError, te: self._check_types(te)
00106
00107 def deserialize(self, str):
00108 """
00109 unpack serialized message in str into this message instance
00110 @param str: byte array of serialized message
00111 @type str: str
00112 """
00113 try:
00114 if self.header is None:
00115 self.header = std_msgs.msg._Header.Header()
00116 if self.time_remaining is None:
00117 self.time_remaining = roslib.rostime.Duration()
00118 end = 0
00119 _x = self
00120 start = end
00121 end += 12
00122 (_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs,) = _struct_3I.unpack(str[start:end])
00123 start = end
00124 end += 4
00125 (length,) = _struct_I.unpack(str[start:end])
00126 start = end
00127 end += length
00128 self.header.frame_id = str[start:end]
00129 _x = self
00130 start = end
00131 end += 16
00132 (_x.power_consumption, _x.time_remaining.secs, _x.time_remaining.nsecs,) = _struct_d2i.unpack(str[start:end])
00133 start = end
00134 end += 4
00135 (length,) = _struct_I.unpack(str[start:end])
00136 start = end
00137 end += length
00138 self.prediction_method = str[start:end]
00139 _x = self
00140 start = end
00141 end += 2
00142 (_x.relative_capacity, _x.AC_present,) = _struct_2b.unpack(str[start:end])
00143 self.time_remaining.canon()
00144 return self
00145 except struct.error, e:
00146 raise roslib.message.DeserializationError(e)
00147
00148
00149 def serialize_numpy(self, buff, numpy):
00150 """
00151 serialize message with numpy array types into buffer
00152 @param buff: buffer
00153 @type buff: StringIO
00154 @param numpy: numpy python module
00155 @type numpy module
00156 """
00157 try:
00158 _x = self
00159 buff.write(_struct_3I.pack(_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs))
00160 _x = self.header.frame_id
00161 length = len(_x)
00162 buff.write(struct.pack('<I%ss'%length, length, _x))
00163 _x = self
00164 buff.write(_struct_d2i.pack(_x.power_consumption, _x.time_remaining.secs, _x.time_remaining.nsecs))
00165 _x = self.prediction_method
00166 length = len(_x)
00167 buff.write(struct.pack('<I%ss'%length, length, _x))
00168 _x = self
00169 buff.write(_struct_2b.pack(_x.relative_capacity, _x.AC_present))
00170 except struct.error, se: self._check_types(se)
00171 except TypeError, te: self._check_types(te)
00172
00173 def deserialize_numpy(self, str, numpy):
00174 """
00175 unpack serialized message in str into this message instance using numpy for array types
00176 @param str: byte array of serialized message
00177 @type str: str
00178 @param numpy: numpy python module
00179 @type numpy: module
00180 """
00181 try:
00182 if self.header is None:
00183 self.header = std_msgs.msg._Header.Header()
00184 if self.time_remaining is None:
00185 self.time_remaining = roslib.rostime.Duration()
00186 end = 0
00187 _x = self
00188 start = end
00189 end += 12
00190 (_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs,) = _struct_3I.unpack(str[start:end])
00191 start = end
00192 end += 4
00193 (length,) = _struct_I.unpack(str[start:end])
00194 start = end
00195 end += length
00196 self.header.frame_id = str[start:end]
00197 _x = self
00198 start = end
00199 end += 16
00200 (_x.power_consumption, _x.time_remaining.secs, _x.time_remaining.nsecs,) = _struct_d2i.unpack(str[start:end])
00201 start = end
00202 end += 4
00203 (length,) = _struct_I.unpack(str[start:end])
00204 start = end
00205 end += length
00206 self.prediction_method = str[start:end]
00207 _x = self
00208 start = end
00209 end += 2
00210 (_x.relative_capacity, _x.AC_present,) = _struct_2b.unpack(str[start:end])
00211 self.time_remaining.canon()
00212 return self
00213 except struct.error, e:
00214 raise roslib.message.DeserializationError(e)
00215
00216 _struct_I = roslib.message.struct_I
00217 _struct_d2i = struct.Struct("<d2i")
00218 _struct_3I = struct.Struct("<3I")
00219 _struct_2b = struct.Struct("<2b")