[ros-users] Subscribing and publishing Topics

Wim Meeussen meeussen at willowgarage.com
Fri Apr 1 15:22:22 UTC 2011


> What i have to do if i get the warning:
> "subscriber on'' destroyed immediately after creation. did you forget to store the handle"
> how can i store handle?

You need to make sure that your ros::Subscriber object does not get
destructed.  I assume you created it in a local scope, and it got
destructed once you went outside the scope. It's a good idea to make
the subscriber a class member.

> if i subscribe a topic, i dont want to get every messages that arrives from that topic i have subscribed.
> i want only get that one, that "now" received.
> If the Callback function taking a while, the messages wich hass arrived while the Callback function is working, will stored in the quee, wenn the callback function has finished, the Callback function will called with the second messaged, but i want that it called with the last message that received:)

If you change the queue length of your subscriber to 1, there will
only ever be a single message in the queue. And that message will be
the last message that was received.

Hope this helps,


Wim Meeussen
Willow Garage Inc.

More information about the ros-users mailing list