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())
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())
#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) print('') hop.print_methods(hop.get_methods()) state1 = hop.State('state1') state1.loc = {'objects': 'table', 'robot': ''} state1.objects = {'table': 5, 'cupboard': 0} state1.gripperfree = True #gripper true referes to gripper free state state1.cupboardisopen = False #cupboard is closed state1.isTable = False state1.isCupboard = False print(""" ******************************************************************************** Call hop.plan(state1,[('task1','robot','coke','cupboard','table')]) ******************************************************************************** """)
""" 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. """