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

When should I split my code into multiple packages, and what's a good way to split it?

asked 2011-11-07 11:38:36 -0500

mmwise gravatar image

updated 2011-11-26 10:32:48 -0500

joq gravatar image

(Mention the advantages of message definition packages.)

Please help in writing up a ROS best practice.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
12

answered 2011-11-26 10:29:48 -0500

joq gravatar image

updated 2015-05-05 15:30:04 -0500

Your ROS packages should belong to one or more repositories. Each repository contains one or more packages, the build dependency units.

When creating a new package, choose the name carefully:

  • Package names are global to the entire ROS ecosystem.
  • They are messy to change later.
  • Try to pick names that will make sense to others who may wish to use your code.
  • Package names should start with a letter, and contain only letters, numbers and '_' characters. Lower case is preferred. Feel free to browse the current list for inspiriation.

Each package can be built separately, so pay attention to dependencies. The package dependency graph must be acyclic, i.e. no package may depend on another that directly or indirectly depends on it.

  • The overhead of a ROS package is not large. Define separate packages wherever they make sense.
  • Avoid combining nodes that pull in mutually unneeded dependencies.
  • To eliminate unnecessary build overhead, avoid combining nodes that are often used separately.
  • If programs with similar dependencies are generally used together, consider combining them into a single package.
  • If some nodes have common dependencies on shared code that you do not wish to export publicly, they can be combined internally within a single package.
  • If the shared code should be exported, consider making it a separate package that the others depend on. (This is reasonable, but not required. A single package can export libraries and headers as well as nodes.)
  • Consider combining message definitions in one or more separate packages. That usually simplifies the dependencies among packages, with nodes depending on the messages, and not so much on each other.
edit flag offensive delete link more

Comments

thanks joq for supplying the first answer :)
mmwise gravatar image mmwise  ( 2011-11-26 10:35:03 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2011-11-07 11:38:36 -0500

Seen: 4,440 times

Last updated: May 05 '15