Ask Your Question
3

A silly question about packages organization!!!

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

Randerson gravatar image

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

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 imagealee ( 2016-02-24 10:28:02 -0500 )edit
Randerson gravatar imageRanderson ( 2016-02-24 12:44:33 -0500 )edit

3 Answers

Sort by » oldest newest most voted
2

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

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
4

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

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 -0500

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

Your Answer

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

Add Answer

Question Tools

Stats

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

Seen: 890 times

Last updated: Feb 26 '16