Skip to content

topic statistics doesn't publish "message_age" data if QoS is Keep last. #83

@hsgwa

Description

@hsgwa

Description

topic statistics doesn't publish "message_age" data if subscription's QoS is Keep last.

Expected Behavior

$ ros2 topic echo /topic_statistics # in another terminal
~~
metrics_source: message_age
~~
metrics_source: message_period
~~
metrics_source: message_age
~~
metrics_source: message_period

Both message_age and message_period are published.

Actual Behavior

$ ros2 topic echo /topic_statistics # in another terminal
~~
metrics_source: message_period
~~
metrics_source: message_period

Only message_period are published.

To Reproduce

I've implemented test case.

$ cd ~/ros2_ws/
$ git clone -b qos_history_1 https://github.com/hsgwa/intra_process_ping_latency_test.git src/intra_process_ping_latency_test
$ colcon build --packages-select intra_process_ping_latency_test
$ . ~/ros2_ws/install/local_setup.bash
$ ros2 run intra_process_ping_latency_test ping_test
$ ros2 topic echo /topic_statistics # in another terminal

System

  • OS: Ubuntu 20.04.1 LTS (Focal Fossa)
  • ROS 2 Distro: Rolling

Additional context

As far as I read source code, this issues seems be caused by following reason.

  1. topic statistic's publisher takes over subscriber's QoS.
    https://github.com/ros2/rclcpp/blob/master/rclcpp/include/rclcpp/create_subscription.hpp#L88
  2. publish_message() publishes "message_age" and then "message_period" almost simultaneously.
    Here, second message (message_period) overwrites first message (message_age) if QoS depth = Keep Last.
    https://github.com/ros2/rclcpp/blob/master/rclcpp/include/rclcpp/topic_statistics/subscription_topic_statistics.hpp#L152

--

I posted this issue to libsatistics_collector because this bug is related to topic statistics, but I probably should have published it to rclcpp.
If you have any comments, I will republish this issue to rclcpp.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions