[ROS2] Using colcon doesn't create any file inside the install/<package>/share directory
My package structure is very simple:
workspace/
src/
example/
launch/
resource/
test/
example/
setup.cfg
setup.py
package.xml
the problem is that I have defined a launch file inside the launch
directory in my package. But running:
colcon build --packages-select example
(where example
is just the name of the package)
is doesn't move/create/copy the launch file from the launch directory into the install
directory. So
install/example/share/example/
contains no launch file, which should be there even according to the tutorial about launch files here. In fact, the line:
(os.path.join('share', package_name), glob('launch/*.launch.py'))
from the tutorial above, suggests that the launch.py
file should be found inside the share directory of the package. And this is not the case for me.
I deleted the build
and install
directory many times. I run colcon build
only, but it doesn't create any launch file inside the share
directory. So I can only use absolute path inside my launch file or move manually the launch file inside the share directory. There is a reason for that? Or is the tutorial assuming that you move manually your launch file inside the share directory?
I'm using foxy on Ubuntu 20.04
UPDATE: My setup.py file contains the following code:
from setuptools import setup
from glob import glob
import os
package_name = 'example'
setup(
name=package_name,
version='0.0.0',
packages=[package_name],
data_files=[
('share/ament_index/resource_index/packages', ['resource/' + package_name]),
('share/' + package_name, ['package.xml']),
(os.path.join("share", package_name), glob("*launch.py")),
],
install_requires=['setuptools'],
zip_safe=True,
maintainer='Max Muller',
maintainer_email='max@infromtik.ca',
description='Test',
license='GPL',
tests_require=['pytest'],
entry_points={
'console_scripts': [ 'test = example.robot_prog:main',
],
},
)
Again, I understood the tutorials and the explanation. But or our example, with package name my_python_pkg
, this will install all launch files from the launch
folder, into ~/ros2_ws/install/my_python_pkg/share/my_python_pkg/launch/
is exactly what it is not doing!!!
It creates the launch
folder inside the package directory inside the install directory: yes
It creates/move the launch file inside the launch
directory created inside the package directory in the install directory: no
And I don't know, what's wrong with it. Evening following the tutorial I get the folder launch
but no launch files, are inside it
You need to actually install the launch folder to your share directory. This is done in the
setup.py
file. Could you edit this question to include a copy of yoursetup.py
file?