-
Notifications
You must be signed in to change notification settings - Fork 62
add sample code of dialogflow #317
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
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
7535ecc
add soundplay_action_name param in dialogflow_client
knorth55 8c18c1f
add volume param in dialogflow_client
knorth55 19aeb47
support non japanese languages
knorth55 e99fd7c
do not use utf-8 for result msg
knorth55 e8cc910
add optional args in dialogflow_task_executive.launch
knorth55 4278fa7
fix typo in dialogflow_client.py
knorth55 f1ebed9
support credential/project_id from args, not environment variables. l…
k-okada 05927a6
add sample programs
k-okada 2c9e010
use catkin_virtualenv for dialogflow_task_executive
k-okada 909b1d5
Merge branch 'master' into sample_dialogflow
k-okada 1483c7a
use requirements.in to generate requirements.txt, becuase python2 env…
k-okada 9d057fa
only support x86_64
k-okada File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| dialogflow==1.1.1 | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| #!/usr/bin/env roseus | ||
|
|
||
| (ros::roseus-add-msgs "dialogflow_task_executive") | ||
| (ros::roseus "dialogflow_example") | ||
|
|
||
| (defun json-to-list (str) | ||
| (let (ret sstr) | ||
| ;; skip first { | ||
| (setq str (string-trim (format nil "{}~% ") str)) | ||
| ;; get first elemnet | ||
| (while str | ||
| (if (position #\, str) | ||
| (setq sstr (subseq str 0 (position #\, str)) | ||
| str (subseq str (1+ (position #\, str)))) | ||
| (setq sstr str str nil)) | ||
| (push (cons (string-trim (format nil "\"~% ") (subseq sstr 0 (position #\: sstr))) | ||
| (string-trim (format nil "\"~% ") (subseq sstr (+ (position #\: sstr) 2)))) ret) | ||
| ) | ||
| ret)) | ||
| (defclass dialogflow-client | ||
| :super propertied-object | ||
| :slots (response-msg string-msg response-sub publish-tm)) | ||
|
|
||
| (defmethod dialogflow-client | ||
| (:init | ||
| () | ||
| (setq response-sub (ros::subscribe "/dialog_response" dialogflow_task_executive::DialogResponse #'send self :dialog-cb)) | ||
| (setq response-msg (instance dialogflow_task_executive::DialogResponse :init)) | ||
| (setq string-msg (instance std_msgs::String :init)) | ||
| (ros::advertise "/text" std_msgs::string 1) | ||
| ;; wait for text publisher | ||
| (ros::rate 1) | ||
| (while (< (ros::get-num-subscribers "/text") 1) | ||
| (ros::sleep)) | ||
| self) | ||
| (:dialog-cb | ||
| (msg) | ||
| (setq response-msg msg)) | ||
| (:wait-for-response | ||
| () | ||
| (while (< (send (ros::time- (send response-msg :header :stamp) publish-tm) :to-sec) 0) | ||
| (ros::ros-info "wait for response ... ") | ||
| (ros::spin-once) | ||
| (ros::sleep)) | ||
| response-msg) | ||
| (:publish-dialog | ||
| (text) | ||
| (let (ret) | ||
| (setq publish-tm (ros::time-now)) | ||
| (send string-msg :data text) | ||
| (ros::publish "/text" string-msg) | ||
| (setq ret (send self :wait-for-response)) | ||
| (send ret :parameters (json-to-list (send ret :parameters))) | ||
| (ros::ros-info "action : ~A" (send ret :action)) | ||
| (ros::ros-info "query : ~A" (send ret :query)) | ||
| (ros::ros-info "response : ~A" (send ret :response)) | ||
| (ros::ros-info "parameters : ~A" (send ret :parameters)) | ||
| (ros::ros-info " speech : ~A" (send ret :speech_score)) | ||
| (ros::ros-info " intent : ~A" (send ret :intent_score)) | ||
| ret)) | ||
| ) | ||
|
|
||
|
|
||
| (ros::roseus "client") | ||
| (setq client (instance dialogflow-client :init)) | ||
| (send client :publish-dialog "一緒に映画見よう") | ||
| (send client :publish-dialog "壁紙がきれいだったよ") | ||
| (send client :publish-dialog "一緒に飾り付けしよう") | ||
| (send client :publish-dialog "風船を右に置いて") | ||
| (exit) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| <launch> | ||
| <arg name="google_cloud_credentials_json" default="" /> | ||
| <arg name="project_id" default="eternal-byte-236613" /> | ||
| <include file="$(find dialogflow_task_executive)/launch/dialogflow_task_executive.launch" > | ||
| <arg name="credential" value="$(arg google_cloud_credentials_json)" /> | ||
| <arg name="project_id" value="$(arg project_id)" /> | ||
| <arg name="run_app_manager" value="true" /> | ||
| <arg name="enable_hotword" default="false" /> | ||
| </include> | ||
| <node pkg="dialogflow_task_executive" type="client.l" | ||
| name="client" output="screen" /> | ||
| </launch> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@k-okada Because of these lines, PR2 cannot run dialogflow_task_executive...
PR2 is still Indigo...