ROS2 in 5 Days - Section 2.6 #7 Issue

I followed the instructions to create ‘my_package_launch_file.launch.py’ inside
cd ~/ros2_ws/src/my_package/launch. But my errors seem to talk about the file missing from ~/ros2_ws/install/ and ~/ros2_ws/install/my_package/lib/my_package and share

My first error was “user:~/ros2_ws$ ros2 launch my_package my_package_launch_file.launch.py
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/install/my_package/share/my_package’” when I tried to do Section 2.6 #7.

So I copied the my_package my_package_launch_file.launch.py file onto ‘/home/user/ros2_ws/install/my_package/share/my_package’. Then I got this error when I ran ‘ros2 launch my_package my_package_launch_file.launch.py’ again: [INFO] [launch]: All log files can be found below /home/user/.ros/log/2024-04-17-06-05-37-326982-3_xterm-3730
‘[INFO] [launch]: Default logging verbosity is set to INFO
[ERROR] [launch]: Caught exception in launch (see debug for traceback): package ‘my_package’ found at ‘/home/user/ros2_ws/install/my_package’, but libexec directory ‘/home/user/ros2_ws/install/my_package/lib/my_package’ does not exist’

What am I doing wrong here?

Hi, I recommend sharing your terminal output between three ` symbols for better readability:

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/install/my_package/share/my_package’

As for your error, remember that you need to add the launch directory to your package’s setup.py in order for the workspace to find it when compiling.

You should never have to copy directories or files in your workspace’s install/ directory. install/, build/ and log/ get generated every time you compile. If you correctly set everything in the src/, then all of the files will generate correctly in the mentioned directories.

1 Like

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