当前位置:网站首页>ROS advertisement data publishing tips - latch configuration
ROS advertisement data publishing tips - latch configuration
2022-06-30 19:24:00 【Dragon like take-off】
stay ros Of published data advertise The last parameter in the function parameter "latch", The default is false, Never noticed , Today, when analyzing other problems, we are ros wiki[Publishers and Subscribers] I accidentally noticed this parameter on the ,
The explanation is as follows :
latch [optional]
- Enables "latching" on a connection. When a connection is latched, the last message published is saved and automatically sent to any future subscribers that connect. This is useful for slow-changing to static data like a map. Note that if there are multiple publishers on the same topic, instantiated in the same node, then only the last published message from that node will be sent, as opposed to the last published message from each publisher on that single topic.
advertise Functions are defined in the file /opt/ros/melodic/include/ros/node_handle.h, It also explains .
/**
* \brief Advertise a topic, simple version
*
* This call connects to the master to publicize that the node will be
* publishing messages on the given topic. This method returns a Publisher that allows you to
* publish a message on this topic.
*
* This version of advertise is a templated convenience function, and can be used like so
*
* ros::Publisher pub = handle.advertise<std_msgs::Empty>("my_topic", 1);
*
* \param topic Topic to advertise on
*
* \param queue_size Maximum number of outgoing messages to be
* queued for delivery to subscribers
*
* \param latch (optional) If true, the last message published on
* this topic will be saved and sent to new subscribers when they
* connect
*
* \return On success, a Publisher that, when it goes out of scope,
* will automatically release a reference on this advertisement. On
* failure, an empty Publisher.
*
* \throws InvalidNameException If the topic name begins with a
* tilde, or is an otherwise invalid graph resource name, or is an
* otherwise invalid graph resource name
*/
template <class M>
Publisher advertise(const std::string& topic, uint32_t queue_size, bool latch = false)
{
AdvertiseOptions ops;
ops.template init<M>(topic, queue_size);
ops.latch = latch;
return advertise(ops);
}Generally, the receiving node cannot receive data until the publishing node is started , But the starting sequence is sometimes out of control , Some data will be lost , Especially for maps that are released only once . When the publishing data end is set to latch = true, The late node can also receive the last frame message before . Another particularly useful thing is publishing rviz Visual data debugger , according to namesapce When analyzing some results , You can check repeatedly to show some items , Just in rviz Check this again in the Display Can , No need to replay the data .
Here's the picture , Play first bag data , After suspension , stay rviz Check to display

边栏推荐
- Video content production and consumption innovation
- Opencv data type code table dtype
- CODING 正式入驻腾讯会议应用市场!
- Swin-Transformer(2021-08)
- Regular expressions (regular matching)
- VMware16安装Win11虚拟机(最全步骤+踩坑)
- Cobbler is easy to use
- 如何使用物联网低代码平台进行服务管理?
- Redis beginner to master 01
- 20220607 fell below the recommended retail price, and the GPU market is moving towards oversupply
猜你喜欢
随机推荐
Four tips tell you how to use SMS to promote business sales?
Word——Word在试图打开文件时遇到错误的一种解决办法
程序员女友给我做了一个疲劳驾驶检测
Large file transfer software based on UDP protocol
Lenovo Yoga 27 2022, full upgrade of super configuration
全栈代码测试覆盖率及用例发现系统的建设和实践
MySQL 索引测试
Practical application of "experience" crawler in work "theory"
How does rust implement dependency injection?
年复一年,为什么打破数据孤岛还是企业发展的首要任务
Ditto设置全局仅粘贴文本快捷键
简述机器学习中的特征工程
【DesignMode】单例模式(singleton pattern)
CODING 正式入驻腾讯会议应用市场!
js 字符串截取方法汇总
20220528 [talk about fake chips] those who are greedy for cheap often suffer heavy losses. Take stock of those fake memory cards and solid state drives
opencv数据类型代码表 dtype
DTD modeling
基于UDP协议设计的大文件传输软件
dtd建模









