ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

How to install launch.py files in a python package in ros2 (python package is created without CMakeLists.txt)?

asked 2021-10-09 13:11:08 -0500

mac137 gravatar image

Hi! The question as in the topic.

When I just create a python package as described in this ros tutorial here, and then manually create a launch/launch_file.py and do colcon build, I cannot execute ros2 launch my_package launch_file.py becuase file '.launch_file.py' was not found in the share directory of package 'my+package' which is at 'path/2/ros_ws/install/my_package/share/lidar_odom'.

I do not have CMakeLists.txt in my package because this file is not created when you create a python package following the mentioned ros tutorial.

How to install then my launch files?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2021-10-16 15:02:30 -0500

mac137 gravatar image

updated 2021-10-16 17:26:49 -0500

@EtienneSchmitz, many thanks for your answer! Maybe this particular code did not work in my case, but it inspired me to modify it a bit and the following piece of code worked for me

setup(
...
data_files=[
...
('share/' + package_name, ['launch/launch_file.py']),
],
...
)
edit flag offensive delete link more
1

answered 2021-10-11 02:14:43 -0500

EtienneSchmitz gravatar image

Hi !

You don't add your launch files in data_files (setup.py in your python package folder).

setup(
...
    data_files=[
    ...
    (os.path.join('share', package_name), glob('launch/*.launch.py'))
    ],
    ....
    )

You will find more explanation on this link

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2021-10-09 13:11:08 -0500

Seen: 108 times

Last updated: Oct 16 '21