Example #1
0
    def _update_thread_run(self):
        # update type_combo_box
        message_type_names = []
        try:
            # this only works on fuerte and up
            packages = sorted([
                pkg_tuple[0] for pkg_tuple in rosmsg.iterate_packages(
                    self._rospack, rosmsg.MODE_MSG)
            ])
        except:
            # this works up to electric
            packages = sorted(rosmsg.list_packages())
        for package in packages:
            for base_type_str in rosmsg.list_msgs(package,
                                                  rospack=self._rospack):
                message_class = roslib.message.get_message_class(base_type_str)
                if message_class is not None:
                    message_type_names.append(base_type_str)

        # TODO: get all ROS packages and launch files here instead
        #self.type_combo_box.setItems.emit(sorted(message_type_names))
        packages = sorted([
            pkg_tuple[0]
            for pkg_tuple in RqtRoscommUtil.iterate_packages('launch')
        ])
        self.package_combo_box.setItems.emit(packages)
Example #2
0
    def _refresh_launchfiles(self, package=None):
        """
        Inspired by rqt_msg.MessageWidget._refresh_msgs
        """
        if package is None or len(package) == 0 or self._package_update:
            return
        self._launchfile_update = True
        previous_launchfile = self._settings.value('launchfile_name', '')
        self._settings.setValue('package', package)
        self._settings.sync()
        self._launchfile_instances = []  # Launch[]
        # TODO: RqtRoscommUtil.list_files's 2nd arg 'subdir' should NOT be
        # hardcoded later.
        _launch_instance_list = RqtRoscommUtil.list_files(package, 'launch')

        rospy.logdebug(
            '_refresh_launches package={} instance_list={}'.format(
                package, _launch_instance_list
            )
        )

        self._launchfile_instances = [
            x.split('/')[1] for x in _launch_instance_list
        ]

        self._combobox_launchfile_name.clear()
        self._combobox_launchfile_name.addItems(self._launchfile_instances)
        if previous_launchfile in self._launchfile_instances:
            index = self._launchfile_instances.index(previous_launchfile)
        else:
            index = 0
        self._launchfile_update = False
        self._combobox_launchfile_name.setCurrentIndex(index)
Example #3
0
 def on_package_combo_box_currentIndexChanged(self, package):
     #if topic_name in self._topic_dict:
     #    self.type_combo_box.setEditText(self._topic_dict[topic_name])
     #pass
     _launch_instance_list = RqtRoscommUtil.list_files(package, 'launch')
     _launchfile_instances = [
         x.split('/')[1] for x in _launch_instance_list
     ]
     self.file_combo_box.setItems.emit(_launchfile_instances)
Example #4
0
 def _refresh_packages(self, mode=message_helpers.MSG_MODE):
     packages = sorted([
         pkg_tuple[0]
         for pkg_tuple in RqtRoscommUtil.iterate_packages(self._mode)
     ])
     self._package_list = packages
     self._logger.debug('pkgs={}'.format(self._package_list))
     self._package_combo.clear()
     self._package_combo.addItems(self._package_list)
     self._package_combo.setCurrentIndex(0)
 def _update_pkgs_contain_launchfiles(self):
     '''
     Inspired by rqt_msg.MessageWidget._update_pkgs_contain_launchfiles
     '''
     packages = sorted([pkg_tuple[0]
                        for pkg_tuple
                        in RqtRoscommUtil.iterate_packages('launch')])
     self._package_list = packages
     rospy.logdebug('pkgs={}'.format(self._package_list))
     self._combobox_pkg.clear()
     self._combobox_pkg.addItems(self._package_list)
     self._combobox_pkg.setCurrentIndex(0)
    def test_iterate_packages(self):
        """
        Not a very good test because the right answer that is hardcoded varies
        depending on the system where this unittest runs.
        """
        pkg_num_sum = 0
        for pkg in RqtRoscommUtil.iterate_packages('launch'):
            pkg_num_sum += 1
            print('pkg={}'.format(pkg))

        print(pkg_num_sum)
        self.assertEqual(pkg_num_sum, self._totalnum_pkg_contains_launch)
