ubuntu-robotics / nodl

CLI and parsing utilities for the ROS 2 NoDL
Apache License 2.0
8 stars 12 forks source link

ros2 nodl show not finding nodl descriptions when installed from subdirectory with ament_nodl #41

Open wjwwood opened 3 years ago

wjwwood commented 3 years ago

So, I have a line like this in my example:

nodl_export_node_description_file(nodl/fake_imu.nodl.xml)

This installs the file and an ament_index marker file to:

$ tree install/
install/
├── ros2launch_security_examples
│   └── share
│       ├── ament_index
│       │   └── resource_index
│       │       ├── nodl_desc
│       │       │   └── ros2launch_security_examples
...
│       └── ros2launch_security_examples
│           ├── nodl
│           │   ├── fake_imu.nodl.xml
...

The ament_index marker file contains:

$ cat install/ros2launch_security_examples/share/ament_index/resource_index/nodl_desc/ros2launch_security_examples
share/ros2launch_security_examples/nodl/fake_imu.nodl.xml
share/ros2launch_security_examples/nodl/imu_sink.nodl.xml

But if I run ros2 nodl I get:

$ ros2 nodl show ros2launch_security_examples
ros2launch_security_examples has no NoDL files in its ament index.

The expected behavior is that it finds these files, but it does not.

If I move the .nodl.xml files out of the subdirectory, then everything works:

$ ros2 nodl show ros2launch_security_examples
{'name': 'imu_sink', 'executable': 'imu_sink', 'actions': {}, 'parameters': {}, 'services': {}, 'topics': {'imu': {'name': 'imu', 'type': 'sensor_msgs/msg/Imu', 'role': <PubSubRole.SUBSCRIPTION: 'subscription'>}}}
{'name': 'fake_imu', 'executable': 'fake_imu', 'actions': {}, 'parameters': {}, 'services': {}, 'topics': {'imu': {'name': 'imu', 'type': 'sensor_msgs/msg/Imu', 'role': <PubSubRole.PUBLISHER: 'publisher'>}}}

Based on the documentation of nodl_export_node_description_file() and the contents of the ament_index file, I would have expected any hierarchy of directories for the nodl description files to be ok. But the python library (and therefore the cli tool) seem to expect all description files to be in the root of the package's share directory:

https://github.com/ubuntu-robotics/nodl/blob/3457cbf9242738ab831f84a0360cffb175d1f415/nodl_python/nodl/_index.py#L38

So is this expected behavior or maybe a bug?

aprotyas commented 3 years ago

It looks like the current implementation of _get_nodl_files_from_package_share() would work with the usage described in ament_nodl's README, where .nodl.xml files are placed in the same directory as the CMakeLists.txt file. nodl_export_node_description_file() respects hierarchy of directories though.