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

Organize packages with top directory or namespace

asked 2021-06-26 07:05:34 -0600

wbadry gravatar image

Hello, I tried to see if this is possible in ROS.

Is it possible to have a package structure like this?

catkin_ws/
├─ src/
│  ├─ project_1_ns/
│  │  ├─ my_robot_pkg/
│  │  │  ├─ CMakeLists.txt
│  │  │  ├─ package.xml
│  ├─ project_2_ns/
│  │  ├─ my_robot_pkg/
│  │  │  ├─ CMakeLists.txt
│  │  │  ├─ package.xml
│  ├─ CMakeLists.txt

THe problem the same package is slightly different and I want to keep the same package name per project. I am ware of the overlayed workspaces via setup.bash. I just don't know if we can add an upper namespace to distinguish packages project_1_ns/my_robot_pkg and project_2_ns/my_robot_pkg

Thanks

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2021-06-26 09:39:51 -0600

gvdhoorn gravatar image

updated 2021-06-26 09:40:26 -0600

(Sub)directories do not namespace packages.

There is only a single, flat, namespace for packages, regardless of how many directories "down" they are nested.

Note that you cannot nest packages, so that can also not be used to namespace them.

Your proposed layout will not work, as (assuming my_robot_pkg is also the name listed in the package.xml) Catkin will complain you have multiple packages with the same name in the workspace.

I see two options (based on the information you provide):

  1. rename the packages (perhaps include the name of the project?)
  2. use separate workspaces, one for each project

Personally, I always use the second approach.

If projects have common dependencies, I put those either in an underlay and use that underlay in the project-specific workspaces, or just checkout copies of those common dependencies in all workspaces (less work, and depending on the nr of dependencies and their sizes, very little overhead).

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2021-06-26 07:05:34 -0600

Seen: 118 times

Last updated: Jun 26 '21