ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
I have finally managed to solve the problem by creating a function that reads the directory tree and includes the information in DATA_FILES. Here is an example in case someone finds it useful. In the code the "models/" and "worlds/" folders contain subfolders. If anyone knows a simpler way to do this I would be very grateful if you would share the information.
import os
from glob import glob
from setuptools import setup
package_name = 'myrobot_gazebo'
data_files=[
('share/ament_index/resource_index/packages',
['resource/' + package_name]),
('share/' + package_name, ['package.xml']),
]
def package_files(data_files, directory_list):
paths_dict = {}
for directory in directory_list:
for (path, directories, filenames) in os.walk(directory):
for filename in filenames:
file_path = os.path.join(path, filename)
install_path = os.path.join('share', package_name, path)
if install_path in paths_dict.keys():
paths_dict[install_path].append(file_path)
else:
paths_dict[install_path] = [file_path]
for key in paths_dict.keys():
data_files.append((key, paths_dict[key]))
return data_files
setup(
name=package_name,
version='0.0.0',
packages=[package_name],
data_files=package_files(data_files, ['models/', 'launch/', 'worlds/']),
install_requires=['setuptools'],
zip_safe=True,
maintainer='ros',
maintainer_email='ros@todo.todo',
description='TODO: Package description',
license='TODO: License declaration',
tests_require=['pytest'],
entry_points={
'console_scripts': [
],
},
)
Best regards.