ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
6

A silly question about packages organization!!!

asked 2016-02-24 05:17:59 -0600

Randerson gravatar image

updated 2016-02-26 04:06:54 -0600

gvdhoorn gravatar image

Inside a package there is initially the two files CMakeList.txt and package.xml and the folder src. From the tutorials, I understood that the scripts belonging to a package should be placed in its scr folder. However, while studying ROS I found many packages that had thier scripts placed in a user created folder called scripts. Taking into account the said, my question is: Why someones creates a new folder called script instead to use the already existing one called scr. Is this a ROS good practices or just a user preference? If it is a good practice, for what I should use the folder script and for what should I use the folder src.

Thanks in advance!

edit retag flag offensive close merge delete

Comments

Do you have an example of such a package?

alee gravatar image alee  ( 2016-02-24 10:28:02 -0600 )edit
Randerson gravatar image Randerson  ( 2016-02-24 12:44:33 -0600 )edit

3 Answers

Sort by » oldest newest most voted
2

answered 2016-02-24 13:29:30 -0600

alee gravatar image

catkin_make looks inside your src directory. However, my understanding is that those scripts are in Python and don't need to go through the gcc compiler. Thus, it doesn't need to compile them into executables. Generally you'd put them in src if they were C++ files. I'm not exactly sure what "good practices" are in this scenario but that's why it's ok to put them in scripts instead of src.

edit flag offensive delete link more
8

answered 2016-02-26 02:32:43 -0600

In order to complement @alee answer, the best practice (up to my knowledge) is:

  • Scripts should go in a scripts folder.
  • Python code (classes, etc) which are not scripts should go into src/<pkg_name>/. Then, in your scripts (or python code) which are not necessarily in the same package, you can import using from <pkg_name> import foo.
edit flag offensive delete link more
2

answered 2016-02-24 13:53:27 -0600

dornhege gravatar image

This is mostly relevant for python packages. The usual practice is to put scripts that can be executed by users in the scripts directory and put source files (also .py) that these scripts use in the src directory.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2016-02-24 05:17:59 -0600

Seen: 3,454 times

Last updated: Feb 26 '16