Example #7
0
 def _update_pkgs_contain_launchfiles(self):
     '''
     Inspired by rqt_msg.MessageWidget._update_pkgs_contain_launchfiles
     '''
     packages = sorted([pkg_tuple[0]
                        for pkg_tuple
                        in RqtRoscommUtil.iterate_packages('launch')])
     self._package_list = packages
     rospy.logdebug('pkgs={}'.format(self._package_list))
     self._combobox_pkg.clear()
     self._combobox_pkg.addItems(self._package_list)
     self._combobox_pkg.setCurrentIndex(0)
    def test_list_files(self):
        """
        Not a very good test because the right answer that is hardcoded varies
        depending on the system where this unittest runs.
        """
        file_num = 0
        pkg_name = 'pr2_moveit_config'
        _totalnum_launches_pkg_contains = 15
        subdir = 'launch'
        file_ext = '.launch'
        files = RqtRoscommUtil.list_files(pkg_name, subdir, file_ext)
        for file in files:
            file_num += 1
            print('file={}'.format(file))

        print(file_num)
        self.assertEqual(file_num, _totalnum_launches_pkg_contains)
    def _refresh_launchfiles(self, package=None):
        '''
        Inspired by rqt_msg.MessageWidget._refresh_msgs
        '''
        if package is None or len(package) == 0:
            return
        self._launchfile_instances = []  # Launch[]
        #TODO: RqtRoscommUtil.list_files's 2nd arg 'subdir' should NOT be
        # hardcoded later.
        _launch_instance_list = RqtRoscommUtil.list_files(package, 'launch')

        rospy.logdebug('_refresh_launches package={} instance_list={}'.format(
            package, _launch_instance_list))

        self._launchfile_instances = [
            x.split('/')[1] for x in _launch_instance_list
        ]

        self._combobox_launchfile_name.clear()
        self._combobox_launchfile_name.addItems(self._launchfile_instances)
    def _refresh_launchfiles(self, package=None):
        '''
        Inspired by rqt_msg.MessageWidget._refresh_msgs
        '''
        if package is None or len(package) == 0:
            return
        self._launchfile_instances = []  # Launch[]
        #TODO: RqtRoscommUtil.list_files's 2nd arg 'subdir' should NOT be
        # hardcoded later.
        _launch_instance_list = RqtRoscommUtil.list_files(package,
                                                         'launch')

        rospy.logdebug('_refresh_launches package={} instance_list={}'.format(
                                                       package,
                                                       _launch_instance_list))

        self._launchfile_instances = [x.split('/')[1]
                                      for x in _launch_instance_list]

        self._combobox_launchfile_name.clear()
        self._combobox_launchfile_name.addItems(self._launchfile_instances)
Example #11
0
 def _update_pkgs_contain_launchfiles(self):
     """
     Inspired by rqt_msg.MessageWidget._update_pkgs_contain_launchfiles
     """
     self._package_update = True
     packages = sorted(
         [
             pkg_tuple[0]
             for pkg_tuple in RqtRoscommUtil.iterate_packages('launch')
         ]
     )
     self._package_list = packages
     rospy.logdebug('pkgs={}'.format(self._package_list))
     previous_package = self._settings.value('package', '')
     self._combobox_pkg.clear()
     self._combobox_pkg.addItems(self._package_list)
     if previous_package in self._package_list:
         index = self._package_list.index(previous_package)
     else:
         index = 0
     self._package_update = False
     self._combobox_pkg.setCurrentIndex(index)
Example #12
0
    def _check_params_alive(self, signal, params_monitored, stop_event):
        """
        Working as a callback of Thread class, this method keeps looping to
        watch if the params whose names are passed exist and emits signal per
        each node.

        Notice that what MoveitWidget._check_nodes_alive &
        MoveitWidget._check_params_alive do is very similar, but since both of
        them are supposed to be passed to Thread class, there might not be
        a way to generalize these 2.

        @type signal: Signal(bool, str)
        @param_name signal: emitting a name of the parameter that's found.
        @type params_monitored: str[]
        @type stop_event: Event()
        """

        while True:
            has_param = False

            for param_name in params_monitored:
                is_rosmaster_running = RqtRoscommUtil.is_roscore_running()

                try:
                    if is_rosmaster_running:
                        # Only if rosmaster is running, check if the parameter
                        # exists or not.
                        has_param = rospy.has_param(param_name)
                except rospy.exceptions.ROSException as e:
                    rospy.logerr('Exception upon rospy.has_param {}'.format(
                        e.message))
                    self.sig_sysmsg.emit(
                        'Exception upon rospy.has_param {}'.format(e.message))
                signal.emit(has_param, param_name)
                rospy.logdebug('has_param {}, check_param_alive: {}'.format(
                    has_param, param_name))
            if stop_event.wait(self._refresh_rate):
                return
Example #13
0
    def _check_params_alive(self, signal, params_monitored):
        """
        Working as a callback of Thread class, this method keeps looping to
        watch if the params whose names are passed exist and emits signal per
        each node.

        Notice that what MoveitWidget._check_nodes_alive &
        MoveitWidget._check_params_alive do is very similar, but since both of
        them are supposed to be passed to Thread class, there might not be
        a way to generalize these 2.

        @type signal: Signal(bool, str)
        @param_name signal: emitting a name of the parameter that's found.
        @type params_monitored: str[]
        """

        while self._is_checking_params:
            # self._is_checking_params only turns to false when the plugin
            # shuts down.

            has_param = False

            for param_name in params_monitored:
                is_rosmaster_running = RqtRoscommUtil.is_roscore_running()

                try:
                    if is_rosmaster_running:
                        # Only if rosmaster is running, check if the parameter
                        # exists or not.
                        has_param = rospy.has_param(param_name)
                except rospy.exceptions.ROSException as e:
                    self.sig_sysmsg.emit(
                         'Exception upon rospy.has_param {}'.format(e.message))
                signal.emit(has_param, param_name)
                rospy.loginfo('has_param {}, check_param_alive: {}'.format(
                                                      has_param, param_name))
            time.sleep(self._refresh_rate)