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

Revision history [back]

click to hide/show revision 1
initial version

From the API docs it seems that all the boost::bind versions (11 and 12 out of 13) require you to also specify the tracked object:

tracked_object: A shared pointer to an object to track for these callbacks. If set, the a weak_ptr will be created to this object, and if the reference count goes to 0 the subscriber callbacks will not get called. Note that setting this will cause a new reference to be added to the object before the callback, and for it to go out of scope (and potentially be deleted) in the code path (and therefore thread) that the callback is invoked from.

The default seems to be typedef boost::shared_ptr<void const> ros::VoidConstPtr, i.e. this compiles:

    sub = nh_.subscribe<std_msgs::String>("mytopic", 10, boost::bind(&TransportHintsTest::callback<std_msgs::String>,
                                                                     this,
                                                                     _1,
                                                                     id),
                                          ros::VoidConstPtr(),
                                          ros::TransportHints().tcpNoDelay());

From the API docs it seems that all the boost::bind versions (11 and 12 out of 13) require you to also specify the tracked object:

tracked_object: A shared pointer to an object to track for these callbacks. If set, the a weak_ptr will be created to this object, and if the reference count goes to 0 the subscriber callbacks will not get called. Note that setting this will cause a new reference to be added to the object before the callback, and for it to go out of scope (and potentially be deleted) in the code path (and therefore thread) that the callback is invoked from.

The default seems to be typedef boost::shared_ptr<void const> ros::VoidConstPtr, i.e. this compiles:

#include <ros/forwards.h>

    sub = nh_.subscribe<std_msgs::String>("mytopic", 10, boost::bind(&TransportHintsTest::callback<std_msgs::String>,
                                                                     this,
                                                                     _1,
                                                                     id),
                                          ros::VoidConstPtr(),
                                          ros::TransportHints().tcpNoDelay());

From the API docs it seems that all the boost::bind versions (11 and 12 out of 13) require you to also specify the tracked object:

tracked_object: A shared pointer to an object to track for these callbacks. If set, the a weak_ptr will be created to this object, and if the reference count goes to 0 the subscriber callbacks will not get called. Note that setting this will cause a new reference to be added to the object before the callback, and for it to go out of scope (and potentially be deleted) in the code path (and therefore thread) that the callback is invoked from.

The default seems to be typedef boost::shared_ptr<void const> ros::VoidConstPtr, i.e. this compiles:

#include <ros/forwards.h>

    sub = nh_.subscribe<std_msgs::String>("mytopic", 10, boost::bind(&TransportHintsTest::callback<std_msgs::String>,
                                                                     this,
                                                                     _1,
                                                                     id),
                                          ros::VoidConstPtr(),
                                          ros::TransportHints().tcpNoDelay());