ROS 通信框架部分
ROS 通信框架部分
参考
前言
记录
message_filters
基本概念
基本代码
Time Synchronizer
Time Sequencer
Cache
Policy-Based Synchronizer
Chain
ros_bag
ros_graph
XmlRpc++
参考
前言
记录
message_filters
基本概念
基本代码
Time Synchronizer
Time Sequencer
Cache
Policy-Based Synchronizer
Chain
ros_bag
ros_graph
XmlRpc++
参考
前言
记录
message_filters
基本概念
- 集中处理多个消息来源的模块,或者说是进行消息同步的模块
基本代码
// 构造 FooFilter foo; BarFilter bar(foo);//Bar的输入连接着foo的输出 bar.connectInput(foo);//等价 bar.registerCallback(myCallback);//myCallback是一个可调用对象
Time Synchronizer
- 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.
#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; }
- 时间同步器现在还支持时间相近的时间戳的消息聚合处理,见后面的Policy-Based Synchronizer
Time Sequencer
- The TimeSequencer filter guarantees that messages will be called in temporal order according to their header‘s timestamp. The TimeSequencer is constructed with a specific delay which specifies how long to queue up messages before passing them through. A callback for a message is never invoked until the messages‘ time stamp is out of date by at least delay. However,for all messages which are out of date by at least the delay,their callback are invoked and guaranteed to be in temporal order. If a message arrives from a time prior to a message which has already had its callback invoked,it is thrown away.
Cache
- 可以存储时间上最近的N个消息
Policy-Based Synchronizer
- 基于某种策略的消息同步
- 有两种同步:ExactTime和ApproximateTime
Chain
ros_bag
ros_graph
XmlRpc++
- 是XML-RPC机制的C++实现,XmlRpc是远程过程调用的一种方式,不过更加简单一些,其使用XML作为数据交换格式,使用HTTP协议进行通信。
- 所有IO都是非阻塞式的,所以网络状态不佳也不会拖慢服务端
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。