ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A answers.ros.org
Ask Your Question
0

ROS2 share launch code

asked 2021-08-17 09:14:44 -0500

veverak gravatar image

Hi,

I have two packages that share some launch file logic (like how to find proper .urdf file and some set of shared launch files) that I could store in third package that is a myproject_lib package holding shared codebase.

How to ideally share such a code designed for launch files between packages? can I expect that I can import myproject_lib in the launch files? or is there some different way?

Thanks

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-08-17 09:39:32 -0500

Airuno2L gravatar image

It depends on if the launch file of your third package is Python, XML, or YAML. Either way, how to do it is covered here: https://docs.ros.org/en/galactic/Guid...

I'll copy pasta here:

Python:

    # include another launch file
launch_include = IncludeLaunchDescription(
    PythonLaunchDescriptionSource(
        os.path.join(
            get_package_share_directory('demo_nodes_cpp'),
            'launch/topics/talker_listener.launch.py'))
)

XML:

  <!-- include another launch file -->
  <include file="$(find-pkg-share demo_nodes_cpp)/launch/topics/talker_listener.launch.py"/>

YAML:

# include another launch file
- include:
    file: "$(find-pkg-share demo_nodes_cpp)/launch/topics/talker_listener.launch.py"
edit flag offensive delete link more

Comments

That is not what I want, this includes another launch file as a "another launchfile" I want to use specific _code_ from shared package in the launch files. Literally import the functions from different module: from mymodule import myfunc;

veverak gravatar image veverak  ( 2021-08-17 14:13:48 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2021-08-17 09:14:44 -0500

Seen: 69 times

Last updated: Aug 17 '21