Parameters from Yaml file did not appear when doing ros2 param list

asked 2023-06-07 23:24:47 -0500

jenanaputra gravatar image

I am using ros2 humble in my jammy ubuntu distro. I tried to get the parameter from my params.yml. When I tried to launch the launch file, then I tried to do ros2 param list, just use_sim_time that appeared instead the parameter that I set in the params.yml. For further information, I also attached my launch file.

from launch import LaunchDescription

from launch_ros.actions import Node

from launch.actions import DeclareLaunchArgument

from launch.substitutions import LaunchConfiguration

def generate_launch_description():
    params_file = "/home/janana/ros2_ws/src/br_navigator_ros/br_navigator_bringup/config/params.yml"

# Declare a launch argument to specify the parameters file
params_arg = DeclareLaunchArgument(
    name="params_file",
    default_value=params_file,
    description="Path to the YAML parameters file"
)

# Create a node
node = Node(
    package='br_pca9685',
    executable='pca9685_node_ver.py',
    name= 'pca9685',
    parameters=[LaunchConfiguration('params_file')]
)

# Create the launch description
ld = LaunchDescription()

# Add the launch argument and node to the launch description
ld.add_action(params_arg)
ld.add_action(node)

return ld

if __name__ == '__main__':
    generate_launch_description()

I have already install the config directory in my CMakeList.txt

install(
    DIRECTORY launch config
    DESTINATION share/${PROJECT_NAME})

This is the content of my params.yml :

pca9685:
  ros__parameters:
    bool_array: [True, True, False, False, True, True, False, True]

Does anyone know how to solve this ?

edit retag flag offensive close merge delete