Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Spawner - utils] Improve launch utils to support the multiple controller names (backport #1782) #1783

Merged
merged 1 commit into from
Oct 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 27 additions & 11 deletions controller_manager/controller_manager/launch_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@
from launch_ros.actions import Node


def generate_load_controller_launch_description(
controller_name, controller_type=None, controller_params_file=None, extra_spawner_args=[]
def generate_controllers_spawner_launch_description(
controller_names: list,
controller_type=None,
controller_params_file=None,
extra_spawner_args=[],
):
"""
Generate launch description for loading a controller using spawner.
Expand All @@ -32,11 +35,11 @@ def generate_load_controller_launch_description(
Examples
--------
# Assuming the controller type and controller parameters are known to the controller_manager
generate_load_controller_launch_description('joint_state_broadcaster')
generate_controllers_spawner_launch_description(['joint_state_broadcaster'])
# Passing controller type and controller parameter file to load
generate_load_controller_launch_description(
'joint_state_broadcaster',
# Passing controller type and parameter file to load the controller
generate_controllers_spawner_launch_description(
['joint_state_broadcaster'],
controller_type='joint_state_broadcaster/JointStateBroadcaster',
controller_params_file=os.path.join(get_package_share_directory('my_pkg'),
'config', 'controller_params.yaml'),
Expand All @@ -55,11 +58,13 @@ def generate_load_controller_launch_description(
description="Wait until the node is interrupted and then unload controller",
)

spawner_arguments = [
controller_name,
"--controller-manager",
LaunchConfiguration("controller_manager_name"),
]
spawner_arguments = controller_names
spawner_arguments.extend(
[
"--controller-manager",
LaunchConfiguration("controller_manager_name"),
]
)

if controller_type:
spawner_arguments += ["--controller-type", controller_type]
Expand Down Expand Up @@ -98,3 +103,14 @@ def generate_load_controller_launch_description(
spawner,
]
)


def generate_load_controller_launch_description(
controller_name: str, controller_type=None, controller_params_file=None, extra_spawner_args=[]
):
return generate_controllers_spawner_launch_description(
controller_names=[controller_name],
controller_type=controller_type,
controller_params_file=controller_params_file,
extra_spawner_args=extra_spawner_args,
)
Loading