@@ -60,7 +60,8 @@ def __init__(self, context):
6060 # Pop-up that displays controller information
6161 self ._popup_widget = QWidget ()
6262 ui_file = os .path .join (
63- get_package_share_directory ("rqt_controller_manager" ), "resource" , "controller_info.ui"
63+ get_package_share_directory (
64+ "rqt_controller_manager" ), "resource" , "controller_info.ui"
6465 )
6566 loadUi (ui_file , self ._popup_widget )
6667 self ._popup_widget .setObjectName ("ControllerInfoUi" )
@@ -71,7 +72,8 @@ def __init__(self, context):
7172 # plugin at once, these lines add number to make it easy to
7273 # tell from pane to pane.
7374 if context .serial_number () > 1 :
74- self ._widget .setWindowTitle (f"{ self ._widget .windowTitle ()} { context .serial_number ()} " )
75+ self ._widget .setWindowTitle (
76+ f"{ self ._widget .windowTitle ()} { context .serial_number ()} " )
7577 # Add widget to the user interface
7678 context .add_widget (self ._widget )
7779
@@ -106,13 +108,15 @@ def __init__(self, context):
106108
107109 # Timer for controller manager updates
108110 self ._update_cm_list_timer = QTimer (self )
109- self ._update_cm_list_timer .setInterval (int (1000.0 / self ._cm_update_freq ))
111+ self ._update_cm_list_timer .setInterval (
112+ int (1000.0 / self ._cm_update_freq ))
110113 self ._update_cm_list_timer .timeout .connect (self ._update_cm_list )
111114 self ._update_cm_list_timer .start ()
112115
113116 # Timer for running controller updates
114117 self ._update_ctrl_list_timer = QTimer (self )
115- self ._update_ctrl_list_timer .setInterval (int (1000.0 / self ._cm_update_freq ))
118+ self ._update_ctrl_list_timer .setInterval (
119+ int (1000.0 / self ._cm_update_freq ))
116120 self ._update_ctrl_list_timer .timeout .connect (self ._update_controllers )
117121 self ._update_ctrl_list_timer .start ()
118122
@@ -141,7 +145,8 @@ def restore_settings(self, plugin_settings, instance_settings):
141145 pass
142146
143147 def _update_cm_list (self ):
144- update_combo (self ._widget .cm_combo , _list_controller_managers (self ._node ))
148+ update_combo (self ._widget .cm_combo ,
149+ _list_controller_managers (self ._node ))
145150
146151 def _on_cm_change (self , cm_name ):
147152 self ._cm_name = cm_name
@@ -181,7 +186,8 @@ def _list_controllers(self):
181186 for name in _get_parameter_controller_names (self ._node , self ._cm_name ):
182187 add_ctrl = all (name != ctrl .name for ctrl in controllers )
183188 if add_ctrl :
184- type_str = _get_controller_type (self ._node , self ._cm_name , name )
189+ type_str = _get_controller_type (
190+ self ._node , self ._cm_name , name )
185191 uninit_ctrl = ControllerState (name = name , type = type_str )
186192 controllers .append (uninit_ctrl )
187193 return controllers
@@ -205,19 +211,26 @@ def _on_ctrl_menu(self, pos):
205211 # Show context menu
206212 menu = QMenu (self ._widget .table_view )
207213 if ctrl .state == "active" :
208- action_deactivate = menu .addAction (self ._icons ["inactive" ], "Deactivate" )
209- action_kill = menu .addAction (self ._icons ["finalized" ], "Deactivate and Unload" )
214+ action_deactivate = menu .addAction (
215+ self ._icons ["inactive" ], "Deactivate" )
216+ action_kill = menu .addAction (
217+ self ._icons ["finalized" ], "Deactivate and Unload" )
210218 elif ctrl .state == "inactive" :
211219 action_activate = menu .addAction (self ._icons ["active" ], "Activate" )
212- action_unload = menu .addAction (self ._icons ["unconfigured" ], "Unload" )
220+ action_unload = menu .addAction (
221+ self ._icons ["unconfigured" ], "Unload" )
213222 elif ctrl .state == "unconfigured" :
214- action_configure = menu .addAction (self ._icons ["inactive" ], "Configure" )
215- action_spawn = menu .addAction (self ._icons ["active" ], "Configure and Activate" )
223+ action_configure = menu .addAction (
224+ self ._icons ["inactive" ], "Configure" )
225+ action_spawn = menu .addAction (
226+ self ._icons ["active" ], "Configure and Activate" )
216227 else :
217228 # Controller isn't loaded
218229 action_load = menu .addAction (self ._icons ["unconfigured" ], "Load" )
219- action_configure = menu .addAction (self ._icons ["inactive" ], "Load and Configure" )
220- action_activate = menu .addAction (self ._icons ["active" ], "Load, Configure and Activate" )
230+ action_configure = menu .addAction (
231+ self ._icons ["inactive" ], "Load and Configure" )
232+ action_activate = menu .addAction (
233+ self ._icons ["active" ], "Load, Configure and Activate" )
221234
222235 action = menu .exec_ (self ._widget .table_view .mapToGlobal (pos ))
223236
@@ -390,7 +403,8 @@ def _get_controller_type(node, node_name, ctrl_name):
390403 @return Controller type
391404 @rtype str
392405 """
393- response = call_get_parameters (node = node , node_name = node_name , parameter_names = [ctrl_name ])
406+ response = call_get_parameters (
407+ node = node , node_name = node_name , parameter_names = [ctrl_name ])
394408 return response .values [0 ].string_value if response .values else ""
395409
396410
@@ -414,4 +428,9 @@ def _get_parameter_controller_names(node, node_name):
414428 """Get list of ROS parameter names that potentially represent a controller configuration."""
415429 parameter_names = call_list_parameters (node = node , node_name = node_name )
416430 suffix = ".type"
417- return [n [: - len (suffix )] for n in parameter_names .result ().result .names if n .endswith (suffix )]
431+ # @note: The versions conditioning is added here to support the source-compatibility with Humble
432+ try :
433+ return [n [: - len (suffix )] for n in parameter_names .result ().result .names if n .endswith (suffix )]
434+ finally :
435+ # for humble, ros2param < 0.20.0
436+ return [n [: - len (suffix )] for n in parameter_names if n .endswith (suffix )]
0 commit comments