$search
00001 package edu.tum.cs.ias.knowrob.mod_dialog.queries; 00002 00003 import java.util.regex.Matcher; 00004 import java.util.regex.Pattern; 00005 00006 import de.tum.in.fipm.kipm.gui.visualisation.applets.CommunicationVisApplet; 00007 import edu.tum.cs.ias.knowrob.mod_dialog.DialogModule; 00008 00009 00010 00011 public class ExecTraceQuery extends SimpleTopLevelQuery { 00012 00013 public ExecTraceQuery(DialogModule mod) { 00014 super(mod); 00015 } 00016 00017 00018 boolean exec_trace_initialized=false; 00019 void initExecutionTrace() { 00020 if(!exec_trace_initialized) { 00021 // DialogModule.executeLispPrologQuery("(with-execution-trace \"/work/ros/tumros-internal/stacks/cram_demo_apps/rosie_execution_trace_visualization/execution_traces/20101005150335-PICK-AND-PLACE-OBJ.ek\")"); 00022 exec_trace_initialized = true; 00023 } 00024 DialogModule.executeLispPrologQuery("(clear-markers)"); 00025 00026 } 00027 00028 00029 @Override 00030 public String match(String q) { 00031 00032 00033 00034 Matcher matcher = Pattern.compile("^([f|F]rom where did you try to pick up an object\\?)").matcher(q); 00035 if(matcher.find()) { 00036 00037 q=this.dialog_module.getCurrentObject(); 00038 dialog_module.setVoice("dfki-obadiah"); 00039 00040 00041 // visualize communication 00042 String query = "(visualize-tsk-location (achieve (object-in-hand ?_ ?_)) ?_ ?_))"; 00043 CommunicationVisApplet.visualizeCommunication(query, null, "", "pr2.jpg"); 00044 00045 initExecutionTrace(); 00046 DialogModule.executeLispPrologQuery(query); 00047 00048 00049 String res = "Over here\n"; 00050 CommunicationVisApplet.visualizeCommunication(null, res, "", "pr2.jpg"); 00051 00052 return res; 00053 } 00054 00055 // Where did you stand while picking up an object? (successful) 00056 // (visualize-tsk-location (achieve (object-in-hand ?_ ?_) ?_ :succeeded)) 00057 00058 matcher = Pattern.compile("^([f|F]rom where did you (successfully)? pick up an object \\?)").matcher(q); 00059 if(matcher.find()) { 00060 00061 q=this.dialog_module.getCurrentObject(); 00062 dialog_module.setVoice("dfki-obadiah"); 00063 00064 00065 // visualize communication 00066 String query = "(visualize-tsk-location (achieve (object-in-hand ?_ ?_)) ?_ :succeeded)"; 00067 CommunicationVisApplet.visualizeCommunication(query, null, "", "pr2.jpg"); 00068 00069 initExecutionTrace(); 00070 DialogModule.executeLispPrologQuery(query); 00071 00072 00073 String res = "There.\n"; 00074 CommunicationVisApplet.visualizeCommunication(null, res, "", "pr2.jpg"); 00075 00076 return res; 00077 } 00078 00079 00080 matcher = Pattern.compile("^([f|F]rom where did you put down an object\\?)").matcher(q); 00081 if(matcher.find()) { 00082 00083 q=this.dialog_module.getCurrentObject(); 00084 dialog_module.setVoice("dfki-obadiah"); 00085 00086 00087 // visualize communication 00088 String query = "(visualize-tsk-location (achieve (object-placed-at ?_ ?_)) ?_ ?_)"; 00089 CommunicationVisApplet.visualizeCommunication(query, null, "", "pr2.jpg"); 00090 00091 initExecutionTrace(); 00092 DialogModule.executeLispPrologQuery(query); 00093 00094 00095 String res = "Over there\n"; 00096 CommunicationVisApplet.visualizeCommunication(null, res, "", "pr2.jpg"); 00097 00098 return res; 00099 } 00100 00101 00102 matcher = Pattern.compile("^([w|W]here did you detect objects\\?)").matcher(q); 00103 if(matcher.find()) { 00104 00105 q=this.dialog_module.getCurrentObject(); 00106 dialog_module.setVoice("dfki-obadiah"); 00107 00108 00109 // visualize communication 00110 String query = "(visualize-object-detection ?_ ?_)"; 00111 CommunicationVisApplet.visualizeCommunication(query, null, "", "pr2.jpg"); 00112 00113 initExecutionTrace(); 00114 DialogModule.executeLispPrologQuery(query); 00115 00116 00117 String res = "At these locations.\n"; 00118 CommunicationVisApplet.visualizeCommunication(null, res, "", "pr2.jpg"); 00119 00120 return res; 00121 } 00122 00123 00124 matcher = Pattern.compile("^(how did you move while grasping the object\\?)").matcher(q); 00125 if(matcher.find()) { 00126 00127 q=this.dialog_module.getCurrentObject(); 00128 dialog_module.setVoice("dfki-obadiah"); 00129 00130 00131 // visualize communication 00132 String query = "(visualize-robot-trajectory (achieve (object-in-hand ?_ ?_)) ?_ ?_)"; 00133 CommunicationVisApplet.visualizeCommunication(query, null, "", "pr2.jpg"); 00134 00135 initExecutionTrace(); 00136 DialogModule.executeLispPrologQuery(query); 00137 00138 00139 String res = "Like this.\n"; 00140 CommunicationVisApplet.visualizeCommunication(null, res, "", "pr2.jpg"); 00141 00142 return res; 00143 } 00144 00145 00146 matcher = Pattern.compile("^(how did you move the arm while grasping the object\\?)").matcher(q); 00147 if(matcher.find()) { 00148 00149 q=this.dialog_module.getCurrentObject(); 00150 dialog_module.setVoice("dfki-obadiah"); 00151 00152 00153 // visualize communication 00154 String query = "(visualize-arm-trajectory (achieve (object-in-hand ?_ ?_)) ?_ ?_)"; 00155 CommunicationVisApplet.visualizeCommunication(query, null, "", "pr2.jpg"); 00156 00157 initExecutionTrace(); 00158 DialogModule.executeLispPrologQuery(query); 00159 00160 00161 String res = "Like that.\n"; 00162 CommunicationVisApplet.visualizeCommunication(null, res, "", "pr2.jpg"); 00163 00164 return res; 00165 } 00166 00167 return null; 00168 } 00169 00170 00171 00172 }