From 2e598c83c5c7f72af0f41829351cd60d2f1f3000 Mon Sep 17 00:00:00 2001 From: Bence Magyar Date: Tue, 31 Oct 2023 20:44:14 +0000 Subject: [PATCH] fix spawner conflicts - contd --- .../controller_manager/spawner.py | 83 ------------------- 1 file changed, 83 deletions(-) diff --git a/controller_manager/controller_manager/spawner.py b/controller_manager/controller_manager/spawner.py index 25ba730f1d..35cdaae968 100644 --- a/controller_manager/controller_manager/spawner.py +++ b/controller_manager/controller_manager/spawner.py @@ -172,18 +172,9 @@ def main(args=None): if param_file and not os.path.isfile(param_file): raise FileNotFoundError(errno.ENOENT, os.strerror(errno.ENOENT), param_file) -<<<<<<< HEAD - prefixed_controller_name = controller_name - if controller_namespace: - prefixed_controller_name = controller_namespace + '/' + controller_name - - node = Node('spawner_' + controller_name) - if not controller_manager_name.startswith('/'): -======= node = Node("spawner_" + controller_names[0]) if not controller_manager_name.startswith("/"): ->>>>>>> 4e78813 (Update spawner to accept controllers list and start them in sequence (#1139)) spawner_namespace = node.get_namespace() if spawner_namespace != '/': controller_manager_name = f"{spawner_namespace}/{controller_manager_name}" @@ -196,66 +187,6 @@ def main(args=None): node.get_logger().error('Controller manager not available') return 1 -<<<<<<< HEAD - if is_controller_loaded(node, controller_manager_name, prefixed_controller_name): - node.get_logger().warn('Controller already loaded, skipping load_controller') - else: - if controller_type: - parameter = Parameter() - parameter.name = prefixed_controller_name + '.type' - parameter.value = get_parameter_value(string_value=controller_type) - - response = call_set_parameters( - node=node, node_name=controller_manager_name, parameters=[parameter]) - assert len(response.results) == 1 - result = response.results[0] - if result.successful: - node.get_logger().info(bcolors.OKCYAN + 'Set controller type to "' + controller_type + '" for ' + bcolors.BOLD + prefixed_controller_name + bcolors.ENDC) - else: - node.get_logger().fatal(bcolors.FAIL + 'Could not set controller type to "' + controller_type + '" for ' + bcolors.BOLD + prefixed_controller_name + bcolors.ENDC) - return 1 - - ret = load_controller(node, controller_manager_name, controller_name) - if not ret.ok: - node.get_logger().fatal(bcolors.FAIL + 'Failed loading controller ' + bcolors.BOLD + prefixed_controller_name + bcolors.ENDC) - return 1 - node.get_logger().info(bcolors.OKBLUE + 'Loaded ' + bcolors.BOLD + prefixed_controller_name + bcolors.ENDC) - - if param_file: - load_parameter_file(node=node, node_name=prefixed_controller_name, parameter_file=param_file, - use_wildcard=True) - node.get_logger().info(bcolors.OKCYAN + 'Loaded parameters file "' + param_file + '" for ' + bcolors.BOLD + prefixed_controller_name + bcolors.ENDC) - # TODO(destogl): use return value when upstream return value is merged - # ret = - # if ret.returncode != 0: - # Error message printed by ros2 param - # return ret.returncode - node.get_logger().info('Loaded ' + param_file + ' into ' + prefixed_controller_name) - - if not args.load_only: - ret = configure_controller(node, controller_manager_name, controller_name) - if not ret.ok: - node.get_logger().error('Failed to configure controller') - return 1 - - if not args.stopped and not args.inactive: - ret = switch_controllers( - node, - controller_manager_name, - [], - [controller_name], - True, - True, - 5.0) - if not ret.ok: - node.get_logger().error('Failed to activate controller') - return 1 - - node.get_logger().info(bcolors.OKGREEN + 'Configured and activated ' + - bcolors.BOLD + prefixed_controller_name + bcolors.ENDC) - elif args.stopped: - node.get_logger().warn('"--stopped" flag is deprecated use "--inactive" instead') -======= for controller_name in controller_names: prefixed_controller_name = controller_name if controller_namespace: @@ -392,7 +323,6 @@ def main(args=None): + "Configured and activated all the parsed controllers list!" + bcolors.ENDC ) ->>>>>>> 4e78813 (Update spawner to accept controllers list and start them in sequence (#1139)) if not args.unload_on_kill: return 0 @@ -402,25 +332,12 @@ def main(args=None): while True: time.sleep(1) except KeyboardInterrupt: -<<<<<<< HEAD - if not args.stopped and not args.inactive: - node.get_logger().info('Interrupt captured, deactivating and unloading controller') - ret = switch_controllers( - node, - controller_manager_name, - [controller_name], - [], - True, - True, - 5.0) -======= if not args.inactive: node.get_logger().info("Interrupt captured, deactivating and unloading controller") # TODO(saikishor) we might have an issue in future, if any of these controllers is in chained mode ret = switch_controllers( node, controller_manager_name, controller_names, [], True, True, 5.0 ) ->>>>>>> 4e78813 (Update spawner to accept controllers list and start them in sequence (#1139)) if not ret.ok: node.get_logger().error('Failed to deactivate controller') return 1