21 from prbt_hardware_support.msg
import OperationModes
22 from python_qt_binding
import loadUi
23 from python_qt_binding.QtGui
import QPixmap
24 from python_qt_binding.QtWidgets
import QWidget
32 """Initializes the widget. Widget content will be loaded from 33 `PilzStatusIndicatorRqt.ui`. 35 :param serial_number: A serial number to differentiate multiple 36 instances of the same widget.""" 37 super(PilzStatusIndicatorWidget, self).
__init__()
38 ui_file = os.path.join(rospkg.RosPack().get_path(
39 'pilz_status_indicator_rqt'),
'resource',
'PilzStatusIndicatorRqt.ui')
41 self.setObjectName(
'PilzStatusIndicatorRqtUi')
44 assert self.labelROS,
"ROS label must be loaded from ui file" 45 assert self.labelHW,
"HW label must be loaded from ui file" 46 assert self.labelOM,
"OM label must be loaded from ui file" 47 assert self.labelOM_text,
"OM text label must be loaded from ui file" 48 assert self.barSpeed,
"barSpeed must be loaded from ui file" 51 self.labelOM.setScaledContents(
True)
56 self.windowTitle() + (
' (%d)' % serial_number))
60 label.setStyleSheet(
"QLabel { background-color: %s }" % GREEN)
62 label.setStyleSheet(
"QLabel { background-color: %s }" % RED)
65 """Sets the HW status to be displayed in the widget, using 68 :param status: The status to set: 69 False will be red, True will be green.""" 73 """Sets the HW status to be displayed in the widget, using 76 :param status: The status to set: 77 False will be red, True will be green.""" 81 """Sets the operation mode to be displayed in the widget, influencing 82 both the shown image and the text beneath it. 84 :param mode: The mode to be set of type 85 `prbt_hardware_support.msg.OperationModes`. 86 :param _qpixmap_class: (Internal use only)""" 87 if mode == OperationModes.AUTO:
89 elif mode == OperationModes.T1:
91 elif mode == OperationModes.T2:
95 icon_path = os.path.join(rospkg.RosPack().get_path(
96 'pilz_status_indicator_rqt'),
'resource', icon_name +
'.png')
97 pixmap = _qpixmap_class(icon_path)
98 self.labelOM.setPixmap(pixmap)
99 self.labelOM_text.setText(icon_name.capitalize())
102 """Sets the speed override to be displayed in the widget, influencing 103 the progress bar and the textual percentage within it. 105 :param val: The speed override as a value between 0 and 1.""" 106 if val > 1
or val < 0:
108 "expecting speed value between 0 and 1, got {} !".format(val))
113 self.barSpeed.setValue(100. * val)