当前位置:网站首页>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

边栏推荐
- MySQL function to get the full path
- Business Intelligence BI and business management decision-making thinking 4: business cost analysis
- 小小笔记-整型提升(C语言)
- Swin-Transformer(2021-08)
- 设计电商秒杀系统
- 全栈代码测试覆盖率及用例发现系统的建设和实践
- Entropy - conditional entropy - joint entropy - mutual information - cross entropy
- Redis beginner to master 01
- Kalman滤波器--从高斯融合推导
- 「经验」爬虫在工作中的实战应用『实现篇』
猜你喜欢

20220607跌破建议零售价,GPU市场正全面走向供过于求...

虚拟主机什么时候适合更换成云主机?

BeanUtils.copyProperties() 对比 mapstruct

程序员女友给我做了一个疲劳驾驶检测

全技术栈、全场景、全角色云原生系列培训重磅首发,助力企业打造硬核云原生技术团队

华兴证券:混合云原生架构下的 Kitex 实践

商业智能BI与业务管理决策思维之四:业务成本分析

Swin-transformer --relative positional Bias

Sqlserver SQL Server Management Studio and transact SQL create accounts and create read-only users to access the specified database

Swin-transformer --relative positional Bias
随机推荐
[community star selection] the 23rd issue of the July revision plan | bit by bit creation, converging into a tower! Huawei freebuses 4E and other cool gifts
10 statistical methods commonly used for "dry goods" data analysis, with key application scenarios attached
开发那些事儿:Linux系统中如何安装离线版本MySQL?
slice
美国服务器租用和托管服务哪个好?
Swin-transformer --relative positional Bias
torch. roll
Lenovo Yoga 27 2022, full upgrade of super configuration
熵-条件熵-联合熵-互信息-交叉熵
拓维信息使用 Rainbond 的云原生落地实践
Redis入门到精通01
Rust 如何实现依赖注入?
Neon optimization 2: arm optimization high frequency Instruction Summary
Memory Limit Exceeded
20220528【聊聊假芯片】贪便宜往往吃大亏,盘点下那些假的内存卡和固态硬盘
Video content production and consumption innovation
torch stack() meshgrid()
mysql修改数据类型_MySQL修改字段类型[通俗易懂]
ArcGIS无插件加载(无偏移)天地图
Kalman filter -- Derivation from Gaussian fusion