Reputation: 5
there is a possibility to load 2 yaml files in launch file like in ros1?
in ros1 i can do
<node name="node1" type="node1" pkg="pkg1" output="log">
<rosparam command="load" file="$file1.yaml"/>
<rosparam command="load" file="$file2.yaml"/>
</node>
i want to know if we can do the same in ros2 (foxy) i know that i can load one file like this
def generate_launch_description():
path_file = 'test.yaml'
file_parameters = os.path.join(
get_package_share_directory('pkg1'),
'config',
path_file
)
return LaunchDescription([
Node(
package="pkg1",
executable="node1",
name="node1",
output="screen",
parameters=[file_parameters
]
)
])
there is a way to load 2 yaml files in ros2?
Upvotes: 0
Views: 985
Reputation: 341
Yes you can simply define another path for the second .yaml and append it to the parameters.
Example:
def generate_launch_description():
first_path_file = 'test.yaml'
second_path_file = 'second_test.yaml'
first_file_parameters = os.path.join(
get_package_share_directory('pkg1'),
'config',
path_file
)
second_file_parameters = os.path.join(get_package_share_directory(
('pkg1'),
'config',
second_path_file)
return LaunchDescription([
Node(
package="pkg1",
executable="node1",
name="node1",
output="screen",
parameters=[first_file_parameters, second_file_parameters
]
)
])
Mind that you can define parameters for multiple nodes in one .yaml, this could be a cleaner solution.
Upvotes: 0