Skip to content

fly4future/hz_subscriber

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

F4F Logo

Hz subscriber

hz_subscriber is a ROS 2 component package intended to replace ros2 topic hz ... when the topic producer is running as a composable node or component.

📌About The Project

The main goal is to measure topic frequency with much lower overhead by loading the frequency subscriber into the same component container as the publisher, so both can use intra-process communication instead of an external CLI subscriber process.

🏁Motivation

The standard ros2 topic hz command runs as a separate ROS 2 process, not as a component inside the same container as the publisher. As a result, it does not benefit from the same-process composition model used by ROS 2 components.

When working with high-bandwidth image topics, this extra process and transport path can noticeably increase CPU and memory usage, while node composition is specifically designed to reduce that overhead by colocating components in one process.

Note

This package is meant for composable nodes or components, not as a general replacement for every ros2 topic hz use case.

🎈What this package does

This package provides a lightweight C++ subscriber component that:

  • Subscribes to a target topic, typically an image topic.
  • Computes average rate, minimum period, maximum period, standard deviation, and sample window.
  • Prints an output similar to ros2 topic hz, for example:
average rate: 59.978
        min: 0.014s max: 0.019s std dev: 0.00056s window: 182

The component is intended to be loaded into the same rclcpp_components container as the composable publisher, with use_intra_process_comms:=true enabled on both components.

📃Requirements

Both the publisher component and hz_dummy_subscriber must be available in the current ROS 2 environment before loading them into a container. In practice, that means their workspaces must be built and sourced in the current shell, whether the system is running natively or inside Docker.

🏃Running in the same process

1. Start a component container

ros2 run rclcpp_components component_container_mt --ros-args -r __node:=image_container

ROS 2 supports running multiple components in the same process by loading them into a container process managed by rclcpp_components.[1][3]

2. Load the publisher component

ros2 component load /image_container your_image_pkg your_namespace::YourImageNode \
  -e use_intra_process_comms:=true

3. Load the frequency subscriber component

ros2 component load /image_container hz_subscriber hz_subscriber::HzDummySubscriber \
  -p topic:=/image_raw \
  -p report_period_sec:=1.0 \
  -e use_intra_process_comms:=true

Important

To get intra-process behavior, both components must be loaded into the same container, and both must enable use_intra_process_comms.

About

Custom util to check ros2 topic frequency

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors