Further work. Robot scanning works

This commit is contained in:
Olek Bojda 2018-09-18 21:37:01 +02:00
parent 4f36a75249
commit fde26247f3
3 changed files with 36 additions and 3 deletions

View File

@ -10,6 +10,7 @@ class QtWrapper:
def __init__(self,widget): def __init__(self,widget):
self.widget = widget self.widget = widget
self.logger_counter = 0 self.logger_counter = 0
self.displayed_robots_id_list = []
def connect_robot_signals(self): def connect_robot_signals(self):
raise NotImplementedError raise NotImplementedError
@ -55,7 +56,38 @@ class QtWrapper:
def update_robots_list_gui(self,robots_id_list): def update_robots_list_gui(self,robots_id_list):
robots_id_list.sort() robots_id_list.sort()
id_strings_list = (('PIONIER'+str(x)) for x in robots_id_list) 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): def update_selected_robot_info(self,robot_info):

View File

@ -137,7 +137,7 @@ class ROSWrapper:
pass pass
else: else:
robot_number = topic.split('/') robot_number = topic.split('/')
robot_number = robot_number[1] robot_number = robot_number[2]
robot_number = robot_number[7:] robot_number = robot_number[7:]
if len(robot_number) > 0: if len(robot_number) > 0:
robot_number = int(robot_number) robot_number = int(robot_number)

View File

@ -42,7 +42,7 @@ class UserPlugin(Plugin):
self._qt_wrapper.connect_signals() self._qt_wrapper.connect_signals()
self._ros_wrapper.set_robots_list_update_callback(self.handle_robots_list_update) 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): def shutdown_plugin(self):
self._ros_wrapper.unregister_node() self._ros_wrapper.unregister_node()
@ -178,6 +178,7 @@ class UserPlugin(Plugin):
self._user_info.release_robot() self._user_info.release_robot()
def connection_to_robot_lost(self,lost_robot_id): def connection_to_robot_lost(self,lost_robot_id):
# pass
self._ros_wrapper.release_robot() self._ros_wrapper.release_robot()
self._user_info.release_robot() self._user_info.release_robot()
self._qt_wrapper.connection_to_robot_lost(lost_robot_id) self._qt_wrapper.connection_to_robot_lost(lost_robot_id)