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

How to include a launch file from another node into a current project

asked 2020-06-05 09:29:32 -0500

RayROS gravatar image

I am launching a specific node called roslaunch lidar_deck lidar_deck_rosbag.launch

I created another node called tugInterface, and that also has a launch file called roslaunch tugInterface tuginterface.launch. I circled it in red below.

The problem:

I am trying to include the launch file called roslaunch tugInterface tuginterface.launch into the roslaunch lidar_deck lidar_deck_rosbag.launch but with no success.

Below the lidar_deck lidar_deck_rosbag.launch:

node

<?xml version="1.0" ?>
<launch>
  <param name="/use_sim_time" value="false"/>
  <node pkg="tf" type="static_transform_publisher" name="segment_frame" args="0 0 0 0 0 0 1 base_footprint segment_frame 10"/>

  <node pkg="lidar_boat_detection" type="process_lidar" name="process_lidar" />
  <node pkg="tf" type="static_transform_publisher" name="velodyne_bag_tranform" args="0 0 0 0 0 0 1 base_footprint velodyne 10"/>
  <!-- RViz -->
  <arg name="rviz" default="true"/>
  <node if="$(arg rviz)" pkg="rviz" type="rviz" name="$(anon rviz)" respawn="false" args="-d $(find lidar_deck)/rviz/lidar_deck_rosbag.rviz" />

</launch>

I tried also the following version but that also did not work:

<?xml version="1.0" ?>
<launch>
  <param name="/use_sim_time" value="false"/>
  <node pkg="tf" type="static_transform_publisher" name="segment_frame" args="0 0 0 0 0 0 1 base_footprint segment_frame 10"/>

  <node pkg="lidar_boat_detection" type="process_lidar" name="process_lidar" />
  <node pkg="tf" type="static_transform_publisher" name="velodyne_bag_tranform" args="0 0 0 0 0 0 1 base_footprint velodyne 10"/>

<include file="$(find tugInterface)/launch/tuginterface.launch" />
<node pkg="tugInterface" type="tuginterface" name ="tuginterface" />

  <!-- RViz -->
  <arg name="rviz" default="true"/>
  <node if="$(arg rviz)" pkg="rviz" type="rviz" name="$(anon rviz)" respawn="false" args="-d $(find lidar_deck)/rviz/lidar_deck_rosbag.rviz" />

</launch>

In addition to that I also tried to add <rosparam command="load" file="$(find tugInterface)/tuginterface.launch" /> to the launch file but still didn't work. How can I solve that? Thanks for pointing to the right direction.

edit retag flag offensive close merge delete

Comments

Have you sourced both workspaces? I think otherwise it will not find the other node. Oh sorry, your headline is a little bit confusing, because they are all in the same workspace/project.

MrCheesecake gravatar image MrCheesecake  ( 2020-06-05 09:47:05 -0500 )edit

Hello and thanks for reading the question. Yes the workspace is outsourced. I did it in the .basrh file so that I didn't have to worry.

RayROS gravatar image RayROS  ( 2020-06-05 09:49:34 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2020-06-05 10:01:23 -0500

MrCheesecake gravatar image

updated 2020-06-05 10:03:02 -0500

Your include command looks fine, here is an example of a launch file that works for me:
node_master.launch:

<launch>
    <rosparam command="load" file="$(find node_master)/config/node_master.yaml" />
    <include file="$(find node_1)/launch/full.launch"/>
    <include file="$(find node_2)/launch/full.launch"/>
    <include file="$(find node_3)/launch/full.launch"/>
</launch>

node_1/launch/full.launch:

   <launch>
        <node name="node_1_node" pkg="node_1" type="node_1_node" output="screen"/>
        <rosparam command="load" file="$(find node_1)/config/param.yaml" />
    </launch>

But I think you are using this wrong:
After including the launch file of tugInterface you are starting the node inside the same launchfile.
That node should be instead started in the lauchfile you include, otherwise it's not needed to include that launchfile at all.
You should be able to start that node without including it's launchfile.

edit flag offensive delete link more

Comments

1

I see the mistake I am making. Thank you very much your clarification just helped me solve the problem! :)

RayROS gravatar image RayROS  ( 2020-06-05 10:08:19 -0500 )edit

You are welcome!

MrCheesecake gravatar image MrCheesecake  ( 2020-06-05 10:11:55 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2020-06-05 09:29:32 -0500

Seen: 233 times

Last updated: Jun 05 '20