Ask Your Question
0

ROS2 Package using both C++ and Python

asked 2018-11-26 14:38:07 -0500

beck gravatar image

updated 2018-11-28 16:07:13 -0500

How can I configure a ROS2 package that contains both C++ and python code for installation? I am aware of a previous question here, but the answer does not provide an example. I tried following the tutorial here, but I get No executable found when trying to run my python script with ros2 run (the C++ executables run without issue).

How do I configure my CMakeLists.txt to install python scripts so that ros2 run can find them?

Edit: I have also tried the call to install(FILES <script.py> DESTINATION share/${PROJECT_NAME}) used here to no avail.

edit retag flag offensive close merge delete

Comments

Hi,

have you tried adding launch.py in CMakelist.txt and launch the nodes pass the test. I have migrated .test files from ros1 to launch.py in ros2 but not able to add it in CMakelist.txt. With ros1, we can do with rostest.

Thanks, Poonam

poonam1120 gravatar image poonam1120  ( 2018-12-03 06:14:38 -0500 )edit

@poonam1120 I've already asked you to not use answers to ask questions. Please use comments.

William gravatar image William  ( 2018-12-05 14:38:22 -0500 )edit
1

@William, My apologies.

poonam1120 gravatar image poonam1120  ( 2018-12-06 00:04:08 -0500 )edit

No worries, just try to use comments unless it's actually an answer :)

William gravatar image William  ( 2018-12-06 00:28:25 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2018-11-28 17:09:17 -0500

lucasw gravatar image

updated 2018-11-30 15:49:31 -0500

This works for me in bouncy:

install(PROGRAMS scripts/demo.py DESTINATION lib/${PROJECT_NAME})

https://github.com/lucasw/imgui_ros/b...

PROGRAMS sets the installed file permissions to be executable- but the file has to already be executable, e.g. chmod a+x my_node.py.

edit flag offensive delete link more

Comments

This works, but only after clearing the build and install directories, and does not work with the --symlink-install option. Is it possible to get it to play nice with --symlink-install?

beck gravatar image beck  ( 2018-11-28 17:31:02 -0500 )edit

I'll take a look at symlink install- I didn't realize until looking it up now that it was the new approach to the ros1 'devel' build directory.

lucasw gravatar image lucasw  ( 2018-11-28 20:54:57 -0500 )edit

I ran symlink-install with a clean workspace (also used with --base-paths to use the same src directory as I already set up without making a symlink) and in install/imgui_ros/lib/imgui_ros there is a symlink to demo.py, it works:

source install/setup.bash
ros2 run imgui_ros demo.py
lucasw gravatar image lucasw  ( 2018-11-29 10:27:44 -0500 )edit

This still doesn't work for me. The symlink to the script is being created in the install folder, but ros2 run is not finding it. I installed bouncy from binaries, so if you did an install from source, perhaps this was bug that was fixed?

beck gravatar image beck  ( 2018-11-29 11:44:48 -0500 )edit

I've been using the bouncy binaries.

lucasw gravatar image lucasw  ( 2018-11-29 13:58:03 -0500 )edit

Well, then I'm at a loss as to why this doesn't work.

beck gravatar image beck  ( 2018-11-29 14:16:52 -0500 )edit

Can you makie a minimal example and put it on github, just a cpp and py node that print something?

lucasw gravatar image lucasw  ( 2018-11-30 08:09:50 -0500 )edit

See here.

beck gravatar image beck  ( 2018-11-30 14:35:32 -0500 )edit

Your Answer

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

Add Answer

Question Tools

2 followers

Stats

Asked: 2018-11-26 14:38:07 -0500

Seen: 1,567 times

Last updated: Dec 03 '18