def _update_nodetree(self):
        """
        """

        #TODO(Isaac): 11/25/2012 dynamic_reconfigure only returns params that 
        #             are associated with nodes. In order to handle independent
        #             params, different approach needs taken.
        try:
            nodes = dyn_reconf.find_reconfigure_services()
        except rosservice.ROSServiceIOException as e:
            rospy.logerr("Reconfigure GUI cannot connect to master.")
            raise e  #TODO Make sure 'raise' here returns or finalizes this func.

        if not nodes == self._nodes_previous:
            paramname_prev = ''
            paramitem_top_prev = None
            i_debug = 0
            for node_name_grn in nodes:
                p = ParameterItem(node_name_grn)
                p.set_param_name(node_name_grn)
                names = p.get_param_names()

                i_debug += 1
                rospy.logdebug('_update_nodetree i=%d names=%s',
                               i_debug, names)

                self._add_tree_node(p, self._rootitem, names)
    def _update_nodetree_pernode(self):
        """
        """

        # TODO(Isaac): 11/25/2012 dynamic_reconfigure only returns params that
        #             are associated with nodes. In order to handle independent
        #             params, different approach needs taken.
        try:
            nodes = dyn_reconf.find_reconfigure_services()
        except rosservice.ROSServiceIOException as e:
            rospy.logerr("Reconfigure GUI cannot connect to master.")
            raise e  # TODO Make sure 'raise' here returns or finalizes func.

        if not nodes == self._nodes_previous:
            i_node_curr = 1
            num_nodes = len(nodes)
            elapsedtime_overall = 0.0
            for node_name_grn in nodes:
                time_siglenode_loop = time.time()

                ####(Begin) For DEBUG ONLY; skip some dynreconf creation
#                if i_node_curr % 2 != 0:
#                    i_node_curr += 1
#                    continue
                #### (End) For DEBUG ONLY. ####

                # Instantiate QStandardItem. Inside, dyn_reconf client will
                # be generated too.
                treenodeitem_toplevel = TreenodeQstdItem(
                                node_name_grn, TreenodeQstdItem.NODE_FULLPATH)
                _treenode_names = treenodeitem_toplevel.get_treenode_names()

                try:
                    treenodeitem_toplevel.connect_param_server()
                except rospy.exceptions.ROSException as e:
                    rospy.logerr(e.message)
                    #Skip item that fails to connect to its node.
                    continue
                    #TODO: Needs to show err msg on GUI too.

                # Using OrderedDict here is a workaround for StdItemModel
                # not returning corresponding item to index.
                self._nodeitems[node_name_grn] = treenodeitem_toplevel

                self._add_children_treenode(treenodeitem_toplevel,
                                            self._rootitem, _treenode_names)

                time_siglenode_loop = time.time() - time_siglenode_loop
                elapsedtime_overall += time_siglenode_loop

                _str_progress = 'reconf ' + \
                     'loading #{}/{} {} / {}sec node={}'.format(
                     i_node_curr, num_nodes, round(time_siglenode_loop, 2),
                     round(elapsedtime_overall, 2), node_name_grn)

                # NOT a debug print - please DO NOT remove. This print works
                # as progress notification when loading takes long time.
                rospy.logdebug(_str_progress)
                i_node_curr += 1
    def _update_nodetree_pernode(self):
        """
        """

        # TODO(Isaac): 11/25/2012 dynamic_reconfigure only returns params that
        #             are associated with nodes. In order to handle independent
        #             params, different approach needs taken.
        try:
            nodes = dyn_reconf.find_reconfigure_services()
        except rosservice.ROSServiceIOException as e:
            rospy.logerr("Reconfigure GUI cannot connect to master.")
            raise e  # TODO Make sure 'raise' here returns or finalizes func.

        if not nodes == self._nodes_previous:
            i_node_curr = 1
            num_nodes = len(nodes)
            elapsedtime_overall = 0.0
            for node_name_grn in nodes:
                time_siglenode_loop = time.time()

                ####(Begin) For DEBUG ONLY; skip some dynreconf creation
                #                if i_node_curr % 2 != 0:
                #                    i_node_curr += 1
                #                    continue
                #### (End) For DEBUG ONLY. ####

                # Instantiate QStandardItem. Inside, dyn_reconf client will
                # be generated too.
                treenodeitem_toplevel = TreenodeQstdItem(
                    node_name_grn, TreenodeQstdItem.NODE_FULLPATH)
                _treenode_names = treenodeitem_toplevel.get_treenode_names()

                try:
                    treenodeitem_toplevel.connect_param_server()
                except rospy.exceptions.ROSException as e:
                    rospy.logerr(e.message)
                    #Skip item that fails to connect to its node.
                    continue
                    #TODO: Needs to show err msg on GUI too.

                # Using OrderedDict here is a workaround for StdItemModel
                # not returning corresponding item to index.
                self._nodeitems[node_name_grn] = treenodeitem_toplevel

                self._add_children_treenode(treenodeitem_toplevel,
                                            self._rootitem, _treenode_names)

                time_siglenode_loop = time.time() - time_siglenode_loop
                elapsedtime_overall += time_siglenode_loop

                _str_progress = 'reconf ' + \
                     'loading #{}/{} {} / {}sec node={}'.format(
                     i_node_curr, num_nodes, round(time_siglenode_loop, 2),
                     round(elapsedtime_overall, 2), node_name_grn)

                # NOT a debug print - please DO NOT remove. This print works
                # as progress notification when loading takes long time.
                rospy.logdebug(_str_progress)
                i_node_curr += 1
    def _prune_nodetree_pernode(self):
        try:
            nodes = dyn_reconf.find_reconfigure_services()
        except rosservice.ROSServiceIOException as e:
            rospy.logerr("Reconfigure GUI cannot connect to master.")
            raise e  # TODO Make sure 'raise' here returns or finalizes func.

        for i in reversed(range(0, self._rootitem.rowCount())):
            candidate_for_removal = self._rootitem.child(i).get_raw_param_name()
            if not candidate_for_removal in nodes:
                rospy.logdebug('Removing {} because the server is no longer available.'.format(
                                   candidate_for_removal))
                self._nodeitems[candidate_for_removal].disconnect_param_server()
                self._rootitem.removeRow(i)
                self._nodeitems.pop(candidate_for_removal)
