Ejemplo n.º 1
0
 def test_chemotaxisge(self):
     """
     test creation of ChemotaxisGe
     """
     components = create_from_yaml(os.path.join(os.path.dirname(__file__),
                                                '../so_coordinator/'
                                                'so_specification.yaml'),
                                   'test1',
                                   config_key='ChemotaxisGe',
                                   params={'pose_frame': 'pose_frame',
                                           'motion_topic': 'motion_topic'},
                                   mapping=SO_MAPPING,
                                   components_class=SOComponents)
     self.assert_(True)
Ejemplo n.º 2
0
 def test_flocking_exploration(self):
     """
     test creation of FlockingReyExploration
     """
     components = create_from_yaml(os.path.join(os.path.dirname(__file__),
                                                '../so_coordinator/'
                                                'so_specification.yaml'),
                                   'test1',
                                   config_key='FlockingReyExploration',
                                   params={'pose_frame': 'pose_frame',
                                           'motion_topic': 'motion_topic'},
                                   mapping=SO_MAPPING,
                                   components_class=SOComponents)
     self.assert_(True)
Ejemplo n.º 3
0
 def test_center(self):
     """
     test creation of Foraging
     """
     components = create_from_yaml(os.path.join(os.path.dirname(__file__),
                                                '../so_coordinator/'
                                                'so_specification.yaml'),
                                   'test1',
                                   config_key='MorphogenesisBarycenter',
                                   params={'pose_frame': 'pose_frame'},
                                   mapping=SO_MAPPING,
                                   components_class=SOComponents,
                                   name='centertest')
     self.assert_(True)
Ejemplo n.º 4
0
 def test_morpho_chem(self):
     """
     test creation of MorphogenesisBarycenterChemotaxisBalch
     """
     components = create_from_yaml(os.path.join(os.path.dirname(__file__),
                                                '../so_coordinator/'
                                                'so_specification.yaml'),
                                   'test1',
                                   config_key='MorphogenesisBarycenterChemotaxisBalch',
                                   params={'pose_frame': 'pose_frame',
                                           'motion_topic': 'motion_topic'},
                                   mapping=SO_MAPPING,
                                   components_class=SOComponents,
                                   name='chemtest2')
     self.assert_(True)
Ejemplo n.º 5
0
 def test_repGradient(self):
     """
     test creation of RepulsionFernandez
     """
     components = create_from_yaml(os.path.join(os.path.dirname(__file__),
                                                '../so_coordinator/'
                                                'so_specification.yaml'),
                                   'test1',
                                   config_key='RepulsionGradient',
                                   params={'pose_frame': 'pose_frame',
                                           'motion_topic': 'motion_topic'},
                                   mapping=SO_MAPPING,
                                   components_class=SOComponents,
                                   name='repGrad')
     self.assert_(True)
    def replace_components(self, config_key):
        """
        method to remove existing components and create new ones
        :return:
        """
        # remove current components
        self.remove_components()

        # create new components
        self.components = create_from_yaml(
            os.path.join(self.path, self.pattern_knowledge), self.id,
            planner_prefix=self.get_manager_prefix(), config_key=config_key,
            params=self.params, mapping=self.mapping,
            components_class=self.components_class,
            optional_params=self.optional_params)
Ejemplo n.º 7
0
 def test_gossip(self):
     """
     test creation of GossipMax
     """
     components = create_from_yaml(os.path.join(os.path.dirname(__file__),
                                                '../so_coordinator/'
                                                'so_specification.yaml'),
                                   'test1',
                                   config_key='GossipMax',
                                   params={'pose_frame': 'pose_frame',
                                           'value': 0,
                                           'initial_value': 0},
                                   mapping=SO_MAPPING,
                                   components_class=SOComponents,
                                   name='gossipmax')
     self.assert_(True)
    def __init__(self, so_goal, correlations=None, id='robot1',
                 name='SoCoordinator', path=os.path.dirname(__file__),
                 expert_knowledge='so_expert_knowledge.yaml',
                 pattern_knowledge='so_specification.yaml',
                 decision=DecisionStrategy,
                 components_class=SOComponents,
                 mapping=SO_MAPPING,
                 requires_execution_steps=True,
                 params=None, optional_params=None, **kwargs):

        """
        initialization
        :param correlations: effects of SoCoordinator (on higher level)
        :param so_goal: self-organization goal used in coordination mechanism
                        selection
        :param id: id of the agent
        :param name: unique name of the object
        :param path: path to the yaml files
        :param expert_knowledge: yaml file containing mapping goal - option
        :param pattern_knowledge: yaml file containing option configurations
        :param decision: class containing decision strategy
        :param components_class: class containing factory to create RHBP
                                 components
        :param mapping: dictionary mapping strings to classes
        :param requires_execution_steps: whether the execution steps should be
                                         caused from the parent manager or not.
        :param params: agent specific parameters for creation of RHBP
                       components
        :param optional_params: dictionary indicating component parameters to
                                be adjusted; form: component_key:  {parameters}
        :param kwargs: keyword arguments
        """

        self.path = path
        self.pattern_knowledge = pattern_knowledge
        self.params = params
        self.mapping = mapping
        self.components_class = components_class
        if optional_params is None:
            self.optional_params = {}
        else:
            self.optional_params = optional_params
        self.id = id

        # init parent class (NetworkBehaviour)
        super(SoCoordinator, self).__init__(name=name, requires_execution_steps=requires_execution_steps,
                                            correlations=correlations, always_update_activation=True, **kwargs)

        # Coordination Mechanism Selection

        # 1) Expert Knowledge + Decision Making Strategy
        self.selector = decision(so_goal, os.path.join(path, expert_knowledge))
        selection = self.selector.select()
        # combine optional params and parameters included in expert knowledge
        # (optional params dominate params included in expert knowledge)
        selection[1].update(self.optional_params)

        # 2) Creation of SO Components based on selected so configuration
        self.components = create_from_yaml(
            os.path.join(path, pattern_knowledge), id,
            planner_prefix=self.get_manager_prefix(), config_key=selection[0],
            params=params, mapping=mapping, components_class=components_class,
            optional_params=selection[1])