Added initial GUI view

This commit is contained in:
Olek Bojda 2018-09-18 18:11:39 +02:00
parent 388759b8aa
commit 7ab03542d3
4 changed files with 372 additions and 41 deletions

View File

@ -3,6 +3,8 @@ import os
import rospy import rospy
import rospkg import rospkg
from python_qt_binding.QtGui import QPalette
from python_qt_binding.QtWidgets import QPushButton
# from python_qt_binding.QtWidgets import QWidget, QDialog # from python_qt_binding.QtWidgets import QWidget, QDialog
class QtWrapper: class QtWrapper:
@ -10,12 +12,26 @@ class QtWrapper:
def __init__(self,widget): def __init__(self,widget):
self.widget = widget self.widget = widget
# self.widget.setStyleSheet("background-color:black;")
self.widget.textBrowser.setText('Sukces') # self.widget.setBackgroundRole(QPalette.Button)
# self.widget.setStyleSheet("QPushButton { background-color: yellow }")
self.widget.logsBrowser.setText('Sukces')
def connect_signals(self): 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 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): def select_robot(self,robot_id):
raise NotImplementedError raise NotImplementedError
@ -54,17 +70,7 @@ class QtWrapper:
raise NotImplementedError 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): def connection_to_robot_lost(self,lost_robot_id):
raise NotImplementedError raise NotImplementedError

View File

@ -36,8 +36,6 @@ class ROSWrapper:
self.robots_list_timer = None self.robots_list_timer = None
self.connection_timer = None self.connection_timer = None
self.setup_subscribers_and_publishers(6)
def setup_node(self): def setup_node(self):
rospy.init_node('safety_user_plugin', anonymous=True) rospy.init_node('safety_user_plugin', anonymous=True)
@ -87,7 +85,7 @@ class ROSWrapper:
raise NotImplementedError raise NotImplementedError
def handle_robot_connection_lost(self,event): def handle_robot_connection_lost(self,event):
shutdown_timer(self.connection_timer) self.shutdown_timer(self.connection_timer)
self.robot_connection_lost_callback() self.robot_connection_lost_callback()
def cancel_subscribers_and_publishers(self): def cancel_subscribers_and_publishers(self):

View File

@ -12,11 +12,15 @@ from user_info import UserInfo
from enums.clutch_state import ClutchState as CS from enums.clutch_state import ClutchState as CS
from enums.stop_state import StopState as SS from enums.stop_state import StopState as SS
class UserPlugin(Plugin): class UserPlugin(Plugin):
def __init__(self,context): def __init__(self,context):
super(UserPlugin, self).__init__(context) super(UserPlugin, self).__init__(context)
self.setObjectName('User Plugin - L1.5 safety system') self.setObjectName('User Plugin - L1.5 safety system')
# setStyleSheet("background-color:black;")
self._widget = UserWidget(context) self._widget = UserWidget(context)
self._qt_wrapper = QtWrapper(self._widget) self._qt_wrapper = QtWrapper(self._widget)
@ -35,7 +39,7 @@ class UserPlugin(Plugin):
self.set_callback_functions() self.set_callback_functions()
# At the end! # 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) self._ros_wrapper.set_robots_list_update_callback(self.handle_robots_list_update)
def shutdown_plugin(self): def shutdown_plugin(self):
@ -125,9 +129,12 @@ class UserPlugin(Plugin):
raise NotImplementedError raise NotImplementedError
def handle_robot_connection_lost(self): def handle_robot_connection_lost(self):
lost_robot_id = self._user_info.selected_robot.robot_id if self._user_info.selected_robot != None:
self.release_robot() lost_robot_id = self._user_info.selected_robot.robot_id
self._qt_wrapper.connection_to_robot_lost(lost_robot_id) self.release_robot()
self._qt_wrapper.connection_to_robot_lost(lost_robot_id)
else:
raise NotImplementedError
# Operations # Operations

View File

@ -6,33 +6,353 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>950</width> <width>952</width>
<height>798</height> <height>817</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Form</string> <string>Form</string>
</property> </property>
<widget class="QComboBox" name="comboBox"> <property name="autoFillBackground">
<property name="geometry"> <bool>true</bool>
<rect> </property>
<x>90</x> <property name="styleSheet">
<y>50</y> <string notr="true"/>
<width>161</width> </property>
<height>31</height> <layout class="QVBoxLayout" name="verticalLayout_3" stretch="3,0,1,0,3,0,0,2">
</rect> <item>
</property> <layout class="QHBoxLayout" name="horizontalLayout" stretch="2,1">
</widget> <item>
<widget class="QTextBrowser" name="textBrowser"> <widget class="QComboBox" name="robotsList">
<property name="geometry"> <property name="sizePolicy">
<rect> <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<x>50</x> <horstretch>0</horstretch>
<y>150</y> <verstretch>0</verstretch>
<width>256</width> </sizepolicy>
<height>192</height> </property>
</rect> <property name="minimumSize">
</property> <size>
</widget> <width>0</width>
<height>40</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="openButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>60</height>
</size>
</property>
<property name="text">
<string>Otwórz</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="4,2,3">
<item>
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,0,0,0,0">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;ID robota&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Stan baterii&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_7">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Predkosc liniowa&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_8">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Predkosc obrotowa&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_9">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Stan sprzegla&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_10">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Stan stopu&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="idLabel">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;-&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="batteryLabel">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;-&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="linearLabel">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;-&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="angularLabel">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;-&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="clutchLabel">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;-&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="stateLabel">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;-&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="1">
<widget class="QLabel" name="distanceLabel">
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;-&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QGraphicsView" name="distanceGraphics">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="linearRestrictionLabel">
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;-&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="angularRestrictionLabel">
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;-&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="label_12">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Ograniczenia&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QGraphicsView" name="angularGrpahics">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QGraphicsView" name="linearGraphics">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3" stretch="2,1">
<item>
<widget class="QPushButton" name="stopButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Zatrzymaj robota</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="clutchButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Sprzeglo ON</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Histora komunikatów&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QTextBrowser" name="logsBrowser">
<property name="html">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
</layout>
</widget> </widget>
<resources/> <resources/>
<connections/> <connections/>