Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rosrust_msg does not automatically discover all msg files in package #166

Open
ssnover opened this issue Feb 9, 2022 · 3 comments
Open

Comments

@ssnover
Copy link
Contributor

ssnover commented Feb 9, 2022

I have a catkin-based ROS1 project with a package my_msgs. The package contains msg and action definitions in a hierarchy like:

my_msgs
    action
        package_1
            MyAction.action
    msg
        package_1
            package_1.msg
        package_2
            package_2.msg

With CMakeLists.txt declaring them like so:

add_message_files(
  DIRECTORY
    msg/package_1
  FILES
    package_1.msg
)

add_message_files(
  DIRECTORY
    msg/package_2
  FILES
    package_2.msg
)

# Actions
add_action_files(
  DIRECTORY
    action/package_1
  FILES
    MyAction.action
)

After building, I try to execute cargo build on my rosrust binary crate that uses rosrust_msg. It does generate some messages, but not all that I'm expecting so I looked into the build.rs to do some debugging.

It looks like the expected location for local package msg definitions is under ${CATKIN_WS}/devel/share/<package-name>/msg and it's there that I find the generated msg files for MyAction.action. These have types generated for them under the rosrust_msg package. However, there are no message files copied here for the other msg definitions. It seems like the discovery mechanism is incomplete here. I'd note that rosmsg show can find the message file definitions as it searches the src directory as well. It may be necessary to include that in order to do complete discovery.

@ssnover
Copy link
Contributor Author

ssnover commented Feb 9, 2022

I've been trying to parse the cmake macro definitions for add_message_files and add_action_files to see if there's some way to invoke the prior to make it copy those definitions into devel, but it doesn't appear so. It may be possible to create a new macro that does the intended behavior to make discovery work as written though.

@ssnover
Copy link
Contributor Author

ssnover commented Feb 9, 2022

For some additional info, when I try to manually add the messages, the proc-macro panics:

error: proc macro panicked
 --> src/main.rs:1:1
  |
1 | rosrust::rosmsg_include!(my_msgs/package_1);
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = help: message: message my_msgs/package_1 not found in provided directories
          Directories:
          /home/developer/catkin_ws/devel/share
          /opt/ros/noetic/share
          /home/developer/catkin_ws/devel/../src
          /opt/ros/noetic/../src

It's unclear from that message if it recurses into those directories to search, but the appropriate full path would have been /home/developer/catkin_ws/devel/../src/project_repo/ros/my_msgs/msg/package_1/package_1.msg.

It seems like it would be useful to have an additional macro option rosmsg_include_from!(<path>) which will discover all .msg/.srv files and generate types appropriately. This would allow me to drop a Rust crate straight into my_msgs package. Then I can have other packages with Rust nodes which just include via directory as my_msgs = { path = "../my_msgs" } in their Cargo.toml.

@ssnover
Copy link
Contributor Author

ssnover commented Mar 12, 2022

I've made a small re-implementation of the rospack list command which appears to nearly match the official tool in my catkin workspace (I haven't filtered out metapackages yet). Visible here: https://github.com/ssnover/librospack-rs/blob/main/src/lib.rs

It seems like it'd make sense in the current build.rs paradigm to make use of ROS_PACKAGE_PATH in addition to the CMAKE_PREFIX_PATH variable.

Alternatively, the genmsg crate has a defined mechanism of passing in relevant information and generating msg and srv types. It'd be great to leverage the official mechanism here: https://github.com/ros/genmsg/blob/kinetic-devel/doc/developer.rst

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant