Launch file not found

Hello,

until end of section 2.6 I think I followed all steps. Still when launching the first launch file after

ros2 launch my_package my_package_launch_file.launch.py

I get

file 'my_package_launch_file.launch.py' was not found in the share directory of package 'my_package' which is at '/home/user/ros2_ws/src/install/my_package/share/my_package'

but it exists in

~/ros2_ws/src/my_package/launch

any hint why the build didn’t add the launch File to the package ?

Hi @vkuehn ,

I believe, it is because you might have missed some line(s) in your setup.py file.

Check if you have done the following steps: (specifically step 2 in the below snippet)

Make changes to setup.py file:
------------------------------
Add: import os
Add: from glob import glob

Add to data_files list: (os.path.join('share', package_name), glob('launch/*.launch.py'))

Add to entry_points dict console_scripts: 
['python_executable_name = pkg_name.python_executable_name:main']

And make sure your launch.py file is in this format:

Generate Launch File:
---------------------
from launch import LaunchDescription
from launch_ros.actions import Node

def generate_launch_description():
    return LaunchDescription([
        Node(package="package_name",
             executable="python_executable_name",
             output="screen"),
    ])

I believe, these should fix your problem!

Let me know if you find what I said to be helpful !

Regards,
Girish

1 Like

That did make it work, Thanks a lot !

The Import for the setup was missing.

1 Like