diff --git a/dialogflow_task_executive/node_scripts/dialogflow_client.py b/dialogflow_task_executive/node_scripts/dialogflow_client.py index d8dbeb08a..208c405ef 100644 --- a/dialogflow_task_executive/node_scripts/dialogflow_client.py +++ b/dialogflow_task_executive/node_scripts/dialogflow_client.py @@ -104,7 +104,7 @@ def make_dialog_msg(self, result): msg = DialogResponse() msg.header.stamp = rospy.Time.now() if result.action == 'input.unknown': - rospy.logwarn("Unknown action") + rospy.logwarn("Unknown action '{}'".format(result.action)) msg.action = result.action # check if ROS_PYTHON_VERSION exists in indigo @@ -134,7 +134,9 @@ def __init__(self): def cb(self, goal): feedback = DialogTextFeedback() result = DialogTextResult() + df_result = None success = False + rospy.loginfo("goal = {}".format(goal)) try: if self.session_id is None: self.session_id = str(uuid.uuid1()) @@ -154,7 +156,10 @@ def cb(self, goal): finally: self._as.publish_feedback(feedback) result.done = success - self._as.set_succeeded(result) + if success: + self._as.set_succeeded(result) + else: + self._as.set_preempted() if df_result and self.always_publish_result: self.pub_res.publish(result.response) diff --git a/dialogflow_task_executive/node_scripts/sample_app_print.py b/dialogflow_task_executive/node_scripts/sample_app_print.py old mode 100755 new mode 100644 diff --git a/google_chat_ros/launch/google_chat.launch b/google_chat_ros/launch/google_chat.launch index 8ef7a56ac..c374eb828 100644 --- a/google_chat_ros/launch/google_chat.launch +++ b/google_chat_ros/launch/google_chat.launch @@ -22,6 +22,7 @@ + to_dialogflow_client: $(arg to_dialogflow_client) + send_dialogflow_response_to_google_chat: $(arg send_dialogflow_response_to_google_chat) debug_sound: $(arg debug_sound) diff --git a/google_chat_ros/scripts/helper.py b/google_chat_ros/scripts/helper.py index 4b5a33247..99002b529 100644 --- a/google_chat_ros/scripts/helper.py +++ b/google_chat_ros/scripts/helper.py @@ -18,6 +18,7 @@ def __init__(self): # Get configuration params self.to_dialogflow_task_executive = rospy.get_param("~to_dialogflow_client") self.sound_play_jp = rospy.get_param("~debug_sound") + self.send_dialogflow_response_to_google_chat = rospy.get_param("~send_dialogflow_response_to_google_chat", True) self._message_sub = rospy.Subscriber("google_chat_ros/message_activity", MessageEvent, callback=self._message_cb) self.recent_message_event = None @@ -59,13 +60,14 @@ def _message_cb(self, data): thread_name = data.message.thread_name text = data.message.argument_text if self.to_dialogflow_task_executive: - chat_goal = SendMessageGoal() - chat_goal.space = space - chat_goal.thread_name = thread_name dialogflow_res = self.dialogflow_action_client(text) - content = "<{}> {}".format(sender_id, dialogflow_res.response.response) - chat_goal.text = content - self.send_chat_client(chat_goal) + if self.send_dialogflow_response_to_google_chat: + chat_goal = SendMessageGoal() + chat_goal.space = space + chat_goal.thread_name = thread_name + content = "<{}> {}".format(sender_id, dialogflow_res.response.response) + chat_goal.text = content + self.send_chat_client(chat_goal) if self.sound_play_jp: sound_goal = SoundRequestGoal() sound_goal.sound_request.sound = sound_goal.sound_request.SAY