ROS2 setup.cfg
这个文件将告诉脚本将安装在哪里
修改setup.py以安装launch文件关键在这一行
(os.path.join('share', package_name, 'launch'), glob('launch/*.launch.py')),
还可以安装yaml结尾的
(os.path.join('share', package_name, 'config'), glob('config/*.yaml')),
import os
from glob import glob
from setuptools import setup
...
data_files=[
('share/ament_index/resource_index/packages',
['resource/' + package_name]),
('share/' + package_name, ['package.xml']),
(os.path.join('share', package_name, 'launch'), glob('launch/*.launch.py')),
],
...
ROS2的launch文件如何互相包含、互相引用呢
导入IncludeLaunchDescription
import os
from ament_index_python.packages import get_package_share_directory
from launch.actions import IncludeLaunchDescription
def generate_launch_description():
pkg_gazebo_ros = get_package_share_directory('gazebo_ros')
return LaunchDescription([
IncludeLaunchDescription(
PythonLaunchDescriptionSource(
os.path.join(pkg_gazebo_ros, 'launch', 'gzserver.launch.py')
),
launch_arguments={'world': world}.items(),
)
])
原文链接:
- https://roboticsbackend.com/create-a-ros2-python-package/#Install_other_files_in_a_ROS2_Python_package