Issue with RCLCPP THROTTLE logging in the plugin based approach

未关闭
#2,587 6 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
48/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
cpp

调研方向

首先阅读 rcutils/resource/logging_macros.h.em,尤其是报告中引用的 RCUTILS_LOG_CONDITION_THROTTLE_BEFORE 逻辑,并跟踪 RCLCPP_XXX_THROTTLE 如何到达该逻辑。使用不同 logger 名称的多个 plugin 实例验证其行为;完成的标准是每个 logger 都具有独立的 throttle 间隔。payload 未指定测试文件。

由索引模型根据 Issue 内容生成。

描述

bug help wanted

Bug report

Hello!

I've a plugin that I use it to perform some computations and return and this plugin runs at a higher frequency, and then to reduce spamming, I've changed the original logging with THROTTLE. It works fine as long as only one plugin is loaded in my system. If I load multiple plugins of the same type, it doesn't print the THROTTLE log of other plugins but only the first one even though they have different loggers with different names.

I believe this is caused by the fact that the RCLCPP_XXX_THROTTLE internally uses the following macro RCUTILS_LOG_CONDITION_THROTTLE_BEFORE and this is using some static variables inside. The condition for logging (i.e., if a certain duration has passed since the last log message) will remain the same, as this is determined by the code in the macro, not by the logger. The __rcutils_logging_last_logged variable, which keeps track of the last time a log message was outputted, is static and unique to each line where the macro is used. Therefore, even if you change the logger, the duration-based condition for logging will still be unique to each line.

https://github.com/ros2/rcutils/blob/cf3e9986a557e4c893eb718b90c77ce189494a11/resource/logging_macros.h.em#L182-L206

I think it makes sense to also consider the logger type to be same or not in the same check as well. In my current implementation, the logger name is changed depending on the name of the plugin, but not the type. This way it is unique for every plugin instance.

Required Info:

  • Operating System:
    • Ubuntu 22.04 and 24.04
  • Installation type:
    • Binaries
Expected behavior

Different loggers should have different throttles even if they are in the same line as the plugin

Actual behavior

Different loggers are throttles as one and the information is lost inside the plugin

Is there a workaround or a better approach in this case?

主要语言
C++
星标
829
派生
587
平均合并
4 天 6 小时
30 天内合并 PR
30

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

ros2/rclcpp 的其他 Issue

查看 ros2/rclcpp 的全部 Issue

相似的 Issue

更多 C++ Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。