Robotics StackExchange | Archived questions

Can a Custom Message Built In a Workspace Be Used in Another?

I ran into an interesting scenario: I have two Catkin workspaces, in workspace A,I built a message type "MyMsg". Later for a different project, in workspace B, I made a different version of "MyMsg.msg" and built successfully.

When I start working in workspace B, I thought the workspace B would use its own "MyMsg.msg", but I realized I was wrong when I used rosmsg show to check for message type information.

So is it true that one message type previously built in a catkin workspace can be seen and used in another? Also it might override the local message type with the same name?

Asked by RicoJ on 2020-10-26 11:09:24 UTC

Comments

Answers

It is possible to use a message from one workspace in another. What you need to do to achieve this is to set up chained (or overlayed) workspaces. ROS is looking through the ROS_PACKAGE_PATH, which is something along the lines of <WORKSPACE_B>:<WORKSPACE_A>:/opt/ros/<DISTRO>/share (if you are using catkin_make).

Basically, you do something similar every time you create a workspace, by overlaying the /opt/ros packages with your source workspace.

The first match found is the one that is used, then.

So, basically, depending on how you set up your workspaces, this might very well happen. In the above scenario, you can use a message from workspace A in workspace B as long as there is not the same package available in workspace B. Note that is important that you always use fully qualified message identifiers (i.e. including the package name <my_pkg>/MyMsg whereever you use those packages).

To directly answer your questions:

So is it true that one message type previously built in a catkin workspace can be seen and used in another?

Yes, absolutely.

Also it might override the local message type with the same name?

No, this cannot happen (as long as building the "local" message worked out fine, the name including the package is identical and you've sourced the right workspace in every terminal you want to use)

Asked by mgruhler on 2020-10-27 02:08:56 UTC

Comments