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, QLineEdit, QWidget
00039 import rospy
00040
00041 from rqt_launch.name_surrogate import NamesSurrogate
00042
00043
00044 class NodeWidget(QWidget):
00045 '''
00046 Works as a proxy between ROS Node
00047 (more in particular, roslaunch.nodeprocess) and GUI.
00048 '''
00049
00050 __slots__ = ['_run_id', 'master_uri', 'config', '_process']
00051
00052 def __init__(self, rospack, master_uri, launch_config,
00053 label_status):
00054 '''
00055 @type launch_node: roslaunch.core.Node
00056 @type launch_config: roslaunch.core.Config
00057 @type label_status: StatusIndicator
00058 '''
00059 super(NodeWidget, self).__init__()
00060 self._rospack = rospack
00061 self._master_uri = master_uri
00062 self._launch_config = launch_config
00063
00064 ui_file = os.path.join(self._rospack.get_path('rqt_launch'),
00065 'resource', 'node_widget.ui')
00066 loadUi(ui_file, self)
00067
00068 self.label_status = label_status
00069
00070
00071 self._respawn_toggle.setChecked(self._launch_config.respawn)
00072 self._lineEdit_launch_args = QLineEdit(
00073 self._launch_config.launch_prefix)
00074
00075 rospy.logdebug('_proxy.conf.namespace={} launch_config={}'.format(
00076 self._launch_config.namespace, self._launch_config.name))
00077 self._resolved_node_name = NamesSurrogate.ns_join(
00078 self._launch_config.namespace, self._launch_config.name)
00079 self._label_nodename.setText(self._get_node_name())
00080 self._label_pkg_name.setText(self._launch_config.package)
00081 self._label_name_executable.setText(self._launch_config.type)
00082
00083 self._icon_node_start = QIcon.fromTheme('media-playback-start')
00084 self._icon_node_stop = QIcon.fromTheme('media-playback-stop')
00085 self._icon_respawn_toggle = QIcon.fromTheme('view-refresh')
00086
00087 self._pushbutton_start_stop_node.setIcon(self._icon_node_start)
00088 self._respawn_toggle.setIcon(self._icon_respawn_toggle)
00089
00090 self._node_controller = None
00091
00092 def _get_node_name(self):
00093 return self._resolved_node_name
00094
00095 def connect_start_stop_button(self, slot):
00096 self._pushbutton_start_stop_node.toggled.connect(slot)
00097
00098 def set_node_started(self, is_started=True):
00099
00100 is_node_running = self._node_controller.is_node_running()
00101 rospy.logdebug('NodeWidget.set_node_started running?={}'.format(
00102 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