0
$\begingroup$

Environment:

Operating System: Ubuntu 22.04

ROS Version: ROS 2 Humble Hawksbill

Issue: I have created a ROS 2 package named robot, and I am able to build it successfully with colcon build. However, when I try to run my node using ros2 run robot publisher, I get a "No executable found" error. Running the executable directly from the install/robot/bin directory works as expected.

Package Structure:

Root package directory contains package.xml and setup.py. Python source code is located in src/robot.

Steps Taken:

I confirmed that the publisher script has execute permissions (-rwxrwxr-x).

I have sourced the ROS 2 environment setup script before sourcing my workspace's install/setup.bash.

I checked that AMENT_PREFIX_PATH is set correctly after sourcing.

I created a symlink from install/robot/bin/publisher to install/robot/lib/robot/publisher, but ros2 run still does not recognize the executable.

I've received warnings about the package marker and package.xml installation during the build process, but it's unclear if they're related to the issue.

Warnings During Build:

Warning about implicitly installing a marker in the package index.

Warning about implicitly installing the package.xml file.

Setuptools deprecation warning regarding the setup.py install.

Content of setup.py:

from setuptools import setup

package_name = 'robot'

setup(
    name=package_name,
    version='0.0.1',
    packages=[package_name],
    package_dir={'': 'src'},
    install_requires=['setuptools'],
    zip_safe=True,
    maintainer='Mateusz',
    maintainer_email='[email protected]',
    description='ROS 2 package Robot',
    license='License',
    tests_require=['pytest'],
    entry_points={
        'console_scripts': [
            'publisher = robot.publisher:main',
        ],
    },
)

Content of package.xml:

<?xml version="1.0"?>
<package format="3">
  <name>robot</name>
  <version>0.0.1</version>
  <description>A ROS 2 package for Robot.</description>
  <maintainer email="[email protected]">Mateusz</maintainer>
  <license>MIT License</license>

  <buildtool_depend>ament_cmake</buildtool_depend>
  <depend>rclpy</depend>
  <depend>std_msgs</depend>

  <export>
    <build_type>ament_python</build_type>
  </export>
</package>

Executable Script Details:

Executable named publisher.

The publisher script is located at install/robot/bin/publisher.

I've attempted to create a symlink in the expected location.

Questions:

Are the warnings I'm receiving during the build process indicative of issues that could lead to ros2 run not finding the executable?

Is there a step I'm missing in the process of registering the executable with the ROS 2 runtime environment?

Could this be related to changes in ROS 2 Humble or the way Python executables are handled?

Additional Context:

Direct execution of the publisher script works perfectly, as I can run it using ./install/robot/bin/publisher, and it correctly publishes messages to a topic.

I've verified that the environment variables are set correctly after sourcing the setup scripts.

The symlink in install/robot/lib/robot pointing to the executable appears to be correct, but ros2 run still doesn't find the executable.

Any guidance or suggestions on what might be causing this issue and how to resolve it would be greatly appreciated!

$\endgroup$

2 Answers 2

1
$\begingroup$

Check the output of ros2 pkg prefix robot --share.

If ros2 can't find it, the problem might be with where the package is built.

$\endgroup$
1
  • 1
    $\begingroup$ Thank you, I ran the command ros2 pkg prefix robot --share, and the output confirms that ROS 2 correctly locates the share directory of my package. This indicates that the package is built and installed in the expected location, and that ROS 2 is able to find it. Is there anything else I might check or adjust to ensure the executable is correctly registered and discoverable by ros2 run? $\endgroup$
    – Mateusz
    Commented Feb 12 at 11:50
0
$\begingroup$

I think you forgot to run source ./install/setup.bash after building your workspace, this is needed for the system to be able to find the executables when you run ros2 run.

$\endgroup$
1
  • $\begingroup$ Thanks, I have sourced source ./install/setup.bash and despite this I am still having the same issue. I observed that while AMENT_PREFIX_PATH is properly set, including my package's install directory, the ROS_PACKAGE_PATH variable is empty. It seems there might be a deeper issue with the executable's registration or discovery by the ROS 2 runtime. $\endgroup$
    – Mateusz
    Commented Feb 12 at 9:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.