Skip to content

Allow node clock to be used in THROTTLE log macros #969

@mschickler

Description

@mschickler

Feature request

Feature description

Current implementation of THROTTLE logger macros require rclcpp::Clock object to be a local (due to the way the lambda is defined in the macro body). This precludes the use of the node clock or a clock data member.

Implementation considerations

The lambda could be changed slightly to cache a reference to the clock in a local variable which would allow the THROTTLE macro to be called like this:
RCLCPP_INFO_THROTTLE(get_logger(), *get_clock(), ...)
instead of:
rclcpp::Clock clock;
RCLCPP_INFO_THROTTLE(get_logger(), clock, ...)

The exact change would be in the rclcpp/rclcpp/resource/logging.hpp.em file (see attached diff)
logging.hpp.em.diff.txt

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions