Ask Your Question
0

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 https://docs.ros.org/en/galactic/Tuto...

The launch file is:

from launch import LaunchDescription
from launch_ros.actions import Node

def generate_launch_description():
    return LaunchDescription([
        Node(
            package='lrs_exec',
            output='screen',
            executable='resource',
            name='resource_agent'
        )
    ])

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

Trying to run:

ros2 launch lrs_exec exec.launch.py

I get:

tompe@tpexps:~$ ros2 launch lrs_exec exec.launch.py
[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/launch_service.py:226> 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 resource.py and no difference.

edit retag flag offensive close merge delete

Comments

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
0

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

tompe17 gravatar image

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

entry_points={
    '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

Stats

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

Seen: 52 times

Last updated: Jan 24