Skip to content

Commit

Permalink
aplly suggestions from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
mamueluth committed Feb 21, 2023
1 parent 96aaf9a commit 9c969e9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
13 changes: 6 additions & 7 deletions controller_manager/controller_manager/hardware_spawner.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
# Copyright 2023 PAL Robotics S.L.
# Copyright 2023 Stogl Robotics Consulting UG (haftungsbeschränkt)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -157,7 +157,6 @@ def main(args=None):
"hardware_component_name",
help="The name of the hardware component which should be activated.",
)

parser.add_argument(
"-c",
"--controller-manager",
Expand All @@ -173,13 +172,13 @@ def main(args=None):
type=int,
)

# add arguments which are mutually exclusive
activate_or_confiigure_grp.add_argument(
"--activate",
help="Activates the given components. Note: Components are by default configured before activated. ",
action="store_true",
required=False,
)

activate_or_confiigure_grp.add_argument(
"--configure",
help="Configures the given components.",
Expand All @@ -195,15 +194,14 @@ def main(args=None):
activate = args.activate
configure = args.configure

print(type(hardware_component))

node = Node("hardware_spawner")
if not controller_manager_name.startswith("/"):
spawner_namespace = node.get_namespace()
if spawner_namespace != "/":
controller_manager_name = f"{spawner_namespace}/{controller_manager_name}"
else:
controller_manager_name = f"/{controller_manager_name}"

try:
if not wait_for_controller_manager(
node, controller_manager_name, controller_manager_timeout
Expand All @@ -216,10 +214,11 @@ def main(args=None):
elif configure:
configure_components(node, controller_manager_name, hardware_component)
else:
node.get_logger().warn("Something went wrong.")
node.get_logger().error(
'You need to either specify if the hardware component should be activated with the "--activate" flag or configured with the "--configure" flag'
)
parser.print_help()
return 0

finally:
rclpy.shutdown()

Expand Down
4 changes: 2 additions & 2 deletions controller_manager/src/controller_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,8 @@ void ControllerManager::init_resource_manager(const std::string & robot_descript
{
RCLCPP_WARN_STREAM(
get_logger(),
"[Deprecated]: Automatic activation of all components will not be supported in the future "
"anymore. Use hardware_spawner instead.");
"[Deprecated]: Automatic activation of all hardware components will not be supported in the "
"future anymore. Use hardware_spawner instead.");
resource_manager_->activate_all_components();
}
}
Expand Down

0 comments on commit 9c969e9

Please sign in to comment.