4 from std_msgs.msg
import String
6 from os.path
import basename
9 ask_yesno_client =
None 20 self.intents.update(intents)
24 intent_func = self.intents.get(data.intent_name,
None)
25 if intent_func
is not None:
29 self.
intents[intent_name] = func
41 self.intents.append(intent)
45 self.intent_files.append(intent_file)
49 self.entities.append(entity)
68 self.at_least_one.append(args)
71 def require(self, entity_type, attribute_name=None):
72 if not attribute_name:
73 attribute_name = entity_type
74 self.requires.append(IntentRequire(entity=entity_type, attribute_name=attribute_name))
78 if not attribute_name:
79 attribute_name = entity_type
80 self.optional.append(IntentOptional(entity=entity_type, attribute_name=attribute_name))
90 client.wait_for_server()
91 goal = GetResponseGoal(skill_path, dialog)
92 client.send_goal(goal)
93 client.wait_for_result()
94 result = client.get_result()
95 return result.response
101 client.wait_for_server()
102 goal = GetResponseGoal(skill_path, dialog)
103 client.send_goal(goal)
104 client.wait_for_result()
105 result = client.get_result()
106 return result.response
109 rospy.wait_for_service(
'mycroft/register_skill')
111 register = rospy.ServiceProxy(
'mycroft/register_skill', MycroftSkill)
112 response = register(mycroft_skill)
113 return response.initialised
114 except rospy.ServiceException:
115 rospy.loginfo(
"Service call failed")
129 self.
remove_skill = rospy.Publisher(
'mycroft/remove_skill', String, queue_size=10)
133 if isinstance(intent_parser, IntentBuilder):
134 intent_parser = intent_parser.build()
135 elif not isinstance(intent_parser, Intent):
136 raise ValueError(
'"' + str(intent_parser) +
'" is not an Intent')
138 name = self.
id +
":" + intent_parser.name
140 self.intents.append(intent_parser)
143 name = self.
id +
":" + intent_file
145 self.intent_files.append(intent_file)
148 self.entities.append(entity_file)
155 rospy.wait_for_service(
'mycroft/register_skill')
157 register = rospy.ServiceProxy(
'mycroft/register_skill', MycroftSkill)
158 response = register(skill)
159 return response.initialised
160 except rospy.ServiceException:
161 rospy.loginfo(
"Service call failed")
164 if len(response.entities) > 0:
165 response.entities = dict([(entity.entity, entity.value)
for entity
in response.entities])
167 response.entities = {}
168 intent_func = self.registered_intents.get(response.intent_name,
None)
169 if intent_func
is not None:
170 intent_func(response)
174 client.wait_for_server()
175 goal = GetResponseGoal(self.
path, dialog)
176 client.send_goal(goal)
177 client.wait_for_result()
178 result = client.get_result()
179 return result.response
183 client.wait_for_server()
184 goal = GetResponseGoal(self.
path, dialog)
185 client.send_goal(goal)
186 client.wait_for_result()
187 result = client.get_result()
188 return result.response
191 self.remove_skill.publish(self.
path)
def handle_intent(self, data)
def ask_yesno(self, dialog)
def optionally(self, entity_type, attribute_name=None)
def intent_file(self, intent_file)
def _handle_intent(self, response)
def register_skill(mycroft_skill)
def register_callback(self, intent_name, func)
def buildAndRegister(self)
def __init__(self, intents={})
def register_intent_file(self, intent_file, callback)
def get_response(self, dialog)
def remove_callback(self, intent_name)
def register_intent(self, intent_parser, callback)
def _register_skill(self, skill)
def __init__(self, path="")
def register_entity_file(self, entity_file)
def get_response(skill_path, dialog, client=None)
def __init__(self, intent_name)
def require(self, entity_type, attribute_name=None)
def ask_yesno(skill_path, dialog, client=None)
def register_callbacks(self, intents)