How to perform parallel computing in a separate thread over historical data in ROS?

asked 2019-01-23 01:43:11 -0500

Spartan_007 gravatar image

updated 2019-01-23 01:44:48 -0500


I am writing a node in C++, where I subscribe robot geometry_msgs/PoseStamped type pf message and lidar's \scan. I have a few lidars. For mapping purpose and path-planning I need to perform some computation that requires historical data and I would like to do it in a separate thread simultaneously, when the master node is running (subscribing, or publishing in some topic). Whenever, the other thread that is running in parallel is done with the computation (upto some time instant), that data should be accessible to the master node for decision making. This process should continue until the goal is achieved. I looked into OpenMp parallel programming resources. I kind of have the idea but quite vaguely. Would anyone kindly help me in figuring out how to start writing the node that would run in parallel?

Any kind of help is highly appreciated.

edit retag flag offensive close merge delete


It is a bit unclear from your question what the problem is. All nodes in ROS run in parallel. If you have a node that processes some inputs and you want to do something with the result, then just publish the result in a topic and use the topic in another node.

Reamees gravatar image Reamees  ( 2019-01-23 03:49:39 -0500 )edit


based on the question statement above, imagine that I want to process the scan and pose data for upto 100 frames and this number of frames up to which I need to compute, keeps on increasing like exploration task. The computation based on historical data may take long time.

Spartan_007 gravatar image Spartan_007  ( 2019-01-23 04:07:24 -0500 )edit

continued, If I want to perform it in a separate thread, I should be able to access the result after computation is over. Do you think, I can simply save the original published topics in separate files and perform the computation in separate thread and publish corresponding data when its completed?

Spartan_007 gravatar image Spartan_007  ( 2019-01-23 04:10:59 -0500 )edit

At this point, I have a doubt. If the heavy computation requires more than a second, will that node still remain alive? I mean, if the subscriber of the publishers in this node waits for seconds in another node will it still be fine? Please let me know if my doubts are not clear.

Spartan_007 gravatar image Spartan_007  ( 2019-01-23 04:16:28 -0500 )edit

The nodes will not die, unless you program them to die, how long they wait and what they do is entirely down to how you program your nodes. Sorry, can't really be more helpful.

Reamees gravatar image Reamees  ( 2019-01-23 04:31:06 -0500 )edit

ok, thanks. I'll try and let you know if any issues pop up.

Spartan_007 gravatar image Spartan_007  ( 2019-01-23 04:46:05 -0500 )edit

This sounds like a good use case for actions

jayess gravatar image jayess  ( 2019-01-23 09:56:18 -0500 )edit