Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Providing your two launch file could be nice but I see your issue here.

Your launch file is probably looking like that :

<launch>
    <include file="$(find your_pkg)/launch_1/launchfile.launch"/>
    <include file="$(find your_pkg)/launch_2/launchfile.launch"/> 
</launch>

It creates an issue if there are nodes with the same name. To avoid that you have different solutions :

  • Add a namespace in the include tag :

    <launch>
    <include file="$(find your_pkg)/launch_1/launchfile.launch" ns="namespace1"/>
    <include file="$(find your_pkg)/launch_2/launchfile.launch" ns="namespace2"/> 
    </launch>
    

Like that you will have nodes from the first include named /namespace1/node and from the second include /namespace2/node.

  • Or you can set the name configurable with arguments. Inside yourlaunch files instead of <node pkg="node" type="node" name="your_node_name"/> you can have :

    <arg name="node_name_arg" default="a_name"/>
    <node pkg="node" type="node" name="$(arg node_name_arg)"/>
    

And your launch file would be :

<launch>
     <include file="$(find your_pkg)/launch_1/launchfile.launch">
           <arg name="node_name_arg" value="node_name_1"/>
     </include>
     <include file="$(find your_pkg)/launch_2/launchfile.launch">
           <arg name="node_name_arg" value="node_name_2"/>
     </include>
</launch>

That is to answer your question BUT you took joint_state_publisher as an exemple but that means you try to launch it twice which is not right. It would be like if you wanted to launch rviz for each of your launch files eventhough it will gather the same data since it subscribes to topics. The right thing to do is to clean up a little bit your launch files to contain only the different nodes, the commons ones should be on the main launch file, like that :

<launch>
     <!-- Launch all the commons nodes for exemple robot_state_publisher and rviz -->
     <node pkg="robot_state_publisher" type="robot_state_publisher" name="spr">
        <param name="publish_frequency" type="double" value="30.0" />
     </node
     <node name="rviz" pkg="rviz" type="rviz"/>

     <!-- Launch your launch files containing specifics packages -->
     <include file="$(find your_pkg)/launch_1/launchfile.launch"/>
     <include file="$(find your_pkg)/launch_2/launchfile.launch"/>
</launch>

And you might want to create a standalone launch file launching the nodes required for each of your different launch files.

Providing your two launch file could be nice but I see your issue here.

Your launch file is probably looking like that :

<launch>
    <include file="$(find your_pkg)/launch_1/launchfile.launch"/>
    <include file="$(find your_pkg)/launch_2/launchfile.launch"/> 
</launch>

It creates an issue if there are nodes with the same name. To avoid that you have different solutions :

  • Add a namespace in the include tag :

    <launch>
    <include file="$(find your_pkg)/launch_1/launchfile.launch" ns="namespace1"/>
    <include file="$(find your_pkg)/launch_2/launchfile.launch" ns="namespace2"/> 
    </launch>
    

Like that you will have nodes from the first include named /namespace1/node and from the second include /namespace2/node.

  • Or you can set the name configurable with arguments. Inside yourlaunch files instead of <node pkg="node" type="node" name="your_node_name"/> you can have :

     <arg name="node_name_arg" default="a_name"/>
     <node pkg="node" type="node" name="$(arg node_name_arg)"/>
    

And your launch file would be :

<launch>
     <include file="$(find your_pkg)/launch_1/launchfile.launch">
           <arg name="node_name_arg" value="node_name_1"/>
     </include>
     <include file="$(find your_pkg)/launch_2/launchfile.launch">
           <arg name="node_name_arg" value="node_name_2"/>
     </include>
</launch>

That is to answer your question BUT you took joint_state_publisher as an exemple but that means you try to launch it twice which is not right. It would be like if you wanted to launch rviz for each of your launch files eventhough it will gather the same data since it subscribes to topics. The right thing to do is to clean up a little bit your launch files to contain only the different nodes, the commons ones should be on the main launch file, like that :

