def get_fitness(self, individual):
        """ Run the simulation and return the fitness """
        state_machine = sm.StateMachine(self.start_positions,
                                        self.random_events, self.sm_pars,
                                        self.mode)
        pytree = PyTree(individual[:],
                        behaviors=behaviors,
                        world_interface=state_machine,
                        verbose=self.verbose)

        # run the Behavior Tree
        ticks, _ = pytree.run_bt()

        return fitness_function.compute_fitness(state_machine, pytree, ticks,
                                                self.targets,
                                                self.fitness_coeff)
Esempio n. 2
0
def test_balance():
    """ Test run of balancing with off gravity piece """
    behavior_tree.load_settings_from_file(
        'duplo_state_machine/BT_SETTINGS_BALANCE.yaml')
    start_positions = []
    start_positions.append(sm.Pos(-0.05, -0.1, 0.0))
    start_positions.append(sm.Pos(0.0, -0.1, 0.0))
    start_positions.append(sm.Pos(0.05, -0.1, 0.0))

    state_machine = sm.StateMachine(start_positions, False)
    goals = ['0 at pos (0.0, 0.0, 0.0192)?']

    planner.plan(state_machine, behaviors, goals)

    behavior_tree.load_settings_from_file(
        'behavior_tree_learning/tests/BT_TEST_SETTINGS.yaml')
Esempio n. 3
0
def test_croissant():
    """ Test run of stacking four bricks in a structure looking somewhat like a croissant """
    behavior_tree.load_settings_from_file(
        'duplo_state_machine/BT_SETTINGS_CROISSANT.yaml')
    start_positions = []
    start_positions.append(sm.Pos(-0.05, -0.1, 0))
    start_positions.append(sm.Pos(0, -0.1, 0))
    start_positions.append(sm.Pos(0.05, -0.1, 0))
    start_positions.append(sm.Pos(0.1, -0.1, 0))
    state_machine = sm.StateMachine(start_positions, False)
    goals = ['0 at pos (0.0, 0.0, 0.0)?', '1 at pos (0.0, 0.0, 0.0192)?', \
             '2 at pos (0.016, -0.032, 0.0)?', '3 at pos (0.016, 0.032, 0.0)?']
    planner.plan(state_machine, behaviors, goals)

    behavior_tree.load_settings_from_file(
        'behavior_tree_learning/tests/BT_TEST_SETTINGS.yaml')
Esempio n. 4
0
def test_tower():
    """ Test run of stacking three bricks in a tower """
    behavior_tree.load_settings_from_file(
        'duplo_state_machine/BT_SETTINGS_TOWER.yaml')
    start_positions = []
    start_positions.append(sm.Pos(-0.05, -0.1, 0))
    start_positions.append(sm.Pos(0, -0.1, 0))
    start_positions.append(sm.Pos(0.05, -0.1, 0))
    state_machine = sm.StateMachine(start_positions, False)
    goals = [
        '0 at pos (0.0, 0.05, 0.0)?', '1 at pos (0.0, 0.05, 0.0192)?',
        '2 at pos (0.0, 0.05, 0.0384)?'
    ]
    planner.plan(state_machine, behaviors, goals)

    behavior_tree.load_settings_from_file(
        'behavior_tree_learning/tests/BT_TEST_SETTINGS.yaml')
Esempio n. 5
0
def test_blocking():
    """ Test run of shuffling bricks to avoid blocking """
    behavior_tree.load_settings_from_file(
        'duplo_state_machine/BT_SETTINGS_BLOCKING.yaml')
    start_positions = []
    start_positions.append(sm.Pos(0.0, -0.05, 0.0))
    start_positions.append(sm.Pos(0.0, 0.05, 0.0))
    start_positions.append(sm.Pos(-0.1, 0.0, 0.0))

    state_machine = sm.StateMachine(start_positions, False)
    goals = [
        '0 at pos (-0.1, 0.0, 0.0)?', '1 at pos (-0.1, 0.0, 0.0192)?',
        '2 at pos (0.0, 0.0, 0.0)?'
    ]

    planner.plan(state_machine, behaviors, goals)

    behavior_tree.load_settings_from_file(
        'behavior_tree_learning/tests/BT_TEST_SETTINGS.yaml')