0
$\begingroup$

Rosanswers logo

Hello,

I've tried following this tutorial page (https://index.ros.org//doc/ros2/Tutorials/Colcon-Tutorial/) to build my own python package for ROS2 Dashing on Ubuntu 18.04 (bionic), but I'm running into issues.

Here is a link to my package: https://github.com/SouLeo/ROS2_AllenNLP_Parser/tree/master/parser It includes my setup.cfg, setup.py, and package.xml.

My issue is that, even though I can build successfully with

colcon build --symlink-install

after sourcing with

source ~/ws/install/setup.bash

I can't run

ros2 run temoto_parser srl_test

Instead I get an error:

Package 'temoto_parser' not found

Any help at all would be greatly appreciated. Thanks!


Originally posted by SouLeo on ROS Answers with karma: 35 on 2019-09-06

Post score: 2

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

I think ros2 run uses the ament index to find packages, and it looks like the package temoto_parser isn't installing a marker file.

Create a folder called resource/ (this folder name doesn't really matter, it's just what's been used so far) in the same directory as your setup.py file. Next, create an empty file with the same name as your package in that folder: resource/temoto_parser. In your setup.py use the data_files keyword argument to install the marker file temoto_parser to share/ament_index/resource_index/packages.

See the ros2/examples repo for python packages that do this. Here's the relevant part of the setup.py, and here's a marker file in a folder called resource.

Here's a page with a little more info about the ament_index, though it's targeted at packages using CMake.


Originally posted by sloretz with karma: 3061 on 2019-09-06

This answer was ACCEPTED on the original site

Post score: 2


Original comments

Comment by SouLeo on 2019-09-06:
Thank you so much! This solved my problem!

Comment by DanRose on 2019-09-07:
I believe this is due to a bug in colcon core. Package discovery currently uses either setup.py or setup.cfg. I’m working on a fix in https://github.com/colcon/colcon-core/pull/215

Comment by Dirk Thomas on 2019-09-07:
This behavior is not a bug. Earlier colcon-ros did this automatically for the user but that "magic" has recently been removed (https://github.com/colcon/colcon-ros/pull/74) since it makes it difficult for users to spot that while it works when building from source it would fall when packaging the package into e.g a Debian package.

Comment by DanRose on 2019-09-07:
I think there is a bug here, though I may have misattributed it. Here's which files change when you remove the setup.cfg and colcon build --symlink-install. Note the path.* hooks so that, without setup.cfg, the directory containing srl_test gets injected into PATH:

-./build/temoto_parser/setup.cfg
-./install/temoto_parser/lib/temoto_parser
-./install/temoto_parser/lib/temoto_parser/srl_test
-./src/ROS2_AllenNLP_Parser/parser/setup.cfg

+./install/temoto_parser/bin
+./install/temoto_parser/bin/srl_test
+./install/temoto_parser/share/temoto_parser/hook/path.dsv
+./install/temoto_parser/share/temoto_parser/hook/path.ps1
+./install/temoto_parser/share/temoto_parser/hook/path.py
+./install/temoto_parser/share/temoto_parser/hook/path.sh
$\endgroup$

Your Answer

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