def iterativePlanAuto(myPatcher, ex, pddlDomainFile, pddlProblemFile, viewer, envFile, planner = "ff"): iteration = 0 initialProblemFile = pddlProblemFile cacheClearCount = 0 prevPDDLFile = None while True: reinterpreted = False iteration += 1 plannerOutFname = pddlProblemFile+ ".out" planCount = 0 strPlanFileH, plannerOutStr, planCount = runPlanner(pddlDomainFile, pddlProblemFile, plannerOutFname, planner) if strPlanFileH ==-1: reinterpreted = terminateOrReinterpret() cacheClearCount = forgetAndRestart(myPatcher, "obstructs", pddlProblemFile, ex, \ cacheClearCount) continue objSeq = [] if planner == "ff": objSeq = getObjSeqInPlan(strPlanFileH) try: planning_primitives.test(strPlanFileH, ex, objSeq) print "Success. Quitting." print "Total planning time: {0}".format(totalExecTime) print "Replan count: "+ repr(iteration) print "Cache clearing count: "+ repr(cacheClearCount) if prevPDDLFile is not None: obsCount = tryIO(prevPDDLFile, "read").count("obstructs") else: obsCount = 0 print "Number of obstructions handled: "+ repr(obsCount) sys.exit(0) except planning_primitives.ExecutingException, e: errorStr = e.pddl_error_info if errorStr == "": print "Lower level failed without error message. Possibly due to sampling limit." reinterpreted = terminateOrReinterpret() cacheClearCount = forgetAndRestart(myPatcher, "obstructs", pddlProblemFile, ex, \ cacheClearCount) continue print "Got facts:" print errorStr if viewer: #raw_input("Press return to continue") time.sleep(0.5) prevPDDLFile = pddlProblemFile pddlProblemFile = initialProblemFile.replace(".pddl", repr(iteration) + ".pddl") updateInitFile(myPatcher, pddlProblemFile, iteration, plannerOutFname, \ plannerOutStr, errorStr, planCount, planner) print
def iterativePlanAuto(myPatcher, ex, pddlDomainFile, pddlProblemFile, viewer, envFile, planner = "ff"): iteration = 0 initialProblemFile = pddlProblemFile cacheClearCount = 0 while True: reinterpreted = False iteration += 1 plannerOutFname = pddlProblemFile+ ".out" planCount = 0 strPlanFileH, plannerOutStr, planCount = runPlanner(pddlDomainFile, pddlProblemFile, plannerOutFname, planner) if strPlanFileH ==-1: reinterpreted = terminateOrReinterpret() cacheClearCount = forgetAndRestart(myPatcher, "obstructs", pddlProblemFile, ex, \ cacheClearCount) continue objSeq = [] if planner == "ff": objSeq = getObjSeqInPlan(strPlanFileH) try: planning_primitives.test(strPlanFileH, ex, objSeq) print "Success. Quitting." print "Total planning time: {0}".format(totalExecTime) print "Replan count: "+ repr(iteration) print "Cache clearing count: "+ repr(cacheClearCount) obsCount = tryIO(prevPDDLFile, "read").count("obstructs") print "Number of obstructions handled: "+ repr(obsCount) sys.exit(0) except planning_primitives.ExecutingException, e: errorStr = e.pddl_error_info if errorStr == "": print "Lower level failed without error message. Possibly due to sampling limit." reinterpreted = terminateOrReinterpret() cacheClearCount = forgetAndRestart(myPatcher, "obstructs", pddlProblemFile, ex, \ cacheClearCount) continue print "Got facts:" print errorStr if viewer: #raw_input("Press return to continue") time.sleep(0.5) prevPDDLFile = pddlProblemFile pddlProblemFile = initialProblemFile.replace(".pddl", repr(iteration) + ".pddl") updateInitFile(myPatcher, pddlProblemFile, iteration, plannerOutFname, \ plannerOutStr, errorStr, planCount, planner) print
def iterativePlanAuto(pddlDomainFile, pddlProblemFile, viewer, planner = "ff"): iteration = 0 ex = planning_primitives.initOpenRave(viewer) cacheClearCount = 0 while True: iteration += 1 plannerOutFname = pddlProblemFile+ ".out" planCount = 0 strPlanFileH, plannerOutStr, planCount = runPlanner(pddlDomainFile, pddlProblemFile, plannerOutFname, planner) prevPDDLFile = pddlProblemFile pddlProblemFile = initialProblemFile.replace(".pddl", repr(iteration) + ".pddl") reinterpret = "y" if strPlanFileH ==-1: reinterpret = raw_input("Planner failed. Reinterpret (y/n)?") if reinterpret != "y": print "Quitting" sys.exit(-1) myPatcher.forgetLearnedFactsAbout("obstructs") myPatcher.writeCurrentInitState(pddlProblemFile) planning_primitives.clearGPCache(ex) cacheClearCount += 1 continue try: planning_primitives.test(strPlanFileH, ex) print "Success. Quitting." print "Total planning time: {0}".format(totalExecTime) print "Replan count: "+ repr(iteration) print "Cache clearing count: "+ repr(cacheClearCount) obsCount = tryIO(prevPDDLFile, "read").count("obstructs") print "Number of obstructions handled: "+ repr(obsCount) sys.exit(0) except planning_primitives.ExecutingException, e: errorStr = e.pddl_error_info if errorStr == "": print "Failure: Error in simulation. Try increasing number of samples." sys.exit(-1) print "Got facts:" print errorStr if viewer: #raw_input("Press return to continue") time.sleep(0.5) updateInitFile(pddlProblemFile, iteration, plannerOutFname, \ plannerOutStr, errorStr, planCount, planner) print