def process_file(self, record_file): """ Extract information from record file. Return True if we are done collecting all information. """ try: reader = RecordReader(record_file) print("Begin to process record file {}".format(record_file)) for msg in reader.read_messages(): print(msg.topic) if msg.topic == kChassisInfoTopic and self.vehicle_vin is None: chassis = chassis_pb2.Chassis() chassis.ParseFromString(msg.message) if chassis.license.vin: self.vehicle_vin = chassis.license.vin elif msg.topic == kHMIInfoTopic and self.vehicle_name is None: hmistatus = hmi_status_pb2.HMIStatus() hmistatus.ParseFromString(msg.message) if hmistatus.current_map: self.vehicle_name = hmistatus.current_map print(self.vehicle_name) if self.done(): return True except: return False print("Finished processing record file {}".format(record_file)) return self.done()
def process_file(self, bag_file): """ Extract information from bag file. Return True if we are done collecting all information. """ try: reader = RecordReader(bag_file) print "begin" for msg in reader.read_messages(): if msg.topic == kChassisInfoTopic and self.vehicle_vin == None: chassis = chassis_pb2.Chassis() chassis.ParseFromString(msg.message) if chassis.license.vin: self.vehicle_vin = chassis.license.vin elif msg.topic == kHMIInfoTopic and self.vehicle_name == None: hmistatus = hmi_status_pb2.HMIStatus() hmistatus.ParseFromString(msg.message) print hmistatus.MessageType if hmistatus.current_vehicle: self.vehicle_name = hmistatus.current_vehicle print self.vehicle_name if self.done(): return True except: return False return self.done()