12
12
13
13
14
14
class Server (AbstractHMIServer ):
15
- def __init__ (self , name : str , context_url : str , require_endpoint : bool , rate : float ):
15
+ def __init__ (
16
+ self , name : str , context_url : str , require_endpoint : bool , rate : float
17
+ ):
16
18
super (Server , self ).__init__ (name )
17
19
18
20
self ._context_url = context_url
19
21
self ._require_endpoint = require_endpoint
20
22
self ._rate = rate
21
23
22
- self ._intent_client = actionlib .SimpleActionClient ("get_intent" , GetIntentAction )
24
+ self ._intent_client = actionlib .SimpleActionClient (
25
+ "get_intent" , GetIntentAction
26
+ )
23
27
rospy .loginfo (f"Waiting for { self ._intent_client .action_client .ns } .." )
24
28
self ._intent_client .wait_for_server ()
25
29
26
- rospy .loginfo (f"Server initialized (context_url={ context_url } , require_endpoint={ require_endpoint } )" )
30
+ rospy .loginfo (
31
+ f"Server initialized (context_url={ context_url } , require_endpoint={ require_endpoint } )"
32
+ )
27
33
28
34
def _determine_answer (self , description , grammar , target , is_preempt_requested ):
29
- self ._intent_client .send_goal (GetIntentGoal (
30
- context_url = self ._context_url ,
31
- require_endpoint = self ._require_endpoint ,
32
- intents = [grammar ]
33
- ))
35
+ self ._intent_client .send_goal (
36
+ GetIntentGoal (
37
+ context_url = self ._context_url ,
38
+ require_endpoint = self ._require_endpoint ,
39
+ intents = [grammar ],
40
+ )
41
+ )
34
42
35
43
r = rospy .Rate (self ._rate )
36
44
while not rospy .is_shutdown ():
@@ -41,9 +49,13 @@ def _determine_answer(self, description, grammar, target, is_preempt_requested):
41
49
42
50
result = self ._intent_client .get_result ()
43
51
if result is not None :
44
- return HMIResult (
45
- semantics = {kv .key : kv .value for kv in result .slots },
46
- sentence = result .intent
47
- ) if result .is_understood else None
52
+ return (
53
+ HMIResult (
54
+ semantics = {kv .key : kv .value for kv in result .slots },
55
+ sentence = result .intent ,
56
+ )
57
+ if result .is_understood
58
+ else None
59
+ )
48
60
49
61
r .sleep ()
0 commit comments