Launch component into container defined by included launch file
Hi
This question can be regarded as an extension of the question https://answers.ros.org/question/3781... and https://answers.ros.org/question/3069....
Situation: I have a "base" launch file which describes a collection of nodes. Some of these nodes are launched in a component container. The base launch file is already fairly complex. I do not want to add to it any further.
Goal: To further expand the project, I want to build upon the base rather than to change it. I want to create a launch file which includes the base launch file and then describes some more nodes to launch. Some of these nodes need to be added to the component container which is described by the included launch file.
This is what I have so far (includes omitted for readability):
base_package_directory = get_package_share_directory('base_package')
base_launch_description = IncludeLaunchDescription(PythonLaunchDescriptionSource(base_package + '/launch/base.py'))
base_container = next(e for e in base_vehicle.get_sub_entities()[0].entities if isinstance(e, ComposableNodeContainer))
additional_node = LoadComposableNodes(
composable_node_descriptions = [ComposableNode(
name = 'additional_node',
package = 'additional_package',
plugin = 'additional_node',
)],
target_container = base_container,
)
return launch.LaunchDescription([base_launch_description, additional_node])
This looks terribly ugly. Also, it results in an error:
RuntimeError: cannot access 'node_name' before executing action
Where node_name
is an attribute of the ComposableNodeContainer
"base_container".
My guts are telling me "you are doing it wrong" – especially when looking at line 2 and 3. How do I do this right?
Kind regards
Hermann