diff --git a/consai_ros2/consai_visualizer/resource/visualizer.ui b/consai_ros2/consai_visualizer/resource/visualizer.ui index a02a3d780..3f50a49ef 100644 --- a/consai_ros2/consai_visualizer/resource/visualizer.ui +++ b/consai_ros2/consai_visualizer/resource/visualizer.ui @@ -39,7 +39,7 @@ - Connection + ping Qt::AlignCenter @@ -49,7 +49,7 @@ - Battery + 電圧 Qt::AlignCenter @@ -59,7 +59,7 @@ - Error + リターン Qt::AlignCenter @@ -95,24 +95,24 @@ - ConnectionStatus + - Qt::AlignCenter - + - TextLabel + - - - + + - TextLabel + - @@ -145,21 +145,21 @@ - ConnectionStatus + - - + - TextLabel + - - - + + - TextLabel + - @@ -183,7 +183,7 @@ - + @@ -192,21 +192,21 @@ - ConnectionStatus + - - + - TextLabel + - - - + + - TextLabel + - @@ -227,7 +227,7 @@ - + @@ -236,21 +236,21 @@ - ConnectionStatus + - - + - TextLabel + - - - + + - TextLabel + - @@ -280,21 +280,21 @@ - ConnectionStatus + - - + - TextLabel + - - - + + - TextLabel + - @@ -324,21 +324,21 @@ - ConnectionStatus + - - + - TextLabel + - - - + + - TextLabel + - @@ -368,21 +368,21 @@ - ConnectionStatus + - - + - TextLabel + - - - + + - TextLabel + - @@ -412,21 +412,21 @@ - ConnectionStatus + - - + - TextLabel + - - - + + - TextLabel + - @@ -456,21 +456,21 @@ - ConnectionStatus + - - + - TextLabel + - - - + + - TextLabel + - @@ -500,21 +500,21 @@ - ConnectionStatus + - - + - TextLabel + - - - + + - TextLabel + - @@ -544,21 +544,21 @@ - ConnectionStatus + - - + - TextLabel + - - - + + - TextLabel + - @@ -588,21 +588,21 @@ - ConnectionStatus + - - + - TextLabel + - - - + + - TextLabel + - diff --git a/consai_ros2/consai_visualizer/src/consai_visualizer/visualizer.py b/consai_ros2/consai_visualizer/src/consai_visualizer/visualizer.py index 844c47798..bab03681e 100644 --- a/consai_ros2/consai_visualizer/src/consai_visualizer/visualizer.py +++ b/consai_ros2/consai_visualizer/src/consai_visualizer/visualizer.py @@ -28,7 +28,7 @@ from crane_visualization_interfaces.msg import ObjectsArray from python_qt_binding import loadUi from python_qt_binding.QtCore import QPointF, Qt, QTimer -from python_qt_binding.QtWidgets import QTreeWidgetItem, QWidget +from python_qt_binding.QtWidgets import QTreeWidgetItem, QWidget, QFrame from qt_gui.plugin import Plugin import rclpy from robocup_ssl_msgs.msg import BallReplacement, Replacement, RobotReplacement @@ -125,7 +125,7 @@ def __init__(self, context): self._reset_timer.timeout.connect(self._update_robot_synthetics) self._reset_timer.start(1000) - self.latest_battery_voltage = [0] * 16 + self.latest_battery_voltage = [-1] * 16 # self._widget.pushButton.clicked.connect(self.publish) self._widget.session_injection_comboBox.addItem("simple_ai") @@ -179,6 +179,8 @@ def _session_injection(self): self._pub_session_injection.publish(msg) def _callback_feedback(self, msg): + self.latest_return_counter = [-1] * 16 + self.latest_battery_voltage = [-1] * 16 for feedback in msg.feedback: try: self.latest_battery_voltage[feedback.robot_id] = feedback.voltage[0] @@ -186,6 +188,10 @@ def _callback_feedback(self, msg): except AttributeError: # 初期化より先にコールバックが呼ばれてしまうことがあるため、エラーを回避する pass + try: + self.latest_return_counter[feedback.robot_id] = feedback.counter + except AttributeError: + pass # for synthetics def _callback_ping(self, msg): @@ -335,12 +341,19 @@ def _update_robot_synthetics(self): for i in range(16): # 電圧 try: - getattr(self._widget, f"robot{i}_voltage").setText( - "{:.2f}".format(self.latest_battery_voltage[i]) - ) + label = getattr(self._widget, f"robot{i}_voltage") + if self.latest_battery_voltage[i] == -1: + label.setText("-") + label.setLineWidth(0) + else: + label.setText("{:.2f}".format(self.latest_battery_voltage[i])) + label.setLineWidth(1) + label.setFrameStyle(QFrame.Box | QFrame.Plain) except AttributeError: try: - getattr(self._widget, f"robot{i}_voltage").setText(str(0.0)) + label = getattr(self._widget, f"robot{i}_voltage") + label.setText("-") + label.setLineWidth(0) except AttributeError: pass pass @@ -349,14 +362,34 @@ def _update_robot_synthetics(self): try: # 一旦全て"-"で埋める for i in range(12): - getattr(self._widget, f"robot{i}_connection_status").setText("-") + label = getattr(self._widget, f"robot{i}_connection_status") + label.setText("-") + label.setLineWidth(0) for ping_status in self.ping.ping: - getattr( + label = getattr( self._widget, f"robot{ping_status.robot_id}_connection_status" - ).setText("{:.1f}ms".format(ping_status.ping_ms)) + ) + label.setText("{:.1f}ms".format(ping_status.ping_ms)) + label.setLineWidth(1) + label.setFrameStyle(QFrame.Box | QFrame.Plain) except AttributeError: try: - getattr(self._widget, f"robot{i}_connection_status").setText("-") + label = getattr(self._widget, f"robot{i}_connection_status") + label.setText("-") + label.setLineWidth(0) except AttributeError: pass pass + + try: + for i in range(12): + label = getattr(self._widget, f"robot{i}_counter") + if self.latest_return_counter[i] == -1: + label.setText("-") + label.setLineWidth(0) + else: + label.setText(str(self.latest_return_counter[i])) + label.setLineWidth(1) + label.setFrameStyle(QFrame.Box | QFrame.Plain) + except AttributeError: + pass