Beispiel #5
0
    def _prune_nodetree_pernode(self):
        try:
            nodes = dyn_reconf.find_reconfigure_services()
        except rosservice.ROSServiceIOException as e:
            rospy.logerr("Reconfigure GUI cannot connect to master.")
            raise e  # TODO Make sure 'raise' here returns or finalizes func.

        for i in reversed(range(0, self._rootitem.rowCount())):
            candidate_for_removal = self._rootitem.child(i).get_raw_param_name()
            if not candidate_for_removal in nodes:
                rospy.logdebug('Removing {} because the server is no longer available.'.format(
                                   candidate_for_removal))
                self._nodeitems[candidate_for_removal].disconnect_param_server()
                self._rootitem.removeRow(i)
                self._nodeitems.pop(candidate_for_removal)
Beispiel #6
0
    def refresh_servers(self):
        self.dynamic_reconfigure_servers = find_reconfigure_services()
        rospy.loginfo("Found dynamic reconfigure servers:\n" +
                      str(self.dynamic_reconfigure_servers))
        self.dropdown = gui.DropDown()
        choose_ddi = gui.DropDownItem("Choose server...")
        self.dropdown.add_child(0, choose_ddi)
        for idx, server_name in enumerate(self.dynamic_reconfigure_servers):
            ddi = gui.DropDownItem(server_name)
            self.dropdown.add_child(idx + 1, ddi)

        self.dropdown.set_on_change_listener(self.on_dropdown_change)
        # using ID 2 to update the dropdown
        self.hor_servers.add_child(2, self.dropdown)
        # This makes the dropdown not be left
        self.dropdown.style['display'] = 'block'
        self.dropdown.style['margin'] = '10px auto'
        self.dropdown.style['float'] = 'none'
        self.wid.add_child(1, self.hor_servers)
    def refresh_servers(self):
        self.dynamic_reconfigure_servers = find_reconfigure_services()
        rospy.loginfo("Found dynamic reconfigure servers:\n" +
                      str(self.dynamic_reconfigure_servers))
        #self.dropdown = gui.DropDown(200, 20)
        self.dropdown = gui.DropDown(-1, -1)
        #choose_ddi = gui.DropDownItem(200, 20, "Choose server...")
        choose_ddi = gui.DropDownItem(-1, -1, "Choose server...")
        self.dropdown.append(0, choose_ddi)
        for idx, server_name in enumerate(self.dynamic_reconfigure_servers):
            #ddi = gui.DropDownItem(200, 20, server_name)
            ddi = gui.DropDownItem(-1, -1, server_name)
            self.dropdown.append(idx+1, ddi)

        self.dropdown.set_on_change_listener(self, 'on_dropdown_change')
        # using ID 2 to update the dropdown
        self.hor_servers.append(2, self.dropdown)
        # This makes the dropdown not be left
        self.dropdown.style['display'] = 'block'
        self.dropdown.style['margin'] = '10px auto'
        self.dropdown.style['float'] = 'none'
        self.wid.append(1, self.hor_servers)
Beispiel #8
0
    def refresh_topics(self):
        """
        refresh tree view items
        """

        nodes = dynamic_reconfigure.find_reconfigure_services()
        # dparams = []
        dparams = {}
        for node in nodes:
            client = dynamic_reconfigure.client.Client(node, timeout=3)
            gdesc = client.get_group_descriptions()
            for pdesc in gdesc["parameters"]:
                param = node + "/" + pdesc["name"]
                dparams[param] = pdesc

        for param, desc in self._current_params.items():
            if param not in dparams:
                del self._current_params[param]
                # TODO: delete the tree widget item

        for param, desc in dparams.items():
            if param not in self._current_params:
                self._current_params[param] = desc
                self.insert_param(param, desc)
Beispiel #9
0
#
# Author: Isaac Saito

import time

import dynamic_reconfigure as dyn_reconf
import dynamic_reconfigure.client
import rosservice
import rospy

from rqt_reconfigure.treenode_qstditem import TreenodeQstdItem


if __name__ == '__main__':
    try:
        nodes = dyn_reconf.find_reconfigure_services()
    except rosservice.ROSServiceIOException as e:
        rospy.logerr("Reconfigure GUI cannot connect to master.")
        raise e  # TODO Make sure 'raise' here returns or finalizes func.

    i_node_curr = 1
    num_nodes = len(nodes)
    elapsedtime_overall = 0.00
    for node_name_grn in nodes:
        time_siglenode_loop = time.time()

        try:
            _dynreconf_client = dynamic_reconfigure.client.Client(
                                               str(node_name_grn), timeout=5.0)
        except rospy.exceptions.ROSException:
            rospy.logerr("TreenodeQstdItem. Couldn't connect to {}".format(
Beispiel #10
0
    def refresh_topics(self):
        """
        refresh tree view items
        """
        # print "is refreshing"

        nodes = dynamic_reconfigure.find_reconfigure_services()
        # dparams = []
        dparams = {}
        for node in nodes:
            client = dynamic_reconfigure.client.Client(node, timeout=3)
            gdesc = client.get_group_descriptions()
            for pdesc in gdesc["parameters"]:
                param = node + "/" + pdesc["name"]
                dparams[param] = pdesc

        # dparams = dparams.items()

        for param, desc in self._current_params.items():
            if param not in dparams:
                del self._current_params[param]
                # TODO: delete the tree widget item

        for param, desc in dparams.items():
            if param not in self._current_params:
                self._current_params[param] = desc
                self.insert_param(param, desc)


        # print self._current_params

        # print self._tree_items

        # dparams = rospy.get_published_topics()

        # print self._items_param

        # selected_dict = { self._selected_items[index] : index for index in range(len(self._selected_items)) }
        # print selected_dict
        # print self._selected_items
        # print self.get_selected()

        return 


        try:
            if self._selected_topics is None:
                topic_list = dparams
                if topic_list is None:
                    rospy.logerr('Not even a single published topic found. Check network configuration')
                    return
        except IOError as e:
            rospy.logerr("Communication with rosmaster failed: {0}".format(e.strerror))
            return

        if self._current_topic_list != topic_list:
            self._current_topic_list = topic_list

            print "is updating"

            # start new topic dict
            new_topics = {}

            for topic_name, topic_type in topic_list:
                # if topic is new or has changed its type
                if topic_name not in self._topics or \
                   self._topics[topic_name]['type'] != topic_type:
                    # create new TopicInfo
                    topic_info = TopicInfo(topic_name, topic_type)
                    message_instance = None
                    if topic_info.message_class is not None:
                        message_instance = topic_info.message_class()
                    # add it to the dict and tree view
                    topic_item = self._recursive_create_widget_items(self.topics_tree_widget, topic_name, topic_type, message_instance)
                    new_topics[topic_name] = {
                       'item': topic_item,
                       'info': topic_info,
                       'type': topic_type,
                    }
                else:
                    # if topic has been seen before, copy it to new dict and
                    # remove it from the old one
                    new_topics[topic_name] = self._topics[topic_name]
                    del self._topics[topic_name]

            # clean up old topics
            for topic_name in self._topics.keys():
                self._topics[topic_name]['info'].stop_monitoring()
                index = self.topics_tree_widget.indexOfTopLevelItem(
                                           self._topics[topic_name]['item'])
                self.topics_tree_widget.takeTopLevelItem(index)
                del self._topics[topic_name]

            # switch to new topic dict
            self._topics = new_topics