would any folder with only source code in it (no package.xml, CMakeLists.txt) be called a package?
No.
If not, what differentiates them in terms of the functions they can perform?
In the general ROS context, a package is a directory which contains a package manifest (ie: a package.xml
file).
Tools such as Catkin (and the related Python libraries) will only consider directories with package.xml
files in them.
In essence, package.xml
is a marker file, which also happens to contain important information itself (such as the name of the package (which does not have to be equal to the name of the directory), version of the package, etc).
I was able to run simple nodes I created by from a folder using mkdir
(instead of catkin_create_pkg
), although not through rosrun
and this is because your plain directory is not considered a package, as it does not contain the required marker file (ie: the manifest).
but by executing it manually from the directory itself
As nodes are essentially just regular programs (which happen to use ROS communication primitives instead of reading and writing to files) it's perfectly possible to start them like other normal programs. And what you experienced seems to align with that.
The nodes also show up in the 'rosnode list' command and communication works fine.
Package manifests are mostly a build time/deployment artefact. They're not really used at runtime (they are, but only in certain cases).
Publishing/subscribing, using services or actions, registering nodes with the ROS Master and all the other things that nodes can use to interact with a running ROS application (ie: the set of running nodes) is not dependent on being in a package or not. So this explains why rosnode list
shows them and they can communicate.
Could you see whether any of these clarify the question "what is a package" sufficiently: #q9036 and #q10254.
Yes, I understand that packages are basic blocks of a useful function. But what I don't understand is, would any folder with only source code in it (no package.xml, CMakeLists.txt) be called a package? If not, what differentiates them in terms of the functions they can perform? Thanks