Example #1
0
def ros_style_midca():
	#myMidca = base.MIDCA(None, verbose = 2)
	myMidca = base.PhaseManager(None, verbose=4, metaEnabled=True)
	for phase in ["Perceive", "Interpret", "Eval", "Intend", "Plan", "Act"]:
		myMidca.append_phase(phase)

	myMidca.append_module("Perceive", ROSObserver.ROSObserver())
	myMidca.append_module("Interpret", InstructionReceiver.InstructionReceiver())
	myMidca.append_module("Eval", EvalPointingFromFeedback.EvalPointingFromFeedback())
	myMidca.append_module("Intend", SimpleIntend.SimpleIntend())
	#myMidca.append_module("Plan", AsynchPyhopPlanner.AsynchPyhopPlanner(DECLARE_METHODS_FUNC,
	#														 DECLARE_OPERATORS_FUNC))
	
	myMidca.append_module("Plan", PyHopPlannerBroken.PyHopPlannerBroken(util.pyhop_state_from_world,
                                                                util.pyhop_tasks_from_goals,
                                                                DECLARE_METHODS_FUNC,
                                                                DECLARE_OPERATORS_FUNC,
                                                                extinguishers=False))
	myMidca.append_module("Act", AsynchronousAct.AsynchronousAct())
	
	# add meta layer phases
	#for phase in ["Monitor", "Interpret", "Eval", "Intend", "Plan", "Control"]:
	for phase in ["Monitor", "Interpret", "Intend", "Plan", "Control"]:
	    myMidca.append_meta_phase(phase)
	
	# add meta layer modules
	myMidca.append_meta_module("Monitor", monitor.MRSimpleMonitor())
	myMidca.append_meta_module("Interpret", interpret.MRSimpleDetectOld())
	myMidca.append_meta_module("Interpret", interpret.MRSimpleGoalGen())
	myMidca.append_meta_module("Intend", metaintend.MRSimpleIntend())
	myMidca.append_meta_module("Plan", plan.MRSimplePlanner(using_baxter=True))
	myMidca.append_meta_module("Control", control.MRSimpleControl())

	return myMidca
def UserGoalsMidca(domainFile, stateFile, goalsFile = None, extinguish = False):
    world = domainread.load_domain(domainFile)
    stateread.apply_state_file(world, stateFile)
    myMidca = base.PhaseManager(world, verbose=1, display = asqiiDisplay, metaEnabled=True)

    # add cognitive layer phases
    for phase in ["Simulate", "Perceive", "Interpret", "Eval", "Intend", "Plan", "Act"]:
        myMidca.append_phase(phase)

    # add cognitive layer modules
    myMidca.append_module("Simulate", simulator.MidcaActionSimulator())
    myMidca.append_module("Simulate", simulator.ASCIIWorldViewer())
    myMidca.append_module("Perceive", perceive.PerfectObserver())
    myMidca.append_module("Interpret", note.ADistanceAnomalyNoter())
    myMidca.append_module("Interpret", guide.UserGoalInput())
    myMidca.append_module("Eval", evaluate.SimpleEval())
    myMidca.append_module("Intend", intend.SimpleIntend())
    myMidca.append_module("Plan", planningbroken.PyHopPlannerBroken(extinguish))
    myMidca.append_module("Act", act.SimpleAct())

    # add meta layer phases
    #for phase in ["Monitor", "Interpret", "Eval", "Intend", "Plan", "Control"]:
    for phase in ["Monitor", "Interpret", "Intend", "Plan", "Control"]:
        myMidca.append_meta_phase(phase)

    # add meta layer modules
    myMidca.append_meta_module("Monitor", monitor.MRSimpleMonitor())
    myMidca.append_meta_module("Interpret", interpret.MRSimpleDetect())
    myMidca.append_meta_module("Interpret", interpret.MRSimpleGoalGen())
    myMidca.append_meta_module("Intend", metaintend.MRSimpleIntend())
    myMidca.append_meta_module("Plan", plan.MRSimplePlanner())
    myMidca.append_meta_module("Control", control.MRSimpleControl())

    return myMidca
    planningbroken.PyHopPlannerBroken(util.pyhop_state_from_world,
                                      util.pyhop_tasks_from_goals,
                                      DECLARE_METHODS_FUNC,
                                      DECLARE_OPERATORS_FUNC,
                                      extinguishers=False))
myMidca.append_module("Act", act.SimpleAct())

# add meta layer phases
#for phase in ["Monitor", "Interpret", "Eval", "Intend", "Plan", "Control"]:
for phase in ["Monitor", "Interpret", "Intend", "Plan", "Control"]:
    myMidca.append_meta_phase(phase)

# add meta layer modules
myMidca.append_meta_module("Monitor", monitor.MRSimpleMonitor())
myMidca.append_meta_module("Interpret", interpret.MRSimpleDetectOld())
myMidca.append_meta_module("Interpret", interpret.MRSimpleGoalGen())
myMidca.append_meta_module("Intend", metaintend.MRSimpleIntend())
myMidca.append_meta_module("Plan", plan.MRSimplePlanner())
myMidca.append_meta_module("Control", control.MRSimpleControl())

#myMidca.mem.enableTracing(myMidca.trace)

myMidca.insert_module('Simulate',
                      simulator.ArsonSimulator(arsonChance=0.3, arsonStart=2),
                      1)
#myMidca.insert_module('Interpret', guide.TFStack(), 1)
myMidca.insert_module('Interpret', guide.TFFire(), 2)


def preferFire(goal1, goal2):
    if 'predicate' not in goal1 or 'predicate' not in goal2: