Python nodes and re-usable modules
In REP-0008 (as of today), there's a statement:
Node Files
In ROS, the name of a node type is the same as its executable name. Typically, for python files, this means including #!/usr/bin/env python at the top of your main code file.
If your node is simple, this file may contain the entire code for it. Otherwise, the node file will likely do an import packagename and invoke code there.
NOTE: we strive to keep ROS-specific code separate from reusable, generic code. The separation of 'node files' and files you place in src/packagename helps encourage this.
Because of the above statement, recommended folder structure becomes:
packagename
|- nodes/
|- ROS node executable files
|- src/
|- packagename/
|- __init__.py
|- yourfiles.py
I understand the meaning and the necessity of this difference of node
and reusable module
. However, do developers care this subtle difference? I have a feeling that many developers mix the usage without caring much of the stuff in this REP; some people sometimes write resable portion into node, and sometimes write node portion in src
.
IMO, if a package is made as a ROS package, it's a ROS package and there's less advantage of separating ROS-specific code and else. So why not put all Python code into src
and make them exportable (since other code being not able to refer to the existing code in the package in question is worse)?