1 from distutils.version
import LooseVersion
5 from threading
import Lock
7 import python_qt_binding
8 import python_qt_binding.QtCore
as QtCore
9 from python_qt_binding.QtCore
import QEvent
10 from python_qt_binding.QtCore
import QSize
11 from python_qt_binding.QtCore
import Qt
12 from python_qt_binding.QtCore
import QTimer
13 from python_qt_binding.QtCore
import qWarning
14 from python_qt_binding.QtCore
import Slot
15 import python_qt_binding.QtGui
as QtGui
16 from python_qt_binding.QtGui
import QBrush
17 from python_qt_binding.QtGui
import QColor
18 from python_qt_binding.QtGui
import QFont
19 from python_qt_binding.QtGui
import QIcon
20 from python_qt_binding.QtGui
import QPainter
21 from python_qt_binding.QtGui
import QPen
24 from resource_retriever
import get_filename
27 from std_msgs.msg
import Bool
28 from std_msgs.msg
import Time
29 from std_msgs.msg
import UInt8
31 from image_view2_wrapper
import ComboBoxDialog
33 if LooseVersion(python_qt_binding.QT_BINDING_VERSION).version[0] >= 5:
34 from python_qt_binding.QtWidgets
import QAction
35 from python_qt_binding.QtWidgets
import QComboBox
36 from python_qt_binding.QtWidgets
import QLabel
37 from python_qt_binding.QtWidgets
import QMenu
38 from python_qt_binding.QtWidgets
import QMessageBox
39 from python_qt_binding.QtWidgets
import QSizePolicy
40 from python_qt_binding.QtWidgets
import QWidget
43 from python_qt_binding.QtGui
import QAction
44 from python_qt_binding.QtGui
import QComboBox
45 from python_qt_binding.QtGui
import QLabel
46 from python_qt_binding.QtGui
import QMenu
47 from python_qt_binding.QtGui
import QMessageBox
48 from python_qt_binding.QtGui
import QSizePolicy
49 from python_qt_binding.QtGui
import QWidget
54 rqt plugin to show light like ultra-man's light. 55 It subscribes std_msgs/UInt8 topic and the value means: 61 super(StatusLight, self).
__init__(context)
62 self.setObjectName(
"StatusLight")
64 context.add_widget(self.
_widget)
67 self._widget.save_settings(plugin_settings, instance_settings)
70 self._widget.restore_settings(plugin_settings, instance_settings)
73 self._widget.trigger_configuration()
77 _UNKNOWN_COLOR = QColor(
"#dddddd")
78 _SUCCESS_COLOR = QColor(
"#18FFFF")
79 _WARN_COLOR = QColor(
"#FFCA00")
80 _ERROR_COLOR = QColor(
"#F44336")
83 super(StatusLightWidget, self).
__init__()
89 self._update_topic_timer.timeout.connect(self.
updateTopics)
90 self._update_topic_timer.start(1000)
94 self._update_plot_timer.timeout.connect(self.
redraw)
95 self._update_plot_timer.start(1000 / 15)
111 radius = min(rect.width(), rect.height()) - 100
112 qp.setFont(QFont(
'Helvetica', 100))
113 qp.setPen(QPen(QBrush(color), 50))
116 (rect.width() - radius) / 2, (rect.height() - radius) / 2,
126 need_to_update =
False 127 for (topic, topic_type)
in rospy.get_published_topics():
128 if topic_type ==
"std_msgs/UInt8":
130 self._status_topics.append(topic)
131 need_to_update =
True 134 self._dialog.combo_box.clear()
136 self._dialog.combo_box.addItem(topic)
141 self._dialog.combo_box.setCurrentIndex(
146 self.status_sub.unregister()
147 self.
status_sub = rospy.Subscriber(topic, UInt8,
159 instance_settings.set_value(
"active_topic", self.
_active_topic)
162 if instance_settings.value(
"active_topic"):
163 topic = instance_settings.value(
"active_topic")
164 self._dialog.combo_box.addItem(topic)
def restore_settings(self, plugin_settings, instance_settings)
def __init__(self, context)
def trigger_configuration(self)
def save_settings(self, plugin_settings, instance_settings)