How to perform parallel computing in a separate thread over historical data in ROS?
Hi,
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.
Asked by Spartan_007 on 2019-01-23 02:43:11 UTC
Comments
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.
Asked by Reamees on 2019-01-23 04:49:39 UTC
Hi,
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.Asked by Spartan_007 on 2019-01-23 05:07:24 UTC
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?
Asked by Spartan_007 on 2019-01-23 05:10:59 UTC
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.
Asked by Spartan_007 on 2019-01-23 05:16:28 UTC
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.
Asked by Reamees on 2019-01-23 05:31:06 UTC
ok, thanks. I'll try and let you know if any issues pop up.
Asked by Spartan_007 on 2019-01-23 05:46:05 UTC
This sounds like a good use case for actions
Asked by jayess on 2019-01-23 10:56:18 UTC