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

Renaming a package

asked 2012-02-22 02:16:34 -0500

jlo gravatar image

updated 2012-02-23 00:09:13 -0500

Hi there, I created a package named 'A'. After a while, I wanted to create package 'B' that would be exactly the same as A, just changing some parts of the source code. Is there a way I can:

  1. Rename the package A (so that roscd will recognize the new name for A)
  2. Copy-paste A's folder, rename it and make roscd recognize it (as let's say, package 'B')

Otherwise, the only solution I can think of is roscreating the packages again. I'm sure there's a wiser alternative.

Thanks! :)

Update: felix_k's answer works, but you have to execute 'rospack profile', so that ROS can register you have changed the names. Great! Thanks everybody.

edit retag flag offensive close merge delete

Comments

4

For most simple packages you only have to rename the folder, adjust the name in the manifest and python's load_manifest('...') lines. And any docs/src where it's hard coded, but that could be automatically textually replaced.

felix k gravatar image felix k  ( 2012-02-22 02:30:01 -0500 )edit

It doesn't work. I have changed the folder's name and the name in the manifest.xml, but when I operate a terminal and write "roscd ROS<tab>" instead of "ROSnew" (the new name") it still uses the old one "ROSold". Any other ideas :/? I'm sure something has to be updated for the system to get it.

jlo gravatar image jlo  ( 2012-02-22 21:14:25 -0500 )edit
2

On my system (using zsh), I have to run "rospack profile" for roscd tab completion to work after moving a new package into the ROS path. If you type in "roscd ROSnew" (without tab completion), it should work anyway.

Martin Günther gravatar image Martin Günther  ( 2012-02-23 22:13:48 -0500 )edit

3 Answers

Sort by » oldest newest most voted
5

answered 2012-02-22 06:02:47 -0500

kwc gravatar image

felix_k's comment is the correct answer. Be care to not copy any build artifacts, and make sure to change any package/namespace declarations in your code to match.

edit flag offensive delete link more

Comments

1

I think it would be more helpful to provide a step by step solution instead of pointing to someone's solution. I would definitely edit this answer to address what I'm saying, if I could.

nbro gravatar image nbro  ( 2017-04-27 16:03:11 -0500 )edit
3

answered 2018-03-11 22:17:44 -0500

M@t gravatar image

updated 2018-03-12 03:13:19 -0500

I was able to successfully change the name of my ROS/Catkin package from "PackageA" to "PackageB" by changing the following:

  1. Folder name: /workspace/src/PackageA
  2. Folder name: /workspace/src/PackageA/include/PackageA
  3. Every instance of "PackageA" in the following files located in /workspace/src/PackageA:
    • CMakeLists.txt
    • CMakeLists.txt.user
    • package.xml
  4. Any instance of "PackageA" in any of your source files that include header files you've written. E.g. if your main.cpp has anything like #include <PackageA/my_custom_header.h> then you obviously need to replace this too.

Depending on your specific build environment, there may or may not be additional files with instances of "PackageA" that you need to change. But everything above should be at least the bare minimum that you have to change. After I change all of the above, I was able to run catkin_make and everything recompiled as if "PackageB" had been it's name all along.

As jilo and Martin Gunther already stated, running rospack profile enables roscd to handle the name change.

FYI: I would be very careful copy-pasting any packages, since I'd had problems with this before. Depending on your environment and what you're compiling, you make get cmake errors complaining about trying to link libraries to files that already existing in other packages.

edit flag offensive delete link more

Comments

You write:

Every instance of "PackageA" in the following files located in /workspace/src/PackageA:

    CMakeCache.txt

I don't know if you're using some IDE that is responsible for this, but CMakeCache.txt should not be in your source space.

gvdhoorn gravatar image gvdhoorn  ( 2018-03-12 02:59:27 -0500 )edit

Really? Ok, thanks for the heads up. I've removed that bit from my answer and I'll look into why that's turned up there. I'm using Qt Creator for reference.

M@t gravatar image M@t  ( 2018-03-12 03:15:26 -0500 )edit

The only CMake artefact that should be in your source space is CMakeLists.txt (and maybe some additional .cmake files/modules). Everything else is a configuration phase generated artefact, and should be located in the build space.

gvdhoorn gravatar image gvdhoorn  ( 2018-03-12 03:17:17 -0500 )edit

Shouldn't package.xml also be there? According to the catkin package tutorial.

M@t gravatar image M@t  ( 2018-03-12 03:23:04 -0500 )edit

Yes, but that is not something CMake primarily uses. Both of those files are needed to make a directory a ROS package, but CMake doesn't care.

gvdhoorn gravatar image gvdhoorn  ( 2018-03-12 03:29:43 -0500 )edit
1

answered 2017-04-27 18:00:52 -0500

130s gravatar image

updated 2018-03-12 03:37:26 -0500

A while ago I posted a blog entry for semi-systematically changing package(s) name. There's a few steps described, which are pretty much commands. Let me know on the comment section there for whatever missing so that I'll consider adding them.

(I chose to write it on a personal website instead of writing on ROS wiki because it's not specific to ROS at all.)

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2012-02-22 02:16:34 -0500

Seen: 20,274 times

Last updated: Mar 12 '18