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
def forgetAndRestart(myPatcher, learnedPredicate, problemFile, executor, cacheClearCount):
    cacheClearCount += 1
    myPatcher.forgetLearnedFactsAbout("obstructs")
    myPatcher.writeCurrentInitState(problemFile)
    planning_primitives.clearGPCache(executor)
    return cacheClearCount
示例#3
0
def forgetAndRestart(myPatcher, learnedPredicate, problemFile, executor, cacheClearCount):
    cacheClearCount += 1
    myPatcher.forgetLearnedFactsAbout("obstructs")
    myPatcher.writeCurrentInitState(problemFile)
    planning_primitives.clearGPCache(executor)
    return cacheClearCount