def call(self): next_action = self.get_next_msg(AGENT_ACTION) print next_action class CQ_Agent(mod.FrameworkModule): def __init__(self, **kwargs): super(CQ_Agent, self).__init__("agent", **kwargs) self.add_publisher(AGENT_ACTION) self.add_subscriber(PUZZLE_STATE) def call(self): self.publish(AGENT_ACTION, "hahahahaha!") if __name__ == '__main__': try: starter = AgentStarter() starter.add_module(CQ_Environment) starter.add_module(CQ_Agent) starter.start() except Exception as e: print "Received an exception: {}".format(e) traceback.print_exc() finally: pass
#!/usr/bin/env python import traceback from lidapy.framework.agent_starter import AgentStarter from tmp.hello_module import CQ_SensoryMemory if __name__ == '__main__': try: starter = AgentStarter() starter.add_module(CQ_SensoryMemory) starter.start() except Exception as e: print "Received an exception: {}".format(e) traceback.print_exc() finally: pass
self.publishers[TOPIC_random.topic_name].publish(next_msg) class CreeperModule(FrameworkModule): def __init__(self, **kwargs): super(CreeperModule, self).__init__("creeper", **kwargs) super(CreeperModule, self).add_subscriber(TOPIC_random) def call(self): msg = self.get_next_msg(TOPIC_random.topic_name) if msg is not None: logger.info("Receiving message: {}".format(msg)) if __name__ == '__main__': try: starter = AgentStarter() starter.add_module("talker", TalkerModule) starter.add_module("listener", ListenerModule) starter.add_module("creeper", CreeperModule) starter.start() except Exception as e: print e finally: pass
next_action = self.get_next_msg(AGENT_ACTION) print next_action class CQ_Agent(mod.FrameworkModule): def __init__(self, **kwargs): super(CQ_Agent, self).__init__("agent", **kwargs) self.add_publisher(AGENT_ACTION) self.add_subscriber(PUZZLE_STATE) def call(self): self.publish(AGENT_ACTION, "hahahahaha!") if __name__ == '__main__': try: starter = AgentStarter() starter.add_module(CQ_Environment) starter.add_module(CQ_Agent) starter.start() except Exception as e: print "Received an exception: {}".format(e) traceback.print_exc() finally: pass
self.publishers[TOPIC_random.topic_name].publish(next_msg) class CreeperModule(FrameworkModule): def __init__(self, **kwargs): super(CreeperModule, self).__init__("creeper", **kwargs) super(CreeperModule, self).add_subscriber(TOPIC_random) def call(self): msg = self.get_next_msg(TOPIC_random.topic_name) if msg is not None: logger.info("Receiving message: {}".format(msg)) if __name__ == '__main__': try: starter = AgentStarter() starter.add_module("talker", TalkerModule) starter.add_module("listener", ListenerModule) starter.add_module("creeper", CreeperModule) starter.start() except Exception as e: print e finally: pass