Changing default parameters for node in LaunchDescription

Hi,
I’m trying to create something that needs to dynamically manage and spawn nodes. I’m launching a LaunchDescription but running into an issue where if a parameter is set after launching, and the node crashes and respawns, the parameter gets reset to its “default” value specified in the LaunchDescription.

This is understandable why this happens, but is there a clean way to update the LaunchDescription after it launches? For example something like:

launch_description = LaunchDescription([
        Node(
            package='foo_package',
            executable='foo_node,
            output='screen',
            name='foo_node',
            respawn=True,
            respawn_delay=2,
            parameters=[{"my_param": "my_value"}],
        )])
    )
service = LaunchService()
service.include_launch_description(launch_description)
service.run()

But then in some thread, be able to do something like:

service.launch_description[0].parameters[0] = {"my_param": "my_value_new"}

with the expectation that if foo_node gets respawned, it now gets respawned with my_param set to "my_value_new"?

Thanks!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.