From 7ab03542d3c5903a4088121a4d2eaae5010bb41c Mon Sep 17 00:00:00 2001 From: Olek Bojda Date: Tue, 18 Sep 2018 18:11:39 +0200 Subject: [PATCH] Added initial GUI view --- safety_user_plugin/scripts/qt_wrapper.py | 30 +- safety_user_plugin/scripts/ros_wrapper.py | 4 +- safety_user_plugin/scripts/user_plugin.py | 15 +- safety_user_plugin/ui/user_view.ui | 364 ++++++++++++++++++++-- 4 files changed, 372 insertions(+), 41 deletions(-) diff --git a/safety_user_plugin/scripts/qt_wrapper.py b/safety_user_plugin/scripts/qt_wrapper.py index e4b6875..239631c 100644 --- a/safety_user_plugin/scripts/qt_wrapper.py +++ b/safety_user_plugin/scripts/qt_wrapper.py @@ -3,6 +3,8 @@ import os import rospy import rospkg +from python_qt_binding.QtGui import QPalette +from python_qt_binding.QtWidgets import QPushButton # from python_qt_binding.QtWidgets import QWidget, QDialog class QtWrapper: @@ -10,12 +12,26 @@ class QtWrapper: def __init__(self,widget): self.widget = widget - - self.widget.textBrowser.setText('Sukces') + # self.widget.setStyleSheet("background-color:black;") + # self.widget.setBackgroundRole(QPalette.Button) + # self.widget.setStyleSheet("QPushButton { background-color: yellow }") + self.widget.logsBrowser.setText('Sukces') def connect_signals(self): + # self.widget.openButton.clicked.connect(self.handle_openButton_clicked) + self.widget.clutchButton.clicked.connect(self.handle_clutchButton_clicked) + + def set_robot_selection_callback(self,callback): + # self.handle_openButton_clicked = callback pass + def set_user_stop_state_updated_callback(self,callback): + # raise NotImplementedError + pass + + def set_clutch_switched_callback(self,callback): + self.handle_clutchButton_clicked = callback + def select_robot(self,robot_id): raise NotImplementedError @@ -54,17 +70,7 @@ class QtWrapper: raise NotImplementedError - def set_robot_selection_callback(self,callback): - # raise NotImplementedError - pass - def set_user_stop_state_updated_callback(self,callback): - # raise NotImplementedError - pass - - def set_clutch_switched_callback(self,callback): - # raise NotImplementedError - pass def connection_to_robot_lost(self,lost_robot_id): raise NotImplementedError \ No newline at end of file diff --git a/safety_user_plugin/scripts/ros_wrapper.py b/safety_user_plugin/scripts/ros_wrapper.py index 833a2b1..051e2a9 100644 --- a/safety_user_plugin/scripts/ros_wrapper.py +++ b/safety_user_plugin/scripts/ros_wrapper.py @@ -36,8 +36,6 @@ class ROSWrapper: self.robots_list_timer = None self.connection_timer = None - self.setup_subscribers_and_publishers(6) - def setup_node(self): rospy.init_node('safety_user_plugin', anonymous=True) @@ -87,7 +85,7 @@ class ROSWrapper: raise NotImplementedError def handle_robot_connection_lost(self,event): - shutdown_timer(self.connection_timer) + self.shutdown_timer(self.connection_timer) self.robot_connection_lost_callback() def cancel_subscribers_and_publishers(self): diff --git a/safety_user_plugin/scripts/user_plugin.py b/safety_user_plugin/scripts/user_plugin.py index e5720df..b50c579 100755 --- a/safety_user_plugin/scripts/user_plugin.py +++ b/safety_user_plugin/scripts/user_plugin.py @@ -12,11 +12,15 @@ from user_info import UserInfo from enums.clutch_state import ClutchState as CS from enums.stop_state import StopState as SS + + class UserPlugin(Plugin): def __init__(self,context): super(UserPlugin, self).__init__(context) self.setObjectName('User Plugin - L1.5 safety system') + # setStyleSheet("background-color:black;") + self._widget = UserWidget(context) self._qt_wrapper = QtWrapper(self._widget) @@ -35,7 +39,7 @@ class UserPlugin(Plugin): self.set_callback_functions() # At the end! - # self._qt_wrapper.connect_signals() + self._qt_wrapper.connect_signals() self._ros_wrapper.set_robots_list_update_callback(self.handle_robots_list_update) def shutdown_plugin(self): @@ -125,9 +129,12 @@ class UserPlugin(Plugin): raise NotImplementedError def handle_robot_connection_lost(self): - lost_robot_id = self._user_info.selected_robot.robot_id - self.release_robot() - self._qt_wrapper.connection_to_robot_lost(lost_robot_id) + if self._user_info.selected_robot != None: + lost_robot_id = self._user_info.selected_robot.robot_id + self.release_robot() + self._qt_wrapper.connection_to_robot_lost(lost_robot_id) + else: + raise NotImplementedError # Operations diff --git a/safety_user_plugin/ui/user_view.ui b/safety_user_plugin/ui/user_view.ui index 2fc1dd8..9755a81 100644 --- a/safety_user_plugin/ui/user_view.ui +++ b/safety_user_plugin/ui/user_view.ui @@ -6,33 +6,353 @@ 0 0 - 950 - 798 + 952 + 817 Form - - - - 90 - 50 - 161 - 31 - - - - - - - 50 - 150 - 256 - 192 - - - + + true + + + + + + + + + + + + 0 + 0 + + + + + 0 + 40 + + + + + + + + + 0 + 0 + + + + + 16777215 + 60 + + + + Otwórz + + + + + + + + + Qt::Vertical + + + + 20 + 20 + + + + + + + + + + QLayout::SetDefaultConstraint + + + + + <html><head/><body><p align="center"><span style=" font-weight:600;">ID robota</span></p></body></html> + + + + + + + <html><head/><body><p align="center"><span style=" font-weight:600;">Stan baterii</span></p></body></html> + + + + + + + <html><head/><body><p align="center"><span style=" font-weight:600;">Predkosc liniowa</span></p></body></html> + + + + + + + <html><head/><body><p align="center"><span style=" font-weight:600;">Predkosc obrotowa</span></p></body></html> + + + + + + + <html><head/><body><p align="center"><span style=" font-weight:600;">Stan sprzegla</span></p></body></html> + + + + + + + <html><head/><body><p align="center"><span style=" font-weight:600;">Stan stopu</span></p></body></html> + + + + + + + + + + + <html><head/><body><p align="center">-</p></body></html> + + + + + + + <html><head/><body><p align="center">-</p></body></html> + + + + + + + <html><head/><body><p align="center">-</p></body></html> + + + + + + + <html><head/><body><p align="center">-</p></body></html> + + + + + + + <html><head/><body><p align="center">-</p></body></html> + + + + + + + <html><head/><body><p align="center">-</p></body></html> + + + + + + + + + + + + 100 + 0 + + + + <html><head/><body><p align="center">-</p></body></html> + + + + + + + + 0 + 0 + + + + + 50 + 50 + + + + + + + + + + + + 100 + 0 + + + + <html><head/><body><p align="center">-</p></body></html> + + + + + + + + 100 + 0 + + + + <html><head/><body><p align="center">-</p></body></html> + + + + + + + <html><head/><body><p align="center"><span style=" font-weight:600;">Ograniczenia</span></p></body></html> + + + + + + + + 0 + 0 + + + + + 50 + 50 + + + + + + + + + + + + 0 + 0 + + + + + 50 + 50 + + + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 20 + + + + + + + + + + + 0 + 0 + + + + Zatrzymaj robota + + + + + + + + 0 + 0 + + + + Sprzeglo ON + + + + + + + + + Qt::Vertical + + + + 20 + 20 + + + + + + + + <html><head/><body><p align="center"><span style=" font-weight:600;">Histora komunikatów</span></p></body></html> + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p></body></html> + + + +