ROS消息过滤器 ( message_filters)
2016-06-29 17:12
363 查看
参考地址:http://wiki.ros.org/message_filters
1.概述
message_filter是roscpp和rospy的一个应用库,他集中了一些滤波算法中常用的一些消息。当一个消息到来,在之后的一个时间点,该消息可能被返回或者不返回,将这样的一个过程或者容器理解为消息滤波器。
一个典型的例子就是时间同步器,他从多个数据源采集不同类型的数据,只有每个消息源的消息具体有相同的时间戳时候,他才将信息发布出去。
时间同步装置的一个例子:输入不同类型(type)的多个数据(source),但是仅当接收到的每个数据(source)有相同的时间戳(timestamp),才会有输出(output)。
2. 滤波模式
所有的消息滤波器服从相同的模式,用于连接输入和输出。输入通过滤波器的构造器或者connectInput()的方法连接。输出通过registerCallback()方法连接。
需要注意的是,每个滤波器各自定义输入输出的类型,所以并不是所有的滤波器可以直接互联。
例如:给了两个filters FooFilter 和 BarFilter,其中FooFilter的output和BarFilter的输入数据一致。连接foo和bar的C++例子如下
2.1 registerCallback()
你可以采用registerCallback()方法,注册多个回调函数。他们将按照注册顺序进行函数的回调。
3 订阅器Subscriber
The Subscriber filter
is simply a wrapper around a ROS subscription that provides a source for other filters. TheSubscriber filter
cannot connect to another filter's output, instead it uses a ROS topic as its input.
3.1 连接
输入:没有输入连接
输出:void callback(const boost::shared_ptr<M const>&)
例子:
is the equivalent of:
4. 时间一致器
The TimeSynchronizer filter synchronizes incoming channels by the timestamps contained in their headers, and outputs them in the form of a single callback that takes the same number of channels. The C++ implementation can synchronize
up to 9 channels.
Input
C++: Up to 9 separate filters, each of which is of the form void callback(const boost::shared_ptr<M const>&). The number of filters supported is determined
by the number of template arguments the class was created with.
Python: N separate filters, each of which has signature callback(msg).
Output
C++: For message types M0..M8,void callback(const boost::shared_ptr<M0 const>&, ..., const boost::shared_ptr<M8 const>&).
The number of parameters is determined by the number of template arguments the class was created with.
Python: callback(msg0.. msgN). The number of parameters is determined by the number of template arguments the class was created with.
Suppose you are writing a ROS node that needs to process data from two time synchronized topics. Your program will probably look something like this:
(Note: In this particular case you could use the CameraSubscriber class
from image_transport, which essentially wraps the filtering code above.)
参考:http://blog.csdn.net/fana8010/article/details/23880067. 十分感谢
1.概述
message_filter是roscpp和rospy的一个应用库,他集中了一些滤波算法中常用的一些消息。当一个消息到来,在之后的一个时间点,该消息可能被返回或者不返回,将这样的一个过程或者容器理解为消息滤波器。
一个典型的例子就是时间同步器,他从多个数据源采集不同类型的数据,只有每个消息源的消息具体有相同的时间戳时候,他才将信息发布出去。
时间同步装置的一个例子:输入不同类型(type)的多个数据(source),但是仅当接收到的每个数据(source)有相同的时间戳(timestamp),才会有输出(output)。
2. 滤波模式
所有的消息滤波器服从相同的模式,用于连接输入和输出。输入通过滤波器的构造器或者connectInput()的方法连接。输出通过registerCallback()方法连接。
需要注意的是,每个滤波器各自定义输入输出的类型,所以并不是所有的滤波器可以直接互联。
例如:给了两个filters FooFilter 和 BarFilter,其中FooFilter的output和BarFilter的输入数据一致。连接foo和bar的C++例子如下
FooFilter foo; BarFilter bar(foo);或者:
FooFilter foo; BarFilter bar; bar.connectInput(foo);
2.1 registerCallback()
你可以采用registerCallback()方法,注册多个回调函数。他们将按照注册顺序进行函数的回调。
3 订阅器Subscriber
The Subscriber filter
is simply a wrapper around a ROS subscription that provides a source for other filters. TheSubscriber filter
cannot connect to another filter's output, instead it uses a ROS topic as its input.
3.1 连接
输入:没有输入连接
输出:void callback(const boost::shared_ptr<M const>&)
例子:
message_filters::Subscriber<std_msgs::UInt32> sub(nh, "my_topic", 1); sub.registerCallback(myCallback);
is the equivalent of:
ros::Subscriber sub = nh.subscribe("my_topic", 1, myCallback);
4. 时间一致器
The TimeSynchronizer filter synchronizes incoming channels by the timestamps contained in their headers, and outputs them in the form of a single callback that takes the same number of channels. The C++ implementation can synchronize
up to 9 channels.
Connections
InputC++: Up to 9 separate filters, each of which is of the form void callback(const boost::shared_ptr<M const>&). The number of filters supported is determined
by the number of template arguments the class was created with.
Python: N separate filters, each of which has signature callback(msg).
Output
C++: For message types M0..M8,void callback(const boost::shared_ptr<M0 const>&, ..., const boost::shared_ptr<M8 const>&).
The number of parameters is determined by the number of template arguments the class was created with.
Python: callback(msg0.. msgN). The number of parameters is determined by the number of template arguments the class was created with.
Example (C++)
Suppose you are writing a ROS node that needs to process data from two time synchronized topics. Your program will probably look something like this:#include <message_filters/subscriber.h> #include <message_filters/time_synchronizer.h> #include <sensor_msgs/Image.h> #include <sensor_msgs/CameraInfo.h> using namespace sensor_msgs; using namespace message_filters; void callback(const ImageConstPtr& image, const CameraInfoConstPtr& cam_info) { // Solve all of perception here... } int main(int argc, char** argv) { ros::init(argc, argv, "vision_node"); ros::NodeHandle nh; message_filters::Subscriber<Image> image_sub(nh, "image", 1); message_filters::Subscriber<CameraInfo> info_sub(nh, "camera_info", 1); TimeSynchronizer<Image, CameraInfo> sync(image_sub, info_sub, 10); sync.registerCallback(boost::bind(&callback, _1, _2)); ros::spin(); return 0; }
(Note: In this particular case you could use the CameraSubscriber class
from image_transport, which essentially wraps the filtering code above.)
参考:http://blog.csdn.net/fana8010/article/details/23880067. 十分感谢
相关文章推荐
- 收集的ROS防火墙脚本
- ROS限速脚本 动态限速 固定限速
- ROS超智能的脚本
- ROS 采用NAT方式提高双线转发效率的方法
- ROS最正确的限速--------小包优先+带宽均分+简单队列限制上传速度
- ROS用流量监控动态控制限速点(新方法)----预留带宽
- ROS與二層交換機3COM(4200)做24個多出口ADSL(固定IP)拔號
- ROS莫明掉线断流的解决方法
- 如何使用ROS 限制BT下载
- ros防火墙脚本(经典推荐)
- ROS加强精通过程--禁止 未授权用户上网
- ROS最正确的限速--------小包优先+带宽均分+简单队列限制上传速度
- Ros强开指定首页,类似电信的ADSL强开指定首页,即push功能
- ROS做PCQ集体限速图
- ROS软路由 IPSec配置
- ROS的***设置—PPTP借线操作
- 关于类似于电信弹出广告(push业务),使用ROS与简单web服务器实现
- 在routeros中只允许用户dhcp上网
- Ros固定IP共享上网设置
- ROS 封QQ脚本