0
$\begingroup$

Rosanswers logo

I am working with ROS2 ardent, using Colcon to build.

The build is suceessful and I can also see my executable in <ws/build/package-name/build/lib/> but still when I run the package using ros2 run, no executables are found.


Originally posted by aks on ROS Answers with karma: 667 on 2018-08-01

Post score: 0


Original comments

Comment by Marc Testier on 2018-08-01:
Did you source the setup.bash file in the install folder ?? source <ros2_ws>/install/setup.bash You can add the command to ~/.bashrc so that you don't have to source every time you open a terminal.

Comment by aks on 2018-08-01:
Yes, I have sourced the setup.bash file, still no executable found

$\endgroup$

2 Answers 2

0
$\begingroup$

Rosanswers logo

I found the problem.

In the setup.py file, I had a missing , for the last node in the entry pointsi.e.

entry_points={
    'console_scripts': [
        'listener = demo_nodes_py.topics.listener:main',
        'talker = demo_nodes_py.topics.talker:main'
        'listener_qos = demo_nodes_py.topics.listener_qos:main'
       
    ],
},
NOTE :  The missing `,` before the `listener_qos` node.

The strange thing here is, compiler compiles all the 3 nodes and I can see in the <ws/build/package-name/build/lib/> folder. Shouldnt the compiler just ignore the 3rd node listener_qos in this case ?


Originally posted by aks with karma: 667 on 2018-08-01

This answer was ACCEPTED on the original site

Post score: 0

$\endgroup$
0
$\begingroup$

Rosanswers logo

I have a mixed C++/Python package. To install a Python executable in this package, I've found it sufficient to do this:

  • Add the Python source file to my_package/scripts
  • Add this line at the top of ^that file: #!/usr/bin/env python3
  • Make it executable with chmod +x
  • Add an empty __init__.py file in my_package/scripts
  • Add this to CMakeLists:
install(PROGRAMS  
  scripts/my_python_file.py  
  DESTINATION lib/${PROJECT_NAME} )

To me, this seems easier than what the tutorial recommends with setup.cfg and setup.py but maybe I'm missing something. Perhaps it's not Windows-compatible or something like that.


Originally posted by AndyZe with karma: 2331 on 2022-01-26

This answer was NOT ACCEPTED on the original site

Post score: 3


Original comments

Comment by aserbremen on 2023-02-24:
Here it is said to also use the following command pointing to the directory where the scripts are located (this might be necessary only for certain ROS2 distributions) before using the install(PROGRAMS...) command: ament_python_install_package(my_package/scripts)

The making it executable step is really hard to notice. I had the same procedure from another site, but didn't make the python script executable. I could find the python script under install/my_pacakage/lib/my_pacakage/script.py but ros2 run my_pacakage script.py would throw No executable found

$\endgroup$

Your Answer

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