Quantcast
Channel: ROS Answers: Open Source Q&A Forum - RSS feed
Viewing all articles
Browse latest Browse all 98

Understanding registerCallback() from TF MessageFilter tutorial

$
0
0
I'm going through the TF [MessageFilter tutorial](http://wiki.ros.org/tf/Tutorials/Using%20Stamped%20datatypes%20with%20tf%3A%3AMessageFilter) and I understand the code except for line 13: tf_filter_->registerCallback( boost::bind(&PoseDrawer::msgCallback, this, _1) ); I'm more of a novice when it comes to using the `boost` libraries, but after reading some documentation, it seems that this line is creating a function object that equates to something of this form: `msgCallback(this, _1)` where `this` is the PoseDrawer object and `_1` is a placeholder that will be substituted with the first argument provided to the function object (which I'm assuming is done by the TF library under the hood). What I'm confused about is how you know to provide the `this` object and that the callback function needs an `_1` placeholder. Is the `_1` simply because the callback function (shown below) only takes one argument? If my callback function had no parameters, would I just remove the `_1` argument when calling the function? Why is the `this` object necessary? void msgCallback(const boost::shared_ptr& point_ptr)

Viewing all articles
Browse latest Browse all 98

Trending Articles