ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
I'm going to ask what you expect to happen.
Let's look at your main (where your program starts).
First line, init ros, nothing weird.
Second line, nodehandle, still nothing weird.
Third line, here it gets interesting. You create an object. What does that mean? Answer: You go through the constructor, so let's look at that:
cloud_callback
as callback function. The other one with cloud_processing
as callback function (This is important, remember this).And that's it for the third line.
Now let's take a look at the fourth and final line of your main: ros::spin();
. A very simple explanation of spin()
is that it checks with all its subscribers (2 in your case) if new messages have arrived. It's basically a loop of that one line (line 4). As long as ROS is OK, it will keep looping that one line (check if there are messages and call the callback functions).
However, once the callback function cloud_processing
is called even once, you shut your subscribers down.
In other words, you have a spin()
that has nothing to do anymore, there are no subscribers to check, because you terminated them. Your object (ObjectD
) is never going to call it's constructor again (that's how objects work), so your subscribers will never be started up again.
Hence my original question: What do you expect to happen?