ROS 2 launch file mixins round 2

Sorry as the old topic was closed (ROS 2 launch files as Mixins) here round 2.

Played some more with launch mixins, GitHub - mhubii/demo_launch: ROS 2 launch files as mixins.

In fact, every ROS 2 launch package could be structured such that launch files can be imported via

from launch_mixins.my_amazing_package import AmazingLaunch

E.g. using include launch descriptions

from launch.actions import IncludeLaunchDescription
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.substitutions import PathJoinSubstitution
from launch_ros.substitutions import FindPackageShare

turns into

from launch_mixins.demo_launch import TurtleSimMixin, HelloWorldMixin

And then nodes can be launch a la

ld = LaunchDescription()

# add turtlesim
ld.add_action(TurtleSimMixin.arg_node_name())
ld.add_action(TurtleSimMixin.node_turtlesim())

Or mixed and matched

class MyNewLaunch(HelloWorldMixin, TurtleSimMixin):
    pass

This works for ament_python and ament_cmake, and if many people would default to launch_mixins.package_name, think this might help launch flexible projects.

Wonder how other people structure their launch files, or if this suggestion is not scalable. Happy to learn more!

I don’t really understand what mixins add in terms of functionality.
Are mixin lauch files a kind of meta launch file type that controls other launch files?

Keep asking myself the same question.

Organizing launch functionality via this mechanism makes understanding required / available functionality of a package slightly better understandable. This can be helpful when provided launch files don’t match the requirements perfectly and modifications are needed.

But I am not 100% convinced this approach makes sense.

If I understand this correctly, you’re the one promoting this system and you’re telling me that you don’t know whether this system makes sense. To be honest, that leaves me even more sceptical than before.
While ROS2 offers flexibility with multiple launch file formats YAML, XML, and Python, it can be challenging for newcomers to learn due to the lack of a single, unified standard. Each format has its own advantages and disadvantages, making it difficult to get a clear overview and choose the best approach - as determined in the correlating ROS2 Design document. Additionally, complex launch files, like the one I encountered in my working group , can be cumbersome to understand . To improve user experience, it would be beneficial to consider a more standardized approach to ROS2 launch files.

1 Like

I see your point. Just wanted to share this form of organization assuming Python launch modules to help re-iterate on the mixin idea, learn how others organize their launch files etc!

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