Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 import os
00036
00037 from python_qt_binding import loadUi
00038 from python_qt_binding.QtGui import QIcon
00039 from python_qt_binding.QtWidgets import QLineEdit, QWidget
00040 import rospy
00041
00042 from rqt_launch.name_surrogate import NamesSurrogate
00043
00044
00045 class NodeWidget(QWidget):
00046 '''
00047 Works as a proxy between ROS Node
00048 (more in particular, roslaunch.nodeprocess) and GUI.
00049 '''
00050
00051 __slots__ = ['_run_id', 'master_uri', 'config', '_process']
00052
00053 def __init__(self, rospack, master_uri, launch_config,
00054 label_status):
00055 '''
00056 @type launch_node: roslaunch.core.Node
00057 @type launch_config: roslaunch.core.Config
00058 @type label_status: StatusIndicator
00059 '''
00060 super(NodeWidget, self).__init__()
00061 self._rospack = rospack
00062 self._master_uri = master_uri
00063 self._launch_config = launch_config
00064
00065 ui_file = os.path.join(self._rospack.get_path('rqt_launch'),
00066 'resource', 'node_widget.ui')
00067 loadUi(ui_file, self)
00068
00069 self.label_status = label_status
00070
00071
00072 self._respawn_toggle.setChecked(self._launch_config.respawn)
00073 self._lineEdit_launch_args = QLineEdit(
00074 self._launch_config.launch_prefix)
00075
00076 rospy.logdebug('_proxy.conf.namespace={} launch_config={}'.format(
00077 self._launch_config.namespace, self._launch_config.name))
00078 self._resolved_node_name = NamesSurrogate.ns_join(
00079 self._launch_config.namespace, self._launch_config.name)
00080 self._label_nodename.setText(self._get_node_name())
00081 self._label_pkg_name.setText(self._launch_config.package)
00082 self._label_name_executable.setText(self._launch_config.type)
00083
00084 self._icon_node_start = QIcon.fromTheme('media-playback-start')
00085 self._icon_node_stop = QIcon.fromTheme('media-playback-stop')
00086 self._icon_respawn_toggle = QIcon.fromTheme('view-refresh')
00087
00088 self._pushbutton_start_stop_node.setIcon(self._icon_node_start)
00089 self._respawn_toggle.setIcon(self._icon_respawn_toggle)
00090
00091 self._node_controller = None
00092
00093 def _get_node_name(self):
00094 return self._resolved_node_name
00095
00096 def connect_start_stop_button(self, slot):
00097 self._pushbutton_start_stop_node.toggled.connect(slot)
00098
00099 def set_node_started(self, is_started=True):
00100
00101 is_node_running = self._node_controller.is_node_running()
00102 rospy.logdebug('NodeWidget.set_node_started running?={}'.format(
00103 is_node_running))
00104
00105 if is_started:
00106
00107 self._pushbutton_start_stop_node.setIcon(self._icon_node_start)
00108 self._pushbutton_start_stop_node.setDown(False)
00109
00110
00111 else:
00112
00113 self._pushbutton_start_stop_node.setIcon(self._icon_node_stop)
00114 self._pushbutton_start_stop_node.setDown(True)
00115
00116 def set_node_controller(self, node_controller):
00117
00118 self._node_controller = node_controller
00119
00120