def __init__(self): ###DEBUG MODE### log_level = rospy.DEBUG if global_variables.DEBUG_MODE else rospy.INFO ################ rospy.logdebug("RhbpAgent::init") rospy.init_node('agent_node', anonymous=True, log_level=log_level) self._agent_name = rospy.get_param('~agent_name', 'agentA2') # default for debugging 'agentA1' self._agent_topic_prefix = get_bridge_topic_prefix(agent_name=self._agent_name) # ensure also max_parallel_behaviours during debugging self._manager = Manager(prefix=self._agent_name, max_parallel_behaviours=1) self.behaviours = [] self.goals = [] self.perception_provider = PerceptionProvider() # start communication class self._communication = Communication(self._agent_name) # Task update topic self._pub_subtask_update = self._communication.start_subtask_update(self._callback_subtask_update) # auction structure self.auction = Auction(self) self.number_of_agents = 2 # number_of_agents needs to match amount of launched agents self.map_communication = MapCommunication(self) self._sim_started = False # agent attributes self.local_map = GridMap(agent_name=self._agent_name, agent_vision=5) # instantiate the sensor manager passing a reference to this agent self.sensor_manager = SensorManager(self) # representation of tasks self.tasks = {} self.assigned_subtasks = [] # personal for the agent. the task at index 0 is the task the agent is currently executing # subscribe to MAPC bridge core simulation topics rospy.Subscriber(self._agent_topic_prefix + "request_action", RequestAction, self._action_request_callback) rospy.Subscriber(self._agent_topic_prefix + "start", SimStart, self._sim_start_callback) rospy.Subscriber(self._agent_topic_prefix + "end", SimEnd, self._sim_end_callback) rospy.Subscriber(self._agent_topic_prefix + "bye", Bye, self._bye_callback) rospy.Subscriber(self._agent_topic_prefix + "generic_action", GenericAction, self._callback_generic_action) self._received_action_response = False
def __init__(self): rospy.logdebug("RhbpAgent::init") rospy.init_node('agent_node', anonymous=True, log_level=rospy.DEBUG) self._agent_name = rospy.get_param('~agent_name', 'agentA1') # default for debugging 'agentA1' self._agent_topic_prefix = get_bridge_topic_prefix(agent_name=self._agent_name) # ensure also max_parallel_behaviours during debugging self._manager = Manager(prefix=self._agent_name, max_parallel_behaviours=1) # static things (terrain) self.behaviours = [] self.goals = [] self.perception_provider = PerceptionProvider() self.local_map = GridMap(agent_name=self._agent_name, live_plotting=True) # auction structure self.bids = {} self.number_of_agents = 2 # TODO: check if there's a way to get it automatically self._sim_started = False # subscribe to MAPC bridge core simulation topics rospy.Subscriber(self._agent_topic_prefix + "request_action", RequestAction, self._action_request_callback) rospy.Subscriber(self._agent_topic_prefix + "start", SimStart, self._sim_start_callback) rospy.Subscriber(self._agent_topic_prefix + "end", SimEnd, self._sim_end_callback) rospy.Subscriber(self._agent_topic_prefix + "bye", Bye, self._bye_callback) rospy.Subscriber(self._agent_topic_prefix + "generic_action", GenericAction, self._callback_generic_action) # start communication class self._communication = Communication(self._agent_name) # Map topic self._pub_map = self._communication.start_map(self._callback_map) # Personal message topic self._pub_agents = self._communication.start_agents(self._callback_agents) # Auction topic self._pub_auction = self._communication.start_auction(self._callback_auction) self.time_to_bid = True # only test debug puposes self.task_subdivision = {"task1": {"agents_needed": 3, "agents_assigned": [] } } self._received_action_response = False
def __init__(self, name, agent_name, rhbp_agent, **kwargs): """ :param name: name of the behaviour :param agent_name: name of the agent for determining the correct topic prefix :param rhbp_agent(RhbpAgent): the agent owner of the behaviour :param kwargs: more optional parameter that are passed to the base class """ super(ExplorationBehaviour, self).__init__(name=name, requires_execution_steps=True, planner_prefix=agent_name, **kwargs) self._agent_name = agent_name self._pub_generic_action = rospy.Publisher(get_bridge_topic_prefix(agent_name) + 'generic_action', GenericAction , queue_size=10) self.rhbp_agent = rhbp_agent self.exploration_path_id = None
def __init__(self, name, agent_name, **kwargs): """ :param name: name of the behaviour :param agent_name: name of the agent for determining the correct topic prefix :param kwargs: more optional parameter that are passed to the base class """ super(RandomMove, self).__init__(name=name, requires_execution_steps=True, planner_prefix=agent_name, **kwargs) self._agent_name = agent_name self._pub_generic_action = rospy.Publisher( get_bridge_topic_prefix(agent_name) + 'generic_action', GenericAction, queue_size=10)
def __init__(self, name, perception_provider, agent_name, **kwargs): """ :param name: name of the behaviour :param agent_name: name of the agent for determining the correct topic prefix :param kwargs: more optional parameter that are passed to the base class """ super(ManualMove, self).__init__(name=name, requires_execution_steps=True, planner_prefix=agent_name, **kwargs) self._perception_provider = perception_provider self._agent_name = agent_name self._pub_generic_action = rospy.Publisher(get_bridge_topic_prefix(agent_name) + 'generic_action', GenericAction , queue_size=10) # rospy.Subscriber("/directions", String, callback_direzioni) rospy.Subscriber("/key_player_" + self._agent_name, String, callback_direzioni)
def __init__(self, name, agent_name, rhbp_agent, **kwargs): """Move to Dispenser Args: name (str): name of the behaviour agent_name (str): name of the agent for determining the correct topic prefix rhbp_agent (RhbpAgent): the agent owner of the behaviour **kwargs: more optional parameter that are passed to the base class """ super(ReachMeetingPointBehaviour, self).__init__(name=name, requires_execution_steps=True, planner_prefix=agent_name, **kwargs) self._agent_name = agent_name self._pub_generic_action = rospy.Publisher(get_bridge_topic_prefix(agent_name) + 'generic_action', GenericAction , queue_size=10) self.rhbp_agent = rhbp_agent
def __init__(self, name, agent_name, action_type, params=[], **kwargs): """ :param name: name of the behaviour :param agent_name: name of the agent for determining the correct topic prefix :param action_type: type of the MAPC action :param params: optional static parameters for the MAPC action :param kwargs: more optional parameter that are passed to the base class """ super(GenericActionBehaviour, self) \ .__init__(name=name, requires_execution_steps=True, planner_prefix=agent_name, **kwargs) self._agent_name = agent_name self._action_type = action_type self._params = params self._pub_generic_action = rospy.Publisher( get_bridge_topic_prefix(agent_name) + 'generic_action', GenericAction, queue_size=10)