$search
00001 """autogenerated by genmsg_py from BatteryState2.msg. Do not edit.""" 00002 import roslib.message 00003 import struct 00004 00005 import roslib.rostime 00006 00007 class BatteryState2(roslib.message.Message): 00008 _md5sum = "91b4acb000aa990ac3006834f9a99669" 00009 _type = "pr2_msgs/BatteryState2" 00010 _has_header = False #flag to mark the presence of a Header object 00011 _full_text = """# This message communicates the state of a single battery. 00012 # Battery Controller Flags, one per battery 00013 bool present # is this pack present 00014 bool charging # is this pack charging 00015 bool discharging # is this pack discharging 00016 bool power_present # is there an input voltage 00017 bool power_no_good # is there a fault (No Good) 00018 bool inhibited # is this pack disabled for some reason 00019 # These registers are per battery 00020 time last_battery_update # last time any battery update occurred 00021 int16[48] battery_register # value of this register in the battery 00022 bool[48] battery_update_flag # Has this register ever been updated 00023 time[48] battery_register_update # last time this specific register was updated 00024 00025 """ 00026 __slots__ = ['present','charging','discharging','power_present','power_no_good','inhibited','last_battery_update','battery_register','battery_update_flag','battery_register_update'] 00027 _slot_types = ['bool','bool','bool','bool','bool','bool','time','int16[48]','bool[48]','time[48]'] 00028 00029 def __init__(self, *args, **kwds): 00030 """ 00031 Constructor. Any message fields that are implicitly/explicitly 00032 set to None will be assigned a default value. The recommend 00033 use is keyword arguments as this is more robust to future message 00034 changes. You cannot mix in-order arguments and keyword arguments. 00035 00036 The available fields are: 00037 present,charging,discharging,power_present,power_no_good,inhibited,last_battery_update,battery_register,battery_update_flag,battery_register_update 00038 00039 @param args: complete set of field values, in .msg order 00040 @param kwds: use keyword arguments corresponding to message field names 00041 to set specific fields. 00042 """ 00043 if args or kwds: 00044 super(BatteryState2, self).__init__(*args, **kwds) 00045 #message fields cannot be None, assign default values for those that are 00046 if self.present is None: 00047 self.present = False 00048 if self.charging is None: 00049 self.charging = False 00050 if self.discharging is None: 00051 self.discharging = False 00052 if self.power_present is None: 00053 self.power_present = False 00054 if self.power_no_good is None: 00055 self.power_no_good = False 00056 if self.inhibited is None: 00057 self.inhibited = False 00058 if self.last_battery_update is None: 00059 self.last_battery_update = roslib.rostime.Time() 00060 if self.battery_register is None: 00061 self.battery_register = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] 00062 if self.battery_update_flag is None: 00063 self.battery_update_flag = [False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False] 00064 if self.battery_register_update is None: 00065 self.battery_register_update = [roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time()] 00066 else: 00067 self.present = False 00068 self.charging = False 00069 self.discharging = False 00070 self.power_present = False 00071 self.power_no_good = False 00072 self.inhibited = False 00073 self.last_battery_update = roslib.rostime.Time() 00074 self.battery_register = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] 00075 self.battery_update_flag = [False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False] 00076 self.battery_register_update = [roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time(),roslib.rostime.Time()] 00077 00078 def _get_types(self): 00079 """ 00080 internal API method 00081 """ 00082 return self._slot_types 00083 00084 def serialize(self, buff): 00085 """ 00086 serialize message into buffer 00087 @param buff: buffer 00088 @type buff: StringIO 00089 """ 00090 try: 00091 _x = self 00092 buff.write(_struct_6B2I.pack(_x.present, _x.charging, _x.discharging, _x.power_present, _x.power_no_good, _x.inhibited, _x.last_battery_update.secs, _x.last_battery_update.nsecs)) 00093 buff.write(_struct_48h.pack(*self.battery_register)) 00094 buff.write(_struct_48B.pack(*self.battery_update_flag)) 00095 for val1 in self.battery_register_update: 00096 _x = val1 00097 buff.write(_struct_2I.pack(_x.secs, _x.nsecs)) 00098 except struct.error as se: self._check_types(se) 00099 except TypeError as te: self._check_types(te) 00100 00101 def deserialize(self, str): 00102 """ 00103 unpack serialized message in str into this message instance 00104 @param str: byte array of serialized message 00105 @type str: str 00106 """ 00107 try: 00108 if self.last_battery_update is None: 00109 self.last_battery_update = roslib.rostime.Time() 00110 end = 0 00111 _x = self 00112 start = end 00113 end += 14 00114 (_x.present, _x.charging, _x.discharging, _x.power_present, _x.power_no_good, _x.inhibited, _x.last_battery_update.secs, _x.last_battery_update.nsecs,) = _struct_6B2I.unpack(str[start:end]) 00115 self.present = bool(self.present) 00116 self.charging = bool(self.charging) 00117 self.discharging = bool(self.discharging) 00118 self.power_present = bool(self.power_present) 00119 self.power_no_good = bool(self.power_no_good) 00120 self.inhibited = bool(self.inhibited) 00121 start = end 00122 end += 96 00123 self.battery_register = _struct_48h.unpack(str[start:end]) 00124 start = end 00125 end += 48 00126 self.battery_update_flag = _struct_48B.unpack(str[start:end]) 00127 self.battery_update_flag = map(bool, self.battery_update_flag) 00128 self.battery_register_update = [] 00129 for i in range(0, 48): 00130 val1 = roslib.rostime.Time() 00131 _x = val1 00132 start = end 00133 end += 8 00134 (_x.secs, _x.nsecs,) = _struct_2I.unpack(str[start:end]) 00135 self.battery_register_update.append(val1) 00136 self.last_battery_update.canon() 00137 return self 00138 except struct.error as e: 00139 raise roslib.message.DeserializationError(e) #most likely buffer underfill 00140 00141 00142 def serialize_numpy(self, buff, numpy): 00143 """ 00144 serialize message with numpy array types into buffer 00145 @param buff: buffer 00146 @type buff: StringIO 00147 @param numpy: numpy python module 00148 @type numpy module 00149 """ 00150 try: 00151 _x = self 00152 buff.write(_struct_6B2I.pack(_x.present, _x.charging, _x.discharging, _x.power_present, _x.power_no_good, _x.inhibited, _x.last_battery_update.secs, _x.last_battery_update.nsecs)) 00153 buff.write(self.battery_register.tostring()) 00154 buff.write(self.battery_update_flag.tostring()) 00155 for val1 in self.battery_register_update: 00156 _x = val1 00157 buff.write(_struct_2I.pack(_x.secs, _x.nsecs)) 00158 except struct.error as se: self._check_types(se) 00159 except TypeError as te: self._check_types(te) 00160 00161 def deserialize_numpy(self, str, numpy): 00162 """ 00163 unpack serialized message in str into this message instance using numpy for array types 00164 @param str: byte array of serialized message 00165 @type str: str 00166 @param numpy: numpy python module 00167 @type numpy: module 00168 """ 00169 try: 00170 if self.last_battery_update is None: 00171 self.last_battery_update = roslib.rostime.Time() 00172 end = 0 00173 _x = self 00174 start = end 00175 end += 14 00176 (_x.present, _x.charging, _x.discharging, _x.power_present, _x.power_no_good, _x.inhibited, _x.last_battery_update.secs, _x.last_battery_update.nsecs,) = _struct_6B2I.unpack(str[start:end]) 00177 self.present = bool(self.present) 00178 self.charging = bool(self.charging) 00179 self.discharging = bool(self.discharging) 00180 self.power_present = bool(self.power_present) 00181 self.power_no_good = bool(self.power_no_good) 00182 self.inhibited = bool(self.inhibited) 00183 start = end 00184 end += 96 00185 self.battery_register = numpy.frombuffer(str[start:end], dtype=numpy.int16, count=48) 00186 start = end 00187 end += 48 00188 self.battery_update_flag = numpy.frombuffer(str[start:end], dtype=numpy.bool, count=48) 00189 self.battery_update_flag = map(bool, self.battery_update_flag) 00190 self.battery_register_update = [] 00191 for i in range(0, 48): 00192 val1 = roslib.rostime.Time() 00193 _x = val1 00194 start = end 00195 end += 8 00196 (_x.secs, _x.nsecs,) = _struct_2I.unpack(str[start:end]) 00197 self.battery_register_update.append(val1) 00198 self.last_battery_update.canon() 00199 return self 00200 except struct.error as e: 00201 raise roslib.message.DeserializationError(e) #most likely buffer underfill 00202 00203 _struct_I = roslib.message.struct_I 00204 _struct_6B2I = struct.Struct("<6B2I") 00205 _struct_48B = struct.Struct("<48B") 00206 _struct_2I = struct.Struct("<2I") 00207 _struct_48h = struct.Struct("<48h")