Skip to content

topic statistics results include measurement values out of window #1531

@hsgwa

Description

@hsgwa

Bug report

topic statistics results don't reset by window updating so that the results include values out of a window.
For instance, this behavior can cause steady-state results hidden if the maximum value is recorded at the start-up phase.

I think statistics results should be calculated within a window.

Required Info:

Steps to reproduce issue

$ cd ~/ros2_ws/
$ git clone -b check_statistics_transition_state 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

$ # in other terminal
$ PYTHONUNBUFFERED=1 ros2 topic echo /topic_statistics | grep message_age -A 18 --line-buffered | grep "data_type: 3" -A 1 --line-buffered | grep "data:"
# print out message_age minimum values

Here, ping_test adjusts message_age=1s for first 10s to imitate transition state.
After that, message_age fall down to about 1 ms order value.
message_age_timeseries

Expected behavior

$ PYTHONUNBUFFERED=1 ros2 topic echo /topic_statistics | grep message_age -A 18 --line-buffered | grep "data_type: 3" -A 1 --line-buffered | grep "data:"
  data: 1000.388805 # Transition state. message_age are adjusted to 1000 ms
  data: 1000.388805
  data: 0.791165  # 10 s later
  data: 0.361127 # max value doesn't include transition state.
  data: 0.361127

Actual behavior

$ PYTHONUNBUFFERED=1 ros2 topic echo /topic_statistics | grep message_age -A 18 --line-buffered | grep "data_type: 3" -A 1 --line-buffered | grep "data:"
  data: 1001.457474 # Transition state. message_age are adjusted to 1000 ms
  data: 1001.457474
  data: 1001.457474
  data: 1001.457474  # 10 s later
  data: 1001.457474  # max value includes transition state.
  data: 1001.457474
  data: 1001.457474
  data: 1001.457474

Additional information

The above outputs omit window_start and window_stop though, every window is updated to prevent overlap.

$ PYTHONUNBUFFERED=1 ros2 topic echo /topic_statistics | grep message_age -A 18 --line-buffered  | grep window -A 2
window_start:
  sec: 1611812308
  nanosec: 560635188
window_stop:
  sec: 1611812309
  nanosec: 560659761
--
window_start:
  sec: 1611812309
  nanosec: 560659761
window_stop:
  sec: 1611812310
  nanosec: 560712642

From the source code, it seems that resetting the statistics here will solve this issue.
https://github.com/ros2/rclcpp/blob/master/rclcpp/include/rclcpp/topic_statistics/subscription_topic_statistics.hpp#L154

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