您当前的位置: 首页 >  Python

鱼香ROS

暂无认证

  • 0浏览

    0关注

    498博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

ROS2-在编译类型为ament_python的包里安装launch文件方法

鱼香ROS 发布时间:2021-09-24 17:00:38 ,浏览量:0

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
关注
打赏
1666092100
查看更多评论
立即登录/注册

微信扫码登录

0.0771s