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 addlibrary(targetname PRIVATE
[2] Only a "maybe look at this" http://jbohren.com/tutorials/2014-02-10-roscpp-hello-world/#create-the-simplest-ros-c-program 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.
Asked by raonss on 2019-11-08 06:22:08 UTC
Comments
May have been not at the top of your search results, but I believe gerkey/ros1_external_use has something to add there.
Asked by gvdhoorn on 2019-11-08 07:03:45 UTC
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 usePublisher
s andSubscriber
s from within your application through thatNodeHandle
?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 to subscribe and publish be sufficient?Just trying to avoid an xy-problem here.
Asked by gvdhoorn on 2019-11-08 07:06:58 UTC
@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.
Asked by raonss on 2019-11-11 05:05:29 UTC
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) question: how can I communicate with a ROS application from a non-ROS application?
Asked by gvdhoorn on 2019-11-11 05:09:07 UTC