Skip to content

Commit a62822d

Browse files
committed
Add fast select
1 parent 9bb93d5 commit a62822d

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

drv_brain/launch/includes/drv_v2_host.launch.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@
6666

6767
<!-- Initialize user selection service -->
6868
<node ns="$(arg vision_namespace)" name="drv_user" pkg="drv_user" type="drv_user.py" output="screen">
69+
<!-- If true, will select the target if only 1 candidate present -->
70+
<param name="fast_select" value="true" />
6971
</node>
7072

7173
<!-- Initialize color recognize service, this is used as a simplified object recognizer -->

drv_user/src/drv_user.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,40 @@
1212
# This is used for getting selection here and in JARVIS
1313
param_vision_search_param_lock = '/vision/select/param/lock'
1414

15+
# If true, will select the target if only 1 candidate present
16+
fast_select = True
17+
1518

1619
def handle_user_select(req):
1720
param_control_target_is_set = '/comm/param/control/target/is_set'
1821
param_control_user_selected = '/comm/param/control/target/selected'
1922

23+
rsp = user_selectResponse()
24+
select_msg = String()
25+
2026
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+
2135
selected = -1
2236

2337
info = "Please choose the one you want, if no target, enter 0."
2438
print info
2539
info_msg = String()
2640
info_msg.data = "CHOOSE"
27-
pubInfo.publish(info_msg)
41+
pubInfo.publish(info_msg) # Send this msg to APP for display info
2842

29-
# broadcast the target select request
43+
# Broadcast the target select request
3044
sr_msg = UInt32()
3145
sr_msg.data = num
3246
pubSR.publish(sr_msg)
3347

3448
rospy.set_param(param_vision_search_param_lock, False) # unlock param change
35-
select_msg = String()
3649
while selected < 0:
3750
if rospy.has_param(param_control_target_is_set):
3851
if not rospy.get_param(param_control_target_is_set):
@@ -53,7 +66,6 @@ def handle_user_select(req):
5366
else:
5467
selected = -1
5568

56-
rsp = user_selectResponse()
5769
rsp.selected_id = int(selected)
5870
# Reset the select parameter for next selection
5971
rospy.set_param(param_control_user_selected, -1)
@@ -65,6 +77,8 @@ def handle_user_select(req):
6577
def user_select_server():
6678
rospy.init_node('user_select_server')
6779
s = rospy.Service('drv_user', user_select, handle_user_select)
80+
global fast_select
81+
fast_select = rospy.get_param('fast_select', True)
6882
rospy.set_param(param_vision_search_param_lock, True) # at beginning set param change locked
6983
print "Ready to receive user selection."
7084
rospy.spin()

0 commit comments

Comments
 (0)