# Build node from within an existing CMake project

updated question:

My application produces data, some of which I'd like to share with another party's application. The other application uses ROS. Whats the easiest way to share my data with the other application? It's not yet specified what data should be exchanged, so ideally the solution would work with custom made messages.

Pre-Edit

I build a simple node in a catkin workspace. I want to wrap this node in a shared library that is build as part of my existing CMake project [1]. I found almost no information how to build a node outside a catkin workspace [2].

Or am I going at it all wrong? The only other straightforward method seems to be: 1) Build the node as a standalone application 2) Establish a communication between it and my existing software (for example server-client) 3) Send data to the node which in turn publishes it to the ROS network

This seems overly inefficient/complicated to me and I'd expect my use case to be rather common, so I want to make sure whether this is the preferred design. If its not, I would be very thankful for pointing me in the right direction.

Thanks for any help!

[1] * to ensure ABI compatibility * to allow loading it during run-time as needed * to make dependencies to ROS private (as in add_library(target_name PRIVATE <ros_stuff>)

[2] Only a "maybe look at this" http://jbohren.com/tutorials/2014-02-... but this also plays around with setting environment variables. I'd need passing arguments to somewhere since my software is already running before I start the node.

edit retag close merge delete

I want to wrap this node in a shared library that is build as part of my existing CMake project. I found almost no information how to build a node outside a catkin workspace

May have been not at the top of your search results, but I believe gerkey/ros1_external_use has something to add there.

( 2019-11-08 06:03:45 -0600 )edit

It might be good if you could explain a little more what it is that you actually need/want to do.

You write "a simple node" and then something about communication with an "existing CMake project". That is slightly confusing, as typically nodes are stand-alone programs. Any communication with other programs would be through ROS APIs, or via some other IPC mechanism. But as you write "a shared library", that implies directly loading it into another process.

Are you looking to start a ros::NodeHandle as part of an application that is not what would normally be considered a ROS node and then want to be able to use Publishers and Subscribers from within your application through that NodeHandle?

And to go a little further: are you actually only looking to communicate with a ROS node graphs? Do you absolutely need to use roscpp or would the ability ...(more)

( 2019-11-08 06:06:58 -0600 )edit

@gvdhoorn thanks for the link, it did the trick. As for your second comment, it might well be that something else would be a better fit for my task, but with my limited knowledge of ROS I'm not sure. For the moment my current approach seems to suffice.

( 2019-11-11 04:05:29 -0600 )edit

it might well be that something else would be a better fit for my task, but with my limited knowledge of ROS I'm not sure. For the moment my current approach seems to suffice.

that's why I asked what you actually want to do.

It would allow us here on this board to use our knowledge and experience to provide you with -- potentially easier/more maintainable -- alternatives.

For instance: if you just want to exchange messages with a running ROS application, using any of the alternative client libraries or bridges may be more than sufficient, while being also much easier to integrate (and on different OS fi).

But right now we wouldn't know whether that would be something to even suggest, as you ask about a problem with an approach you've already selected, based on your "limited knowledge of ROS", instead of asking the (perhaps actual ...(more)

( 2019-11-11 04:09:07 -0600 )edit