mvukov / rules_ros2

Build ROS 2 with Bazel
Apache License 2.0
85 stars 47 forks source link

[question] ROS2 Nodes #9

Closed paulsammut closed 2 years ago

paulsammut commented 2 years ago

Hello, thanks so much for making this project! I have a question:

How did you figure out the minimum set of nodes/packages required to "bazelify" Foxy?

I'm trying to do a similar project, except with Buck and with ROS2 Humble, and have been making use of the colcon graph output to figure out the dependency graph, but I'm unsure of which packages I can get rid of.

Thanks for any help!

question

ahans commented 2 years ago

I had a similar question here. Instead of doing everything in Bazel, my starting point is a "fat archive" distribution. I'm using a Python script to parse the tree and use the information in package.xml files (I think that's the only thing colcon relies on), but also use some CMake files. A proper answer to my question over there is still pending. The only thing I got was a reference to this very project!

To find out the minimal set of packages, I would start from a package I want to use as a starting point, e.g., rclcpp, and then walk the dependency tree backwards from there. In my experience this still requires some manual adjustments due to system dependencies assumed to be present and what not, but it's definitely better than a full manual effort.

mvukov commented 2 years ago

This was a while ago, but I think I was lazy to create a script to visualize a dependency graph so I was manually inspecting package.xml files, starting from rclc and when I got that up-n-running I investigated how to build rclcpp. There was a bit of trial-n-error there to figure out what was strictly needed for compilation. Creating a script to inspect deps and create a graph shouldn't be that hard. For my rules_ros repo I created a Python script that used catkin for package discovery.

What you can do is to create a dependency graph for e.g. rclcpp using Bazel and this repo:

bazel query "kind(cc_library, deps(@ros2_rclcpp//:rclcpp))" --output=graph --noimplicit_deps

And then you can visualize the output e.g. here. This visualizes deps between the Bazel targets, should be a good starting point.

paulsammut commented 2 years ago

Thanks a bunch for this. Did you find that the rclc was needed for rclcpp? Or did you just want to include both of them?

edit: I answered my own question here as digging through rclcpp dependencies made me realize that it is dependent on the ros C libraries.

To piggy back on this comment: were you able to run nodes without importing the launch libraries? I saw the comment in the readme about needing rclpy for the ros_launch to work, but I couldn't find em in the repo.

mvukov commented 2 years ago

So, rclcpp is dependent on rcl and some C-based libraries but not rclc directly (my bad for claiming this earlier: I started the dependency analysis from rcl instead).

There are two examples in the examples folder. As there is no launch mechanism in place in this repo (yet), you have to start each node binary in a separate terminal. And this works just fine.