<launch>
     <!-- Launch all the commons nodes for exemple robot_state_publisher and rviz -->
     <node pkg="robot_state_publisher" type="robot_state_publisher" name="spr">
        <param name="publish_frequency" type="double" value="30.0" />
     </node
     <node name="rviz" pkg="rviz" type="rviz"/>

     <!-- Launch your launch files containing specifics packages -->
     <include file="$(find your_pkg)/launch_1/launchfile.launch"/>
     <include file="$(find your_pkg)/launch_2/launchfile.launch"/>
</launch>

And you might want to create a standalone launch file launching the nodes required for each of your different launch files.

Providing your two launch file could be nice but I see your issue here.

Your launch file is probably looking like that :

<launch>
    <include file="$(find your_pkg)/launch_1/launchfile.launch"/>
    <include file="$(find your_pkg)/launch_2/launchfile.launch"/> your_pkg)/launch/launchfile_1.launch"/>
    <include file="$(find your_pkg)/launch/launchfile_2.launch"/> 
</launch>

It creates an issue if there are nodes with the same name. To avoid that you can set the name configurable with arguments. Inside yourlaunch files instead of <node pkg="node" type="node" name="your_node_name"/> you can have :

    <arg name="node_name_arg" default="a_name"/>
    <node pkg="node" type="node" name="$(arg node_name_arg)"/>

And your launch file would be :

<launch>
     <include file="$(find your_pkg)/launch_1/launchfile.launch">
your_pkg)/launch/launchfile_1.launch">
           <arg name="node_name_arg" value="node_name_1"/>
     </include>
     <include file="$(find your_pkg)/launch_2/launchfile.launch">
your_pkg)/launch/launchfile_2.launch">
           <arg name="node_name_arg" value="node_name_2"/>
     </include>
</launch>

That is to answer your question BUT you took joint_state_publisher as an exemple but that means you try to launch it twice which is not right. It would be like if you wanted to launch rviz for each of your launch files eventhough it will gather the same data since it subscribes to topics. The right thing to do is to clean up a little bit your launch files to contain only the different nodes, the commons ones should be on the main launch file, like that :

<launch>
     <!-- Launch all the commons nodes for exemple robot_state_publisher and rviz -->
     <node pkg="robot_state_publisher" type="robot_state_publisher" name="spr">
        <param name="publish_frequency" type="double" value="30.0" />
     </node
     <node name="rviz" pkg="rviz" type="rviz"/>

     <!-- Launch your launch files containing specifics packages -->
     <include file="$(find your_pkg)/launch_1/launchfile.launch"/>
     <include file="$(find your_pkg)/launch_2/launchfile.launch"/>
your_pkg)/launch/launchfile_1.launch"/>
     <include file="$(find your_pkg)/launch/launchfile_2.launch"/>
</launch>

And you might want to create a standalone launch file launching the nodes required for each of your different launch files.

Providing your two launch file could be nice but I see your issue here.

Your launch file is probably looking like that :

<launch>
    <include file="$(find your_pkg)/launch/launchfile_1.launch"/>
    <include file="$(find your_pkg)/launch/launchfile_2.launch"/> 
</launch>

It creates an issue if there are nodes with the same name. To avoid that you can set the name configurable with arguments. Inside yourlaunch files instead of <node pkg="node" type="node" name="your_node_name"/> you can have :

    <arg name="node_name_arg" default="a_name"/>
    <node pkg="node" type="node" name="$(arg node_name_arg)"/>

And your launch file would be :

<launch>
     <include file="$(find your_pkg)/launch/launchfile_1.launch">
           <arg name="node_name_arg" value="node_name_1"/>
     </include>
     <include file="$(find your_pkg)/launch/launchfile_2.launch">
           <arg name="node_name_arg" value="node_name_2"/>
     </include>
</launch>

That is to answer your question BUT you took joint_state_publisher as an exemple but that means you try to launch it twice which is not right. It would be like if you wanted to launch rviz for each of your launch files eventhough it will gather the same data since it subscribes to topics. The right thing to do is to clean up a little bit your launch files to contain only the different nodes, the commons ones should be on the main launch file, like that :

<launch>
     <!-- Launch all the commons nodes for exemple robot_state_publisher and rviz -->
     <node pkg="robot_state_publisher" type="robot_state_publisher" name="spr">
        <param name="publish_frequency" type="double" value="30.0" />
     </node
</node>
     <node name="rviz" pkg="rviz" type="rviz"/>

     <!-- Launch your launch files containing specifics packages -->
     <include file="$(find your_pkg)/launch/launchfile_1.launch"/>
     <include file="$(find your_pkg)/launch/launchfile_2.launch"/>
</launch>

And you might want to create a standalone launch file launching the nodes required for each of your different launch files.

Providing your two launch file could be nice but I see your issue here.

Your launch file is probably looking like that :

<launch>
    <include file="$(find your_pkg)/launch/launchfile_1.launch"/>
    <include file="$(find your_pkg)/launch/launchfile_2.launch"/> 
</launch>

It creates an issue if there are nodes with the same name. To avoid that you have different options :

  • Add a namespace in the include tag :

    <launch>
        <include file="$(find your_pkg)/launch/launchfile_1.launch" ns="namespace1"/>
        <include file="$(find your_pkg)/launch/launchfile_2.launch" ns="namespace2"/> 
    </launch>
    

Like that you will have nodes from the first include named /namespace1/node and from the second include /namespace2/node.

  • You can set the name configurable with arguments. Inside yourlaunch files instead of <node pkg="node" type="node" name="your_node_name"/> you can have :

     <arg name="node_name_arg" default="a_name"/>
     <node pkg="node" type="node" name="$(arg node_name_arg)"/>
    

And your launch file would be :

<launch>
     <include file="$(find your_pkg)/launch/launchfile_1.launch">
           <arg name="node_name_arg" value="node_name_1"/>
     </include>
     <include file="$(find your_pkg)/launch/launchfile_2.launch">
           <arg name="node_name_arg" value="node_name_2"/>
     </include>
</launch>

That is to answer your question BUT you took joint_state_publisher as an exemple but that means you try to launch it twice which is not right. It would be like if you wanted to launch rviz for each of your launch files eventhough it will gather the same data since it subscribes to topics. The right thing to do is to clean up a little bit your launch files to contain only the different nodes, the commons ones should be on the main launch file, like that :

<launch>
     <!-- Launch all the commons nodes for exemple robot_state_publisher and rviz -->
     <node pkg="robot_state_publisher" type="robot_state_publisher" name="spr">
        <param name="publish_frequency" type="double" value="30.0" />
     </node>
     <node name="rviz" pkg="rviz" type="rviz"/>

     <!-- Launch your launch files containing specifics packages -->
     <include file="$(find your_pkg)/launch/launchfile_1.launch"/>
     <include file="$(find your_pkg)/launch/launchfile_2.launch"/>
</launch>

And you might want to create a standalone launch file launching the nodes required for each of your different launch files.

Providing your two launch file could be nice but I see your issue here.

Your launch file is probably looking like that :

<launch>
    <include file="$(find your_pkg)/launch/launchfile_1.launch"/>
    <include file="$(find your_pkg)/launch/launchfile_2.launch"/> 
</launch>

It creates an issue if there are nodes with the same name. To avoid that you have different options :

  • Add a namespace in the include tag :

    <launch>
        <include file="$(find your_pkg)/launch/launchfile_1.launch" ns="namespace1"/>
        <include file="$(find your_pkg)/launch/launchfile_2.launch" ns="namespace2"/> 
    </launch>
    

