1
$\begingroup$

Rosanswers logo

Currently, in all the examples I have seen, load a YAML file inside the Launch file, and pass it to the ROS2 node. I am curious, is there a possibility to pass more than one YAML file to a ROS2 Node?

Something like:

def generate_launch_description():
    ld = LaunchDescription()
    paramaters_one = os.path.join(
        get_package_share_directory('my_robot_bringup'),
        'config',
        'my_params1.yaml'
    )

    paramaters_two = os.path.join(
        get_package_share_directory('my_robot_bringup'),
        'config',
        'my_params2.yaml'
    )

    multiple_parameters_node = Node(
        package='my_robot_bringup',
        executable='multiple_parameters_check',
        name='multiple_parameters_check',
        parameters=[paramaters_one, paramaters_two]
    )
    ld.add_action(multiple_parameters_node)
    return ld

Originally posted by Raza Rizvi on ROS Answers with karma: 95 on 2022-01-24

Post score: 0

$\endgroup$

2 Answers 2

0
$\begingroup$

Rosanswers logo

From @destogl https://discourse.ros.org/t/can-we-pass-multiple-config-files-to-a-node-in-ros2/23970/2?u=tfoote

You can find an example how we are doing it in UR Driver repository. For loading files, please check the few lines before.


Originally posted by tfoote with karma: 58457 on 2022-01-24

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by Raza Rizvi on 2022-01-25:
This should work in my case, thanks a lot.

Comment by tfoote on 2022-01-25:
Please use the checkmark at the left of the answer to accept it so others will know that your question is resolved.

$\endgroup$
0
$\begingroup$

With static typing you can setup two, or multiple files.


from launch.substitutions import LaunchConfiguration, PathJoinSubstitution
from typing import Sequence

def generate_launch_description():
    ld = LaunchDescription()
    paramaters_one = PathJoinSubstitution([
        get_package_share_directory('my_robot_bringup'),
        'config',
        'my_params1.yaml']
    )

    paramaters_two = PathJoinSubstitution([
        get_package_share_directory('my_robot_bringup'),
        'config',
        'my_params2.yaml']
    )

    params_combined: Sequence = [paramaters_one, paramaters_two]

    multiple_parameters_node = Node(
        package='my_robot_bringup',
        executable='multiple_parameters_check',
        name='multiple_parameters_check',
        parameters=params_combined
    )
    ld.add_action(multiple_parameters_node)
    return ld

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.