Unit2: what's the point of Launch files?

Hello,

By the end of Unit2, we have 2 ways to start our simple.py script.
ros2 launch my_package long_launch_name.py
ros2 run my_package short_nickname

Looking at long_launch_name.py, all it does is tell ros2 to launch the script using the short_nickname

So using launch over run requires:

  • setting up an extra file
  • write a small script referring to the executable nickname
  • writing a full file name with extension each time I use the launch command

I know it’s still very basic level of Ros2 at this point, but any hint as to why I’d want to create a launch file over just using “ros2 run” directly?

Hi @sebjapon,
There are many reasons to write launch files. In the context of a course, the approach seems rather pedagogical.
For real projects, there are many reasons, for example:

  • Launch several nodes simultaneously from a single terminal
  • Launch nodes with parameters (very useful when tuning models).
  • It can also allow you to group code execution by functionality (and launch/restart only part of your application).
    Generally speaking, writing ROS launches is good practice, but if you only have one node to run and no parameters, it’s a bit of an overkill.
1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.