ROS与boost::bind( )
来源:互联网 发布:海辉软件 国际 集团 编辑:程序博客网 时间:2024/06/16 07:43
转自:http://blog.csdn.net/yaked/article/details/44942773
C++的书我自认为看过不少,但是对boost不太熟悉。百度过后boost可以看作是C++的第三方库,像我们常用的iostream等都是自带的库。
因为ROS 的原因,看到许多地方的回调函数(call back)都用到了boost::bind。
1. http://wiki.ros.org/ROSNodeTutorialC%2B%2B
其中talk.cpp的21行 cb = boost::bind(&NodeExample::configCallback, node_example, _1, _2);
其中的 node_example是指针变量NodeExample *node_example = new NodeExample();
2. http://wiki.ros.org/actionlib_tutorials/Tutorials/Writing%20a%20Callback%20Based%20Simple%20Action%20Client
最下面的 fibonacci_class_client.cpp 中的25行
ac.sendGoal(goal, boost::bind(&MyNode::doneCb, this, _1, _2), Client::SimpleActiveCallback(), Client::SimpleFeedbackCallback());
来取代
ac.sendGoal(goal, &doneCb, &activeCb, &feedbackCb);
参考网站:
http://www.boost.org/doc/libs/1_43_0/libs/bind/bind.html#with_member_pointers
bind(f, _1, 5)(x)is equivalent to f(x, 5); here _1 is a placeholder argument that means "substitute with the first input argument."
这里的 _1 相当于一个占位符,用来代替第一个输入参数。
bind( f, 5, _1)(x); // f(5, x)
bind( f, _2, _1)(x, y); // f(y, x)
bind( g, _1, 9, _1)(x); // g(x, 9, x)
bind( g, _3, _3, _3)(x, y, z); // g(z, z, z)
bind( g, _1, _1, _1)(x, y, z); // g(x, x, x)
观察上面的两个地方的boost::bind,都是boost::bind(&NodeExample::configCallback, node_example, _1, _2)差不多形式,搞懂一个就好。
bind(&X::f, &x, _1)(i); //(&x)->f(i)
因此boost::bind(&NodeExample::configCallback, node_example, _1, _2)的意思就是 node_example -> configCallback(x, y)
- ROS与boost::bind( )
- ROS与boost::bind( )
- boost::function与boost::bind 的使用
- [C++] boost::function boost::bind 与 回调
- Boost程序库学习-bind与function
- boost::bind与find_if的搭配使用
- boost::bind的理解与使用
- boost.bind
- boost::bind
- boost::bind
- boost::bind
- Boost::bind
- Boost::bind
- bind -boost
- boost::bind()
- boost bind
- boost::bind
- boost::bind
- [android] adb install 多设备时指定设备app
- 分享Iteye的开涛对Ioc的精彩讲解
- Android wifi学习Demo
- make: 警告:检测到时钟错误。您的创建可能是不完整的。
- JS---小技巧总结
- ROS与boost::bind( )
- shell脚本备份mysql和项目数据
- 用Android Studio进行内存分析调试
- iOS开发之利用MVVM框架来优化项目结构。对Controller瘦身以及MVC向MVVM框架的迁移。
- ADAS 详解
- 百度URL API实现地址 经纬度互相转换
- 内部类(总结版)
- kernel中各种initcall的优先级
- opencv编译中下载opencv_ffmpeg.dll和ippicv出错的相关办法