ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
2

Issues Building ROS2: Dashing Python Package

asked 2019-09-06 10:49:34 -0500

SouLeo gravatar image

Hello,

I've tried following this tutorial page (https://index.ros.org//doc/ros2/Tutor...) 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_AllenN... 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!

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
2

answered 2019-09-06 11:03:20 -0500

sloretz gravatar image

updated 2019-09-06 11:03:56 -0500

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.

edit flag offensive delete link more

Comments

Thank you so much! This solved my problem!

SouLeo gravatar image SouLeo  ( 2019-09-06 11:09:43 -0500 )edit

I believe this is due to a bug in colcon core. Package discovery currently uses either setup.py orsetup.cfg. I’m working on a fix in https://github.com/colcon/colcon-core...

DanRose gravatar image DanRose  ( 2019-09-07 05:52:50 -0500 )edit

This behavior is not a bug. Earlier colcon-rosdid this automatically for the user but that "magic" has recently been removed (https://github.com/colcon/colcon-ros/...) 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.

Dirk Thomas gravatar image Dirk Thomas  ( 2019-09-07 11:02:54 -0500 )edit

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
DanRose gravatar image DanRose  ( 2019-09-07 15:35:17 -0500 )edit

Question Tools

Stats

Asked: 2019-09-06 10:49:34 -0500

Seen: 2,917 times

Last updated: Sep 06 '19