def self_test(self): """ make sure the goal is sane """ bb = Blackboard() self.touch(bb) assert self.test(bb) == True
def __init__(self, parent, action, bb=None): self.parent = parent self.action = action self.bb = Blackboard() self.delta = Blackboard() #self.cost = action.calc_cost() self.cost = 1 self.g = calcG(self) self.h = 1 if not parent == None: self.bb.update(parent.bb) elif not bb == None: self.bb.update(bb) action.touch(self.delta) self.bb.update(self.delta)
def __init__(self): self.idle_timeout = 30 self.bb = Blackboard() #self.mem_manager = MemoryManager(self) self.planner = plan self.current_goal = None self.goals = [] # all goals this instance can use self.filters = [] # list of methods to use as a filter self.actions = [] # all actions this npc can perform self.plan = [] # list of actions to perform # '-1' will be the action currently used # this special filter will prevent time precepts from being stored self.filters.append(time_filter)
temp_offset = -1.5 # serial port for connection to the PT8005 sound_serial_port = "/dev/ttyUSB0" parser = ArgumentParser() parser.add_argument("-v", action="store_true") options = parser.parse_args() if options.v: log_level = logging.DEBUG if __name__ == "__main__": log_format = "%(asctime)s: %(message)s" logging.basicConfig(format=log_format, level=log_level, datefmt="%H:%M:%S") blackboard = Blackboard() gas = GasReader(blackboard) temperature = TemperatureReader(blackboard, temp_offset=temp_offset) sound = SoundReader(blackboard, serial_port=sound_serial_port) exporter = PrometheusExporter(blackboard) threads.append(threading.Thread(target=gas.measure, daemon=True)) threads.append(threading.Thread(target=gas.set_baseline, daemon=True)) threads.append(threading.Thread(target=gas.calibrate, daemon=True)) threads.append(threading.Thread(target=temperature.measure, daemon=True)) threads.append(threading.Thread(target=sound.measure, daemon=True)) threads.append(threading.Thread(target=exporter.fill_gauges, daemon=True)) exporter.start_prometheus_http_server()