Skip to content

Commit

Permalink
fix spawner conflicts - contd
Browse files Browse the repository at this point in the history
  • Loading branch information
bmagyar committed Oct 31, 2023
1 parent 56991d4 commit 2e598c8
Showing 1 changed file with 0 additions and 83 deletions.
83 changes: 0 additions & 83 deletions controller_manager/controller_manager/spawner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 2e598c8

Please sign in to comment.