Like that you will have nodes from the first include named /namespace1/node and from the second include /namespace2/node.

  • You can set the name configurable with arguments. Inside yourlaunch files instead of <node pkg="node" type="node" name="your_node_name"/> you can have :

    <arg name="node_name_arg" default="a_name"/>
    <node pkg="node" type="node" name="$(arg node_name_arg)"/>
    

And your launch file would be :

<launch>
     <include file="$(find your_pkg)/launch/launchfile_1.launch">
           <arg name="node_name_arg" value="node_name_1"/>
     </include>
     <include file="$(find your_pkg)/launch/launchfile_2.launch">
           <arg name="node_name_arg" value="node_name_2"/>
     </include>
</launch>

That is to answer your question BUT you took joint_state_publisher as an exemple but that means you try to launch it twice which is not right. It would be like if you wanted to launch rviz for each of your launch files eventhough it will gather the same data since it subscribes to topics. The right thing to do is to clean up a little bit your launch files to contain only the different nodes, the commons ones should be on the main launch file, like that :

<launch>
     <!-- Launch all the commons nodes for exemple robot_state_publisher and rviz -->
     <node pkg="robot_state_publisher" type="robot_state_publisher" name="spr">
        <param name="publish_frequency" type="double" value="30.0" />
     </node>
     <node name="rviz" pkg="rviz" type="rviz"/>

     <!-- Launch your launch files containing specifics packages -->
     <include file="$(find your_pkg)/launch/launchfile_1.launch"/>
     <include file="$(find your_pkg)/launch/launchfile_2.launch"/>
</launch>

And you might want to create a standalone launch file launching the nodes required for each of your different launch files.

Providing your two launch file could be nice but I see your issue here.

Your launch file is probably looking like that :

<launch>
    <include file="$(find your_pkg)/launch/launchfile_1.launch"/>
    <include file="$(find your_pkg)/launch/launchfile_2.launch"/> 
</launch>

It creates an issue if there are nodes with the same name. To avoid that you have different options :

  • Add a namespace in the include tag :

    <launch>
        <include file="$(find your_pkg)/launch/launchfile_1.launch" ns="namespace1"/>
        <include file="$(find your_pkg)/launch/launchfile_2.launch" ns="namespace2"/> 
    </launch>
    

Like that you will have nodes from the first include named /namespace1/node and from the second include /namespace2/node.

  • You can set the name configurable with arguments. Inside yourlaunch files instead of <node pkg="node" type="node" name="your_node_name"/> you can have :

    <arg name="node_name_arg" default="a_name"/>
    <node pkg="node" type="node" name="$(arg node_name_arg)"/>
    

And your launch file would be :

<launch>
     <include file="$(find your_pkg)/launch/launchfile_1.launch">
           <arg name="node_name_arg" value="node_name_1"/>
     </include>
     <include file="$(find your_pkg)/launch/launchfile_2.launch">
           <arg name="node_name_arg" value="node_name_2"/>
     </include>
</launch>

That is to answer your question BUT you took joint_state_publisher as an exemple but that means you try to launch it twice which is not right. It would be like if you wanted to launch rviz for each of your launch files eventhough it will gather the same data since it subscribes to topics. The right thing to do is to clean up a little bit your launch files to contain only the different nodes, the commons ones should be on the main launch file, like that :

<launch>
     <!-- Launch all the commons nodes for exemple robot_state_publisher and rviz -->
     <node pkg="robot_state_publisher" type="robot_state_publisher" name="spr">
        <param name="publish_frequency" type="double" value="30.0" />
     </node>
     <node name="rviz" pkg="rviz" type="rviz"/>

     <!-- Launch your launch files containing specifics packages -->
     <include file="$(find your_pkg)/launch/launchfile_1.launch"/>
     <include file="$(find your_pkg)/launch/launchfile_2.launch"/>
</launch>

And you might want to create a standalone launch file launching the nodes required for each of your different launch files.