ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Subscribe topic from library?

asked 2013-09-18 01:35:37 -0500

Hendrik Wiese gravatar image

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!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2013-09-18 03:47:58 -0500

dornhege gravatar image

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.

edit flag offensive delete link more


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.

Hendrik Wiese gravatar image Hendrik Wiese  ( 2013-09-18 04:40:19 -0500 )edit

Question Tools

1 follower


Asked: 2013-09-18 01:35:37 -0500

Seen: 100 times

Last updated: Sep 18 '13