Ask Your Question
0

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

asked 2020-10-26 11:09:24 -0500

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?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2020-10-27 02:08:56 -0500

mgruhler gravatar image

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)

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

2 followers

Stats

Asked: 2020-10-26 11:09:24 -0500

Seen: 163 times

Last updated: Oct 27 '20