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 '''
00048 Works as a proxy between ROS Node
00049 (more in particular, roslaunch.nodeprocess) and GUI.
00050 '''
00051
00052 __slots__ = ['_run_id', 'master_uri', 'config', '_process']
00053
00054 def __init__(self, rospack, master_uri, launch_config,
00055 label_status):
00056 '''
00057 @type launch_node: roslaunch.core.Node
00058 @type launch_config: roslaunch.core.Config
00059 @type label_status: StatusIndicator
00060 '''
00061 super(NodeWidget, self).__init__()
00062 self._rospack = rospack
00063 self._master_uri = master_uri
00064 self._launch_config = launch_config
00065
00066 ui_file = os.path.join(self._rospack.get_path('rqt_launch'),
00067 'resource', 'node_widget.ui')
00068 loadUi(ui_file, self)
00069
00070 self.label_status = label_status
00071
00072
00073 self._respawn_toggle.setChecked(self._launch_config.respawn)
00074 self._lineEdit_launch_args = QLineEdit(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(is_node_running))
00103
00104 if is_started:
00105
00106 self._pushbutton_start_stop_node.setIcon(self._icon_node_start)
00107 self._pushbutton_start_stop_node.setDown(False)
00108
00109
00110 else:
00111
00112 self._pushbutton_start_stop_node.setIcon(self._icon_node_stop)
00113 self._pushbutton_start_stop_node.setDown(True)
00114
00115 def set_node_controller(self, node_controller):
00116
00117 self._node_controller = node_controller
00118
00119