[ROS in 5 mins] 017 – How to include a launch file inside a launch file

[ROS-in-5-mins]-017-How-to-include-a-launch-file-inside-a-launch-file

Written by Ruben Alves

07/07/2018

Hello ROS Developers!

In today’s video we are going to see how to include a ROS launch file inside of another one, which is really useful specially if you are working with big projects.

But before we start, if you are new to ROS and want to Learn ROS Fast, I recommend you to take any of the following courses on Robot Ignite Academy:

ROS Basics In 5 Days (Python)
ROS Basics In 5 Days (C++)

Whether you like the video or not, please leave a comment on the comments section below, so we can interact and learn from each other.

Step1. Create a project in Robot Ignite Academy(RIA)

We have the best online ROS course available in RIA. It helps you learn ROS in the easiest way without setting up ROS environment locally. The only thing you need is a browser! Create an account here and start to browse the trial course for free now! We’ll use the TF ROS 101 course as an example today.

Step2. Create a package

With the following command, you can create a package without any dependency from a shell

cd ~/catkin_ws/src
catkin_create_pkg tutorial

Let’s say we want to create a launch file called include_demo.launch to launch another launch file called listener_with_user_data.launch from rospy_tutorial package. We can use the include tag in our launch file like this

<launch>
    <include file="$(find rospy_tutorials)/003_listener_with_user_data/listener_with_user_data.launch" />
</launch>

Then you run roslaunch tutorial include_demo.launch . You should see the talker nodes launched by the tutorial. You can also specify namespace like following  to launch the same file with different namespace multiple times.

<launch> 
    <include ns="robot1" file="$(find rospy_tutorials)/003_listener_with_user_data/listener_with_user_data.launch" /> 
    <include ns="robot2" file="$(find rospy_tutorials)/003_listener_with_user_data/listener_with_user_data.launch" /> 
</launch>

This technic is especially useful when you are running a huge project. You can also specify different TF coordinate to the different robot in a similar way.

If you are interested in how to define multiple robot joints coordinates using TF, please check our TF ROS 101 course.

 

Edit by: Tony Huang

Masterclass 2023 batch2 blog banner

Check Out These Related Posts

0 Comments

Submit a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Pin It on Pinterest

Share This