12
12
# This is used for getting selection here and in JARVIS
13
13
param_vision_search_param_lock = '/vision/select/param/lock'
14
14
15
+ # If true, will select the target if only 1 candidate present
16
+ fast_select = True
17
+
15
18
16
19
def handle_user_select (req ):
17
20
param_control_target_is_set = '/comm/param/control/target/is_set'
18
21
param_control_user_selected = '/comm/param/control/target/selected'
19
22
23
+ rsp = user_selectResponse ()
24
+ select_msg = String ()
25
+
20
26
num = req .select_num
27
+
28
+ if num == 1 and fast_select :
29
+ rsp .selected_id = 1
30
+ select_msg .data = 'Auto selected target No.1.'
31
+ print select_msg .data
32
+ pubInfo .publish (select_msg )
33
+ return rsp
34
+
21
35
selected = - 1
22
36
23
37
info = "Please choose the one you want, if no target, enter 0."
24
38
print info
25
39
info_msg = String ()
26
40
info_msg .data = "CHOOSE"
27
- pubInfo .publish (info_msg )
41
+ pubInfo .publish (info_msg ) # Send this msg to APP for display info
28
42
29
- # broadcast the target select request
43
+ # Broadcast the target select request
30
44
sr_msg = UInt32 ()
31
45
sr_msg .data = num
32
46
pubSR .publish (sr_msg )
33
47
34
48
rospy .set_param (param_vision_search_param_lock , False ) # unlock param change
35
- select_msg = String ()
36
49
while selected < 0 :
37
50
if rospy .has_param (param_control_target_is_set ):
38
51
if not rospy .get_param (param_control_target_is_set ):
@@ -53,7 +66,6 @@ def handle_user_select(req):
53
66
else :
54
67
selected = - 1
55
68
56
- rsp = user_selectResponse ()
57
69
rsp .selected_id = int (selected )
58
70
# Reset the select parameter for next selection
59
71
rospy .set_param (param_control_user_selected , - 1 )
@@ -65,6 +77,8 @@ def handle_user_select(req):
65
77
def user_select_server ():
66
78
rospy .init_node ('user_select_server' )
67
79
s = rospy .Service ('drv_user' , user_select , handle_user_select )
80
+ global fast_select
81
+ fast_select = rospy .get_param ('fast_select' , True )
68
82
rospy .set_param (param_vision_search_param_lock , True ) # at beginning set param change locked
69
83
print "Ready to receive user selection."
70
84
rospy .spin ()
0 commit comments