Ask Your Question

Can you have ros2 python launch files in pure python packages?

asked 2022-01-24 08:42:31 -0500

tompe17 gravatar image

updated 2022-01-24 08:43:11 -0500

I created a package with:

ros2 pkg create --build-type ament_python lrs_exec

In that package I created a lcunh file according to

The launch file is:

from launch import LaunchDescription
from launch_ros.actions import Node

def generate_launch_description():
    return LaunchDescription([

The executable is called and is in a sub-dir lrs_exec of the package lrs_exec.

Trying to run:

ros2 launch lrs_exec

I get:

tompe@tpexps:~$ ros2 launch lrs_exec
[INFO] [launch]: All log files can be found below /home/tompe/.ros/log/2022-01-24-15-02-45-557721-tpexps-4043650
[INFO] [launch]: Default logging verbosity is set to INFO
Task exception was never retrieved
future: <Task finished name='Task-2' coro=<LaunchService._process_one_event() done, defined at /opt/ros/galactic/lib/python3.8/site-packages/launch/> exception=SubstitutionFailure("executable 'resource' not found on the libexec directory '/home/tompe/lrs2_ws/install/lrs_exec/lib/lrs_exec' ")>
Traceback (most recent call last):

So should this work or do I have to create a specific launch package as it was created in the launch turotial? I tested with and no difference.

edit retag flag offensive close merge delete


Above I had manually created install/lrs_exec/lib/lrs_exec. The first error message was that the directory did not exist.

tompe17 gravatar image tompe17  ( 2022-01-24 08:47:32 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2022-01-24 09:14:57 -0500

tompe17 gravatar image

So my mistake, I had forgotten to add to entry points in The following:

    'console_scripts': [
        'resource = lrs_exec.resource:main'

fixed the problem. I am pretty new to ros2 and assumed I did not have to do these things to find the program. Have now learned otherwise.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2022-01-24 08:42:31 -0500

Seen: 52 times

Last updated: Jan 24