Ask Your Question
0

What is the difference between a ROS package and a simple folder?

asked 2020-04-08 10:19:00 -0500

nj08 gravatar image

Hi,

I'm new to ROS. I came across the concepts of packages, but I couldn't understand the main purpose of it (except for the package.xml & CMakelists.txt files). I was able to run simple nodes I created by from a folder using mkdir (instead of catkin_create_pkg), although not through rosrun, but by executing it manually from the directory itself (as rosrun doesn't work in the case). The nodes also show up in the 'rosnode list' command and communication works fine. So what are the other functionalities a ROS Package provides that a normal folder doesn't?

Thanks

edit retag flag offensive close merge delete

Comments

Could you see whether any of these clarify the question "what is a package" sufficiently: #q9036 and #q10254.

gvdhoorn gravatar image gvdhoorn  ( 2020-04-08 12:46:24 -0500 )edit

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

nj08 gravatar image nj08  ( 2020-04-08 13:02:27 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2020-04-08 13:09:34 -0500

gvdhoorn gravatar image

updated 2020-04-08 13:15:36 -0500

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.

edit flag offensive delete link more

Comments

1

Note btw that the concept of a package is not necessarily ROS-specific.

Compare the use of the term with how fi Python has packages, NPM has packages, the Rust programming language has packages, you install .deb packages on Debian and Ubuntu, etc, etc.

All of these typically only consider packages as packages when they adhere to a certain layout and contain specific files with specific names and content.

For Python fi, only directories with an __init__.py are considered packages. You can certainly store Python scripts and modules in directories without those marker files, but they will not be considered packages.

It's exactly the same within ROS. Nodes (.launch files and a few other types of files) don't absolutely need to be hosted by packages. But it will complicate things, as you already discovered, as certain tools don't work with non-packages.

gvdhoorn gravatar image gvdhoorn  ( 2020-04-08 13:13:31 -0500 )edit

That answered a lot of questions! Thank you!

nj08 gravatar image nj08  ( 2020-04-08 13:59:29 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2020-04-08 10:19:00 -0500

Seen: 43 times

Last updated: Apr 08