Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improvements on dialogflow and google chat #451

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions dialogflow_task_executive/node_scripts/dialogflow_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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())
Expand All @@ -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)

Expand Down
Empty file modified dialogflow_task_executive/node_scripts/sample_app_print.py
100755 → 100644
Empty file.
2 changes: 2 additions & 0 deletions google_chat_ros/launch/google_chat.launch
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<!-- params for helper -->
<arg name="use_helper" default="true" />
<arg name="to_dialogflow_client" default="false" />
<arg name="send_dialogflow_response_to_google_chat" default="true" />
<arg name="debug_sound" default="false" />

<node name="google_chat_ros" pkg="google_chat_ros" type="google_chat_ros_node.py"
Expand Down Expand Up @@ -49,6 +50,7 @@
respawn="$(arg respawn)" output="screen" if="$(arg use_helper)">
<rosparam subst_value="true">
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)
</rosparam>
</node>
Expand Down
14 changes: 8 additions & 6 deletions google_chat_ros/scripts/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down