$search
00001 package edu.tum.cs.ias.knowrob.vis.applets; 00002 00003 import javax.swing.JFrame; 00004 00005 import edu.tum.cs.ias.knowrob.prolog.PrologInterface; 00006 import edu.tum.cs.ias.knowrob.vis.applets.PlanVisAppletFsm; 00007 00015 public class PlanVisTest { 00019 public static void main(String[] args) { 00020 00021 JFrame f = new JFrame(); 00022 f.setSize(800,600); 00023 00024 PlanVisAppletFsm applet = new PlanVisAppletFsm(); 00025 PrologInterface.initJPLProlog("re_unr_interface"); 00026 // PFont dejavuFont = applet.createFont("DejaVu Sans",13); 00027 // applet.textFont(dejavuFont); // FIXME: problem with textFont, font seems OK, but the method throws a NullPointerException 00028 applet.loadPrologPlan("http://www.roboearth.org/kb/test-recipe-greeting-sm.owl#UnrGreetingTest"); 00029 00030 applet.init(); 00031 applet.frame = f; 00032 00033 applet.drawActionsTreeLayout(); 00034 applet.redraw(); 00035 00036 f.add(applet); 00037 f.setTitle("PlanVis"); 00038 f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 00039 f.setLocationRelativeTo(null); 00040 f.setVisible(true); 00041 00042 f.addMouseListener(applet); 00043 f.addMouseMotionListener(applet); 00044 f.addKeyListener(applet); 00045 00046 00047 00048 // 00049 // Action recommend = Action.getAction("http://ias.cs.tum.edu/kb/knowrob.owl#RecommendingAProduct", "Recommend a product"); 00050 // applet.setTask(recommend); 00051 // 00052 // 00053 // 00054 // Action detect = Action.getAction("http://ias.cs.tum.edu/kb/knowrob.owl#DetectPerson", "Detect persons"); 00055 // detect.addSuperClass(OWLClass.getOWLClass("http://ias.cs.tum.edu/kb/knowrob.owl#PersonDetection")); 00056 // detect.addHasValue("minNumber", "1"); 00057 // applet.addAction(detect); 00058 // 00059 // recommend.addSubAction(detect); 00060 // recommend.getTransitions().setStartAction(detect); 00061 // 00062 // 00063 // 00064 // Action identify = Action.getAction("http://ias.cs.tum.edu/kb/knowrob.owl#IdentifyPerson", "Identify the person"); 00065 // identify.addSuperClass(OWLClass.getOWLClass("http://ias.cs.tum.edu/kb/knowrob.owl#PersonIdentification")); 00066 // identify.addHasValue("outputsCreated", "?NAME"); 00067 // recommend.addSubAction(identify); 00068 // detect.addTransition(ActionTransition.getActionTransition("http://ias.cs.tum.edu/kb/knowrob.owl#Transition2", detect, identify, "http://www.roboearth.org/kb/unr_actions.owl#COMPLETED_OK")); 00069 // 00070 // 00071 // 00072 // Action talk_to = Action.getAction("http://ias.cs.tum.edu/kb/knowrob.owl#GreetPerson", "Greet and ask if help is needed"); 00073 // talk_to.addSuperClass(OWLClass.getOWLClass("http://ias.cs.tum.edu/kb/knowrob.owl#SpeechSynthesis")); 00074 // talk_to.addHasValue("spokenText", "Hello, ?NAME! Can I help you?"); 00075 // talk_to.addHasValue("outputsCreated", "?RESPONSE"); 00076 // recommend.addSubAction(talk_to); 00077 // identify.addTransition(ActionTransition.getActionTransition("http://ias.cs.tum.edu/kb/knowrob.owl#Transition3", identify, talk_to, "http://www.roboearth.org/kb/unr_actions.owl#COMPLETED_OK")); 00078 // 00079 // 00080 // 00081 // Action check_if_question = Action.getAction("http://ias.cs.tum.edu/kb/knowrob.owl#ProductPlacementQuestion", "Question for product location?"); 00082 // check_if_question.addSuperClass(OWLClass.getOWLClass("http://ias.cs.tum.edu/kb/knowrob.owl#ProductPlacementQuestion")); 00083 // check_if_question.addHasValue("evaluateOn", "?RESPONSE"); 00084 // check_if_question.addHasValue("outputsCreated", "?OBJECT"); 00085 // recommend.addSubAction(check_if_question); 00086 // talk_to.addTransition(ActionTransition.getActionTransition("http://ias.cs.tum.edu/kb/knowrob.owl#Transition4", talk_to, check_if_question, "http://www.roboearth.org/kb/unr_actions.owl#COMPLETED_OK")); 00087 // 00088 // 00089 // Action compute_obj_pos = Action.getAction("http://ias.cs.tum.edu/kb/knowrob.owl#CompObjPos", "Compute object position"); 00090 // compute_obj_pos.addSuperClass(OWLClass.getOWLClass("http://ias.cs.tum.edu/kb/knowrob.owl#CompObjPos")); 00091 // compute_obj_pos.addHasValue("objectActedOn", "?OBJECT"); 00092 // recommend.addSubAction(compute_obj_pos); 00093 // check_if_question.addTransition(ActionTransition.getActionTransition("http://ias.cs.tum.edu/kb/knowrob.owl#Transition5", check_if_question, compute_obj_pos, "http://www.roboearth.org/kb/unr_actions.owl#COMPLETED_CONDITION_TRUE")); 00094 // 00095 // 00096 // 00097 // Action ask_operator = Action.getAction("http://ias.cs.tum.edu/kb/knowrob.owl#AskHumanOperator", "Ask human operator"); 00098 // ask_operator.addSuperClass(OWLClass.getOWLClass("http://ias.cs.tum.edu/kb/knowrob.owl#HumanOperatorQuestion")); 00099 // ask_operator.addHasValue("objectActedOn", "?OBJECT"); 00100 // ask_operator.addHasValue("outputsCreated", "?STORAGE_LOC"); 00101 // recommend.addSubAction(ask_operator); 00102 // compute_obj_pos.addTransition(ActionTransition.getActionTransition("http://ias.cs.tum.edu/kb/knowrob.owl#Transition6", compute_obj_pos, ask_operator, "http://www.roboearth.org/kb/unr_actions.owl#COMPLETED_TIMEOUT")); 00103 // ask_operator.addTransition(ActionTransition.getActionTransition("http://ias.cs.tum.edu/kb/knowrob.owl#Transition7", ask_operator, compute_obj_pos, "http://www.roboearth.org/kb/unr_actions.owl#COMPLETED_TIMEOUT")); 00104 // 00105 // 00106 // 00107 // Action describe_loc = Action.getAction("http://ias.cs.tum.edu/kb/knowrob.owl#DescribeLocation", "Describe location"); 00108 // describe_loc.addSuperClass(OWLClass.getOWLClass("http://ias.cs.tum.edu/kb/knowrob.owl#SpeechSynthesis")); 00109 // describe_loc.addHasValue("spokenText", "?OBJECT can be found at ?STORAGE_LOC"); 00110 // recommend.addSubAction(describe_loc); 00111 // compute_obj_pos.addTransition(ActionTransition.getActionTransition("http://ias.cs.tum.edu/kb/knowrob.owl#Transition8", compute_obj_pos, describe_loc, "http://www.roboearth.org/kb/unr_actions.owl#COMPLETED_OK")); 00112 // 00113 // 00114 // 00115 // 00116 // Action goodbye = Action.getAction("http://ias.cs.tum.edu/kb/knowrob.owl#Goodbye", "Say goodbye"); 00117 // goodbye.addSuperClass(OWLClass.getOWLClass("http://ias.cs.tum.edu/kb/knowrob.owl#SpeechSynthesis")); 00118 // goodbye.addHasValue("spokenText", "Okay, then have a nice day!"); 00119 // recommend.addSubAction(goodbye); 00120 // check_if_question.addTransition(ActionTransition.getActionTransition("http://ias.cs.tum.edu/kb/knowrob.owl#Transition9", check_if_question, goodbye, "http://www.roboearth.org/kb/unr_actions.owl#COMPLETED_CONDITION_FALSE")); 00121 00122 00123 00124 00125 00126 } 00127 }