ros2 / demos

Apache License 2.0
502 stars 330 forks source link

How to load parameters in component? #587

Closed zhihuiLiang closed 1 year ago

zhihuiLiang commented 1 year ago

I want to load a node in component.There are some parameters in the node.I wrote the launch file like this

def generate_launch_description():
    config = os.path.join(get_package_share_directory(
                            'engineer_bringup'), 'config/engineer_bringup.yaml')

    container = ComposableNodeContainer(
            name='engineer_container',
            namespace='',
            package='rclcpp_components',
            executable='component_container',
            composable_node_descriptions=[
                ComposableNode(
                    package='video_img_publisher',
                    plugin='img_publisher::VideoImgPublisher',
                    name='video_img_publisher',
                    parameters=[config]),
            ],
            output='screen',
    )

    return launch.LaunchDescription([container])

And the yaml file like this

/video_img_publisher:
  ros__parameters:
    video_path: /home/lzh/test.map4
    fps: 30
    fov: 30.0
    width: 640
    height: 480

But the node always run with default parameter.So I want to know how to load the parameters in the component.

clalancette commented 1 year ago

Please open questions like this on https://answers.ros.org, which is our central Question and Answer site. You'll get a better answer there, and it will be searchable for the future.

Make sure to include a lot of information on what platform you are using, which ROS distribution you are using, and the exact steps you took.