一、函数定义

  1. ros::Subscriber subscribe(const std::string& topic, uint32_t queue_size, <callback, which may involve multiple arguments>, const ros::TransportHints& transport_hints = ros::TransportHints());
  • 主要讨论queue_size的影响。
  • This is the incoming message queue size roscpp will use for your callback. 系统设置message queue的大小。
  • If messages are arriving too fast and you are unable to keep up, roscpp will start throwing away messages. 一般而言,如果设置queue_size=10,即如果收到的数据大于10,则将开始抛弃最初收到的第一个数据。

二、设置多大合适

1. 设置为0

  • A value of 0 here means an infinite queue, which can be dangerous. queue_size大小会影响内存的使用。

2. 设置为1,2,3

  • 适用于10Hz的更新情况
  • 设置为1,意味着系统总是使用最新发布的数据,only care about the latest measurement.

3. 设置大于10

  • 系统更需要按顺序执行,例如digital_IO信号。

Reference

http://wiki.ros.org/rospy/Overview/Publishers%20and%20Subscribers#Choosing_a_good_queue_size

相关文章:

  • 2021-07-22
  • 2022-12-23
  • 2022-12-23
  • 2021-04-18
  • 2021-09-14
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-07-06
  • 2021-12-07
  • 2021-12-16
  • 2021-09-09
  • 2022-12-23
  • 2022-12-23
  • 2021-07-30
相关资源
相似解决方案