def on_new_plan_req(agents): pyhop.reset_agents_tasks() pyhop.set_state("robot", state1_r) pyhop.set_state("human", state1_h) for ag, tasks in agents.items(): pyhop.add_tasks(ag, [(t[0], *t[1]) for t in tasks]) pyhop.print_state(pyhop.agents["robot"].state) print(pyhop.agents["robot"].tasks) pyhop.print_methods("robot") pyhop.print_methods("human") sol = [] plans = pyhop.seek_plan_robot(pyhop.agents, "robot", sol) print(sol) rosnode.send_plan(sol)
'''cleancups = 0 while cleancups <= state.NUMBER_OF_DIRTY_TEACUPS: cup = 'teacup'+str(random.randint(1, state.TOTAL_NUMBER_OF_TEACUPS)) if(state2.itemstate[cup]['cleanstate'] == Itemstate.unknown): state2.itemstate[cup]['cleanstate'] = Itemstate.clean cleancups = cleancups + 1''' state.currentcup = '' return state print( '''Running: pyhop.pyhop(teaathome.setupRobotArm(test1()),[('taskmaketea','robot','teabag', 1)],verbose=2)''' ) print('') teaathome.setupTeaAtHome() pyhop.print_operators() print('') pyhop.print_methods() print('') pyhop.pyhop(teaathome.setupRobotArm(test1()), [('taskmaketea', 'robot', 'teabag', 1)], verbose=2) sys.stdout.close() sys.stdout = sys.__stdout__ print('Result log file: logs/test1.log')
""" The "travel from home to the park" example from my lectures. 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 import pyhop import simple_travel_operators print('') pyhop.print_operators() import simple_travel_methods print('') pyhop.print_methods() state1 = pyhop.State('state1') state1.loc = {'me':'home'} state1.cash = {'me':20} # To get multidimensional tables in Python, # you have to use nested lists # (or in this case, nested dictionaries) state1.dist = {'home':{'park':8}} print(""" **************************************** Call pyhop.pyhop(state1,[('travel','me','home','park')]) with different levels of verbosity ****************************************