ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

Do the names have to match

No.

will the name given in the launch file simply overwrite the one given in the .cpp?

Yes.

what would happen if my executable contains multiple nodes? How do I distinguish them in the launch file?

One executable contains one node. However, you may want to run one node many times. In this situation, you should assign unique name to each node. For example, consider you are trying to use 2 cameras. You have already written the node which process image from camera. You can simply do the following:

camera_node_1 = Node(
            package='my_camera_pkg',
            executable='image_proc',
            name='camera_1',         # <- assign a unique name here
            output='screen',
            parameters=[camera_serial_no]
        )
camera_node_2 = Node(
            package='my_camera_pkg',
            executable='image_proc',
            name='camera_2',         # <- assign a unique name here
            output='screen',
            parameters=[camera_serial_no]
        )

This is one feature out of many great features provided by launch files. It allows you to change the name, namespace, etc., without touching the code.

Do the names have to match

No.

will the name given in the launch file simply overwrite the one given in the .cpp?

Yes.

what would happen if my executable contains multiple nodes? How do I distinguish them in the launch file?

One executable contains one node. However, you may want to run one node many times. In this situation, you should assign a unique name to each node. For example, consider you are trying to use 2 two cameras. You have already written the node which process image from a camera. You Therefore, you can simply do the following:

camera_node_1 = Node(
            package='my_camera_pkg',
            executable='image_proc',
            name='camera_1',         # <- assign a unique name here
            output='screen',
            parameters=[camera_serial_no]
        )
camera_node_2 = Node(
            package='my_camera_pkg',
            executable='image_proc',
            name='camera_2',         # <- assign a unique name here
            output='screen',
            parameters=[camera_serial_no]
        )

This is one feature out of many great features provided by launch files. It allows you to change the name, namespace, etc., without touching the code.

code.