0
$\begingroup$

Rosanswers logo

Just a small question: is it possible to subscribe to a topic from within a library, say, like a costmap_2d layer plugin, and if it is, how is it done?

I've tried to just call NodeHandle::subscribe from the library. The call itself works, however the callback method is never executed.

Thanks a lot!


Originally posted by Hendrik Wiese on ROS Answers with karma: 1145 on 2013-09-18

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

Just do it exactly like in any other code: Make a NodeHandle an subscribe using that.

The only things to look out for: Someone must have called ros::init (usually the main program using the library) and at least one NodeHandle must still be alive.


Originally posted by dornhege with karma: 31395 on 2013-09-18

This answer was ACCEPTED on the original site

Post score: 0


Original comments

Comment by Hendrik Wiese on 2013-09-18:
So with regard to the costmap_2d layers I've tried exactly that. Apparently ros::init isn't called anywhere nor is ros::spin and so messages don't arrive in my layer plugin lib. Well, I'm using a different approach now: I create another point cloud from my data and hand it to another ObstacleLayer.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.