Class ThrottleLimiter

Inheritance Relationships

Base Type

Class Documentation

class ThrottleLimiter : public cras::RateLimiter

The (not so clever) algorithm used by topic_tools/throttle node.

Note

It is not very good at achieving the requested if it isn’t orders of magnitude smaller than the incoming rate.

Public Functions

explicit ThrottleLimiter(const ::rclcpp::Rate &rate)
explicit ThrottleLimiter(const ::rclcpp::Clock::SharedPtr &clock, const ::rclcpp::Duration &period)
virtual bool shouldPublish(const ::rclcpp::Time &stamp) override

Call this function whenever a message is received. It tells whether the message has passed the rate-limiting and should be published, or whether it should be skipped.

Parameters:

stamp[in] Time when the message should be sent (usually not header.stamp!).

Returns:

Whether to continue publishing the message.

virtual void reset() override

Reset the rate-limiter as if it were newly created with the same parameters.

Protected Attributes

::rclcpp::Time lastPublishTime = {0, 0}

Stamp of the last message for which shouldPublish() returned true.