Best practice: File/directory structure for multiple larger nodes in one package
This question addresses a general best-practice question; I'll use the project I'm currently working on as an example.
I am working on a ROS2 project in which a simulated cargo-drone (node: drone_simulator; outputs drone position on a topic, no graphics) is controlled from a operator-input node (node: drone_controller) and is visualized with a separate graphics node (node: drone_graphics). I'm using ROS2 Galactic and program in C++ in Ubuntu.
All nodes are solely for this project; no 'generic' nodes involved which can be used for a different project. Also, the nodes are so large that, by good C++ practice, each should be split in several .cpp and .h files.
Based on the tutorials (especially the publisher/subscriber one, https://docs.ros.org/en/galactic/Tuto...) I think that all these nodes should be in one package. Following the guidelines of the tutorial, all .cpp files will end up in the same directory, being my_ws/src/cargo_drone/src
. It is unclear what to do with the .h files, but I guess that my_ws/src/cargo_drone/include
would be an appropriate place.
However, I don't like the fact that .cpp files (and .h files) of different executables are mixed up into one giant directory. There must be more structured way, isn't it?
My questions are:
- What is best practice? Should the nodes (i.e., executables) indeed be grouped into one package, or not?
- If so, where to put all .cpp and .h files (and possibly other resource files) so that it forms some sort of organized structure?
- If not, what is the purpose of having packages and the ability to have multiple nodes in a package (or: when should nodes be grouped in a package and when not?)
Just wanted to say "hi" ;)
Hi Gijs, I's so nice to see you here again! I had already noticed that you are quite active with ROS, and was wondering if you'd see my question.. So, yes dus! Best, Gijs