From b51243eeadcebe258ccb5bd67a5752326d22b831 Mon Sep 17 00:00:00 2001 From: Nick Lamprianidis Date: Sun, 27 Aug 2023 23:07:16 +0200 Subject: [PATCH] Misc minor bugs, optimizations, and typos Signed-off-by: Nick Lamprianidis --- src/rqt_reconfigure/node_selector_widget.py | 16 +++++++--------- src/rqt_reconfigure/param_api.py | 5 ++--- src/rqt_reconfigure/param_client_widget.py | 3 ++- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/rqt_reconfigure/node_selector_widget.py b/src/rqt_reconfigure/node_selector_widget.py index 913ae79..82d11f7 100644 --- a/src/rqt_reconfigure/node_selector_widget.py +++ b/src/rqt_reconfigure/node_selector_widget.py @@ -68,7 +68,7 @@ def __init__(self, parent, context, signal_msg=None): """ Init node selector widget. - @param signal_msg: Signal to carries a system msg that is shown on GUI. + @param signal_msg: Signal to carry a system msg that is shown on GUI. @type signal_msg: QtCore.Signal """ super(NodeSelectorWidget, self).__init__() @@ -83,8 +83,8 @@ def __init__(self, parent, context, signal_msg=None): loadUi(ui_file, self) # List of the available nodes. Since the list should be updated over - # time and we don't want to create node instance per every update - # cycle, This list instance should better be capable of keeping track. + # time, and we don't want to create node instance per every update + # cycle, this list instance should better be capable of keeping track. self._nodeitems = OrderedDict() # Dictionary. 1st elem is node's GRN name, # 2nd is TreenodeQstdItem instance. @@ -158,7 +158,7 @@ def node_selected(self, grn, scroll_to=False): :type grn: str """ - # Iterate over all of the indexes + # Iterate over all the indexes for index in self._enumerate_indexes(): grn_from_index = RqtRosGraph.get_upper_grn(index, '') logging.debug(' Compare given grn={} from selected={}'.format( @@ -225,7 +225,6 @@ def _selection_selected(self, index_current, rosnode_name_selected): # Only when it's a terminal we move forward. item_child = self._nodeitems[rosnode_name_selected] - item_widget = None try: item_widget = item_child.get_param_client_widget() except Exception as e: @@ -261,7 +260,7 @@ def _selection_changed_slot(self, selected, deselected): # Setting length criteria as 1 is only a workaround, to avoid # Node boxes on right-hand side disappears when filter key doesn't # match them. - # Indeed this workaround leaves another issue. Question for + # Indeed, this workaround leaves another issue. Question for # permanent solution is asked here http://goo.gl/V4DT1 index_current = deselected.indexes()[0] @@ -314,7 +313,7 @@ def _update_nodetree_pernode(self): try: nodes = find_nodes_with_params(self._context.node) except Exception as e: - self._logger.error(e) + logging.error(e) # TODO: print to sysmsg pane raise e # TODO Make sure 'raise' here returns or finalizes func. @@ -368,7 +367,7 @@ def _update_nodetree_pernode(self): def _add_children_treenode(self, treenodeitem_toplevel, treenodeitem_parent, child_names_left): """ - Add childen treenode. + Add children treenode. Evaluate current treenode and the previous treenode at the same depth. If the name of both nodes is the same, current node instance is @@ -399,7 +398,6 @@ def _add_children_treenode(self, treenodeitem_toplevel, stditem_prev = treenodeitem_parent.child(row_index_parent) name_prev = stditem_prev.text() - stditem = None # If the name of both nodes is the same, current node instance is # ignored (that means children will be added to the same parent) if name_prev != name_currentnode: diff --git a/src/rqt_reconfigure/param_api.py b/src/rqt_reconfigure/param_api.py index 814a704..ad842fb 100644 --- a/src/rqt_reconfigure/param_api.py +++ b/src/rqt_reconfigure/param_api.py @@ -134,7 +134,7 @@ def create_param_client(node, remote_node_name, param_change_callback=None): def _has_parameters(node, node_name, node_namespace): - # Get all of the service provided by a node (node_name) + # Get all the service provided by a node (node_name) for service_name, service_types in node.get_service_names_and_types_by_node( node_name, node_namespace): @@ -149,7 +149,6 @@ def find_nodes_with_params(node): node_list = [] for node_name, node_namespace in names_and_namespaces: if _has_parameters(node, node_name, node_namespace): - full_name = node_namespace + ( - '/' if not node_namespace.endswith('/') else '') + node_name + full_name = node_namespace.rstrip('/') + '/' + node_name node_list.append(full_name) return node_list diff --git a/src/rqt_reconfigure/param_client_widget.py b/src/rqt_reconfigure/param_client_widget.py index 371fc78..6017654 100644 --- a/src/rqt_reconfigure/param_client_widget.py +++ b/src/rqt_reconfigure/param_client_widget.py @@ -116,7 +116,8 @@ def __init__(self, context, node_name): self._param_client.describe_parameters(param_names) ) except Exception as e: - logging.warn('Failed to retrieve parameters from node: ' + str(e)) + logging.warn( + f'Failed to retrieve parameters from node {self._node_grn}: {e}') # Save and load buttons button_widget = QWidget(self)