Further work. Robot scanning works
This commit is contained in:
parent
4f36a75249
commit
fde26247f3
@ -10,6 +10,7 @@ class QtWrapper:
|
||||
def __init__(self,widget):
|
||||
self.widget = widget
|
||||
self.logger_counter = 0
|
||||
self.displayed_robots_id_list = []
|
||||
|
||||
def connect_robot_signals(self):
|
||||
raise NotImplementedError
|
||||
@ -55,7 +56,38 @@ class QtWrapper:
|
||||
def update_robots_list_gui(self,robots_id_list):
|
||||
robots_id_list.sort()
|
||||
id_strings_list = (('PIONIER'+str(x)) for x in robots_id_list)
|
||||
self.widget.robotsList.addItems(id_strings_list)
|
||||
|
||||
robots_to_add = []
|
||||
robots_to_remove = []
|
||||
|
||||
for robot_id in robots_id_list:
|
||||
if robot_id not in self.displayed_robots_id_list:
|
||||
robots_to_add.append(robot_id)
|
||||
|
||||
for robot_id in self.displayed_robots_id_list:
|
||||
if robot_id not in robots_id_list:
|
||||
robots_to_remove.append(robot_id)
|
||||
|
||||
for robot_id in robots_to_remove:
|
||||
self.remove_robot_from_list(robot_id)
|
||||
|
||||
for robot_id in robots_to_add:
|
||||
self.add_robot_to_list(robot_id)
|
||||
|
||||
|
||||
def remove_robot_from_list(self,robot_id):
|
||||
count = self.widget.robotsList.count()
|
||||
|
||||
for i in range(count):
|
||||
if str(robot_id) in self.widget.robotsList.itemText(i):
|
||||
self.widget.robotsList.removeItem(i)
|
||||
self.displayed_robots_id_list.remove(robot_id)
|
||||
return
|
||||
|
||||
|
||||
def add_robot_to_list(self,robot_id):
|
||||
self.widget.robotsList.addItem('PIONIER'+str(robot_id))
|
||||
self.displayed_robots_id_list.append(robot_id)
|
||||
|
||||
|
||||
def update_selected_robot_info(self,robot_info):
|
||||
|
@ -137,7 +137,7 @@ class ROSWrapper:
|
||||
pass
|
||||
else:
|
||||
robot_number = topic.split('/')
|
||||
robot_number = robot_number[1]
|
||||
robot_number = robot_number[2]
|
||||
robot_number = robot_number[7:]
|
||||
if len(robot_number) > 0:
|
||||
robot_number = int(robot_number)
|
||||
|
@ -42,7 +42,7 @@ class UserPlugin(Plugin):
|
||||
self._qt_wrapper.connect_signals()
|
||||
self._ros_wrapper.set_robots_list_update_callback(self.handle_robots_list_update)
|
||||
|
||||
self._qt_wrapper.update_robots_list_gui([5,6,2])
|
||||
# self._qt_wrapper.update_robots_list_gui([5,6,2])
|
||||
|
||||
def shutdown_plugin(self):
|
||||
self._ros_wrapper.unregister_node()
|
||||
@ -178,6 +178,7 @@ class UserPlugin(Plugin):
|
||||
self._user_info.release_robot()
|
||||
|
||||
def connection_to_robot_lost(self,lost_robot_id):
|
||||
# pass
|
||||
self._ros_wrapper.release_robot()
|
||||
self._user_info.release_robot()
|
||||
self._qt_wrapper.connection_to_robot_lost(lost_robot_id)
|
||||
|
Loading…
Reference in New Issue
Block a user