def init_planner(self):
     logger.info("adding atomic operators to pyhop")
     self.init_state()
     # note: can call declare_operators multiple times for current situation
     hop.declare_operators(self.move_forward, self.turn_left,
                           self.turn_right, self.break_block)
     hop.print_operators(hop.get_operators())
     # for the main task
     hop.declare_methods('get_resource', self.get_resource)
     # for each sub-task of the main task
     hop.declare_methods('find_route', self.find_route_to_resource)
     hop.declare_methods('navigate', self.navigate_to_resource)
     hop.declare_methods('acquire', self.acquire_resource)
     hop.print_methods(hop.get_methods())
Ejemplo n.º 2
0
 def init_planner(self):
     logger.info("adding atomic operators to pyhop")
     self.init_state()
     # note: can call declare_operators multiple times for current situation
     hop.declare_operators(
         self.move_forward,
         self.turn_left,
         self.turn_right,
         self.break_block,
         self.search_placeholder,
     )
     #    self.equip_agent)
     hop.print_operators(hop.get_operators())
     # for the main task
     hop.declare_methods('get_resource', self.get_resource)
     # for each sub-task of the main task
     hop.declare_methods('search_for_gold', self.search_for_gold)
     hop.declare_methods('move_closer', self.move_closer)
     hop.declare_methods('acquire_gold', self.acquire_resource)
     # hop.declare_methods('break_wall', self.break_wall)
     hop.print_methods(hop.get_methods())
    # pick_from_tray(state, r, o)
    if (state.loc[o] == r and state.gripperfree == False and state.loc[r] == x
            and state.cupboardisopen == True):
        state.gripperfree = True
        state.loc[o] = x
        state.objects['cupboard'] += 1
    else:
        return False
    return state


#initial state

hop.declare_operators(look_cupboard, open, look_table, goto, pick, place)
print('')
hop.print_operators(hop.get_operators())


#x and y are locations, o is object and r is robot
def task1(state, r, o, x, y):
    tasklist = [('look_cupboard', r), ('goto', r, '', x), ('open', r, x),
                ('look_table', r), ('goto', r, x, y)]
    X1 = [('pick', r, o, y), ('goto', r, y, x), ('place', r, o, x),
          ('goto', r, x, y)]
    for k in range(5):
        for j in range(len(X1)):
            tasklist.append(X1[j])
    return tasklist


hop.declare_methods('task1', task1)
Ejemplo n.º 4
0
"""
Blocks-world test data for Pyhop 1.1.
Author: Dana Nau <*****@*****.**>, November 15, 2012
This file should work correctly in both Python 2.7 and Python 3.2.
"""
from __future__ import print_function
from pyhop import hop

import operators
import methods1


print('')
hop.print_operators(hop.get_operators())
print('')
hop.print_methods(hop.get_methods())

#############     beginning of tests     ################

print("""
****************************************
First, test pyhop on some of the operators and smaller tasks
****************************************
""")

print("- Define state1: a on b, b on tale, c on table")

"""
A state is a collection of all of the state variables and their values. Every
state variable in the domain should have a value.
"""