38 from python_qt_binding
import loadUi
39 from python_qt_binding.QtCore
import QModelIndex, Signal
40 from python_qt_binding.QtGui
import QStandardItem, QStandardItemModel
41 from python_qt_binding.QtWidgets
import QDialog
42 from rosgraph
import rosenv
44 from roslaunch.core
import RLException
62 sig_sysmsg = Signal(str)
66 @type parent: LaunchMain 79 ui_file = os.path.join(self._rospack.get_path(
'rqt_launch'),
80 'resource',
'launch_widget.ui')
86 master_uri = rosenv.get_master_uri()
87 rospy.loginfo(
'LaunchWidget master_uri={}'.format(master_uri))
91 self._treeview.setItemDelegate(self.
_delegate)
96 self._pushbutton_load_params.clicked.connect(self._parent.load_params)
97 self._pushbutton_start_all.clicked.connect(self._parent.start_all)
98 self._pushbutton_stop_all.clicked.connect(self._parent.stop_all)
100 self._combobox_pkg.currentIndexChanged[str].connect(
103 self._combobox_launchfile_name.currentIndexChanged[str].connect(
113 if launchfile_name
is None or launchfile_name ==
'':
118 rospy.logdebug(
'_load_launchfile_slot launchfile_name={}'.format(
127 except IndexError
as e:
128 msg =
'IndexError={} launchfile={}'.format(e.message,
131 self.sig_sysmsg.emit(msg)
133 except RLException
as e:
134 msg =
'RLException={} launchfile={}'.format(e.message,
137 self.sig_sysmsg.emit(msg)
143 folder_name_launchfile=
'launch'):
145 @rtype: ROSLaunchConfig 146 @raises RLException: raised by roslaunch.config.load_config_default. 149 pkg_name = self._combobox_pkg.currentText()
152 launchfile = os.path.join(self._rospack.get_path(pkg_name),
153 folder_name_launchfile, launchfile_name)
154 except IndexError
as e:
155 raise RLException(
'IndexError: {}'.format(e.message))
158 launch_config = roslaunch.config.load_config_default([launchfile],
160 except rospkg.common.ResourceNotFound
as e:
161 raise RLException(
'ResourceNotFound: {}'.format(e.message))
162 except RLException
as e:
178 self._datamodel.beginResetModel()
179 self._datamodel.endResetModel()
185 for order_xmlelement, node
in enumerate(self._config.nodes):
191 qindex_nodewidget = self._datamodel.index(order_xmlelement,
193 node_widget = self._delegate.create_node_widget(qindex_nodewidget,
199 std_item = QStandardItem(
202 self._datamodel.setItem(order_xmlelement, 0, std_item)
205 self._treeview.setIndexWidget(qindex_nodewidget, node_widget)
208 self._node_controllers.append(node_controller)
210 node_widget.connect_start_stop_button(
211 node_controller.start_stop_slot)
212 rospy.logdebug(
'loop #%d proxy.config.namespace=%s ' +
213 'proxy.config.name=%s',
214 order_xmlelement, proxy.config.namespace,
223 Inspired by rqt_msg.MessageWidget._update_pkgs_contain_launchfiles 225 packages = sorted([pkg_tuple[0]
227 in RqtRoscommUtil.iterate_packages(
'launch')])
230 self._combobox_pkg.clear()
232 self._combobox_pkg.setCurrentIndex(0)
236 Inspired by rqt_msg.MessageWidget._refresh_msgs 238 if package
is None or len(package) == 0:
243 _launch_instance_list = RqtRoscommUtil.list_files(package,
247 '_refresh_launches package={} instance_list={}'.format(package, _launch_instance_list))
250 for x
in _launch_instance_list]
252 self._combobox_launchfile_name.clear()
256 '''Loads all global parameters into roscore.''' 258 else roslaunch.rlutil.get_or_generate_uuid(
None,
True)
259 runner = roslaunch.ROSLaunchRunner(run_id, self.
_config)
260 runner._load_parameters()
262 msg =
'Loaded %d parameters to parameter server.' \
263 % len(self._config.params)
264 self.sig_sysmsg.emit(msg)
279 if __name__ ==
'__main__':
285 sys.exit(main.main(sys.argv, standalone=
'rqt_launch'))