What is a ROS Launch File?

What is a ROS launch file? As we did for ROS parameters, let’s first start with the problem.

This post is a part of the What is ROS? series.

Your robotics application is growing

Let’s say you now have an application with 6 nodes and 10 parameters.

When you want to start your application, you need, first to start the ROS master with roscore. Then you have to set all the different parameters, either from a terminal, or from the code you write inside nodes.

You need to make sure you start your nodes in the right order, or else you might be missing some parameters.

What is a ROS launch file ? 1/2


You are learning ROS?

Check out ROS For Beginners and learn ROS step by step.


Long story short: you’ll end up with many open terminals, this will be messy, and your development process will exponentially slow down.

As you can see, that’s really not scalable at all. You’ll quickly have dozens of terminals open with all your nodes, and debugging your application will become a nightmare with all the parameters and nodes on your ROS environment.

The solution: use ROS launch files

Here come the launch files that will save you.

Basically, a launch file will allow you to start everything you need, from just one file. You can create as many parameters and start as many nodes as you want.

What is a ROS launch file ? 2/2

In this launch file example, you first set all 10 ROS parameters. Then, you start all nodes one by one, in the order you want.

You can also create groups of parameters and nodes with a prefix. You can even use some conditional statements, and combine multiple launch files inside one launch file.

This way, you will be able to quickly launch your application, and to create different launch files for different startup modes of your robot.

To give you a real life example, the robot I am currently programming has more than 15 nodes and maybe 200 parameters. Without using launch files, it would be impossible to start the robot application.

It also brings many advantages when it comes to debugging one specific area of your application. You can decide to start all the parts of your application from a launch file, except one node. And then, start the node in a different terminal, so you can quickly monitor it, relaunch it, and debug it, without affecting the rest of your application.

All in all, ROS launch files will make you save a lot of time when developing robotics application. I strongly encourage you to get your head around them, and start using them as soon as possible!

Did you find this tutorial useful?

Do you want to learn how to program with ROS?

If yes, this course is for you:

ROS For Beginners - A Step By Step Course

>> ROS For Beginners - A Step By Step Course <<