Skip to content

Commit bd4e491

Browse files
author
Prajakta Gokhale
authored
Add new messages for topic statistics (#98)
* Add new msgs for topic statistics Signed-off-by: Prajakta Gokhale <[email protected]> * Change float32 to float64 to avoid build WARNINGs Signed-off-by: Prajakta Gokhale <[email protected]> * Update package.xml Signed-off-by: Prajakta Gokhale <[email protected]>
1 parent f1d709b commit bd4e491

File tree

6 files changed

+163
-0
lines changed

6 files changed

+163
-0
lines changed

statistics_msgs/CMakeLists.txt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
cmake_minimum_required(VERSION 3.5)
2+
3+
project(statistics_msgs)
4+
5+
# Default to C++14
6+
if(NOT CMAKE_CXX_STANDARD)
7+
set(CMAKE_CXX_STANDARD 14)
8+
endif()
9+
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
10+
add_compile_options(-Wall -Wextra -Wpedantic)
11+
endif()
12+
13+
# Find dependencies
14+
find_package(ament_cmake REQUIRED)
15+
find_package(builtin_interfaces REQUIRED)
16+
find_package(rosidl_default_generators REQUIRED)
17+
18+
# Generate added messages with dependencies listed here
19+
rosidl_generate_interfaces(${PROJECT_NAME}
20+
"msg/MetricsMessage.msg"
21+
"msg/StatisticDataPoint.msg"
22+
"msg/StatisticDataType.msg"
23+
DEPENDENCIES builtin_interfaces
24+
)
25+
26+
ament_export_dependencies(rosidl_default_runtime)
27+
28+
ament_package()

statistics_msgs/README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# metrics_statistics_msgs
2+
3+
Package containing ROS 2 message definitions for reporting
4+
statistics for topics and system resources.
5+
6+
## Messages defined in this package
7+
8+
1. StatisticDataType
9+
10+
A message that represent the types of statistics reported.
11+
This defines the following data types that can be used to represent
12+
individual metric data points.
13+
* `average`
14+
* `minimum`
15+
* `maximum`
16+
* `stddev`
17+
* `sample_count`
18+
19+
1. StatisticDataPoint
20+
21+
A message that represents a single statistic value.
22+
This includes:
23+
* `data_type`: Type of the metric data point, as defined in `StatisticDataType`.
24+
* `data`: Value of the metric data point.
25+
26+
1. MetricsMessage
27+
28+
A message that represents statistic data measured from a source
29+
within a time window.
30+
This includes:
31+
* `measurement_source_name`: Source from where the measurement or statistic originates.
32+
* `metrics_source`: Name of the metric.
33+
* `unit`: Unit representing the metric.
34+
* `window_start`: Start time of the metric measurement window.
35+
* `window_stop`: End time of the metric measurement window.
36+
* `statistics`: A list of `StatisticDataPoint` representing the values
37+
of collected metrics.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#############################################
2+
# A generic metrics message providing statistics for measurements from different sources. For example,
3+
# measure a system's CPU % for a given window yields the following data points over a window of time:
4+
#
5+
# - average cpu %
6+
# - std deviation
7+
# - min
8+
# - max
9+
# - sample count
10+
#
11+
# These are all represented as different 'StatisticDataPoint's.
12+
#############################################
13+
14+
# Name metric measurement source, e.g., node, topic, or process name
15+
string measurement_source_name
16+
17+
# Name of the metric being measured, e.g. cpu_percentage, free_memory_mb, message_age, etc.
18+
string metrics_source
19+
20+
# Unit of measure of the metric, e.g. percent, mb, seconds, etc.
21+
string unit
22+
23+
# Measurement window start time
24+
builtin_interfaces/Time window_start
25+
26+
# Measurement window end time
27+
builtin_interfaces/Time window_stop
28+
29+
# A list of statistics data point, defined in StatisticDataPoint.msg
30+
StatisticDataPoint[] statistics
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#############################################
2+
# This holds the structure of a single data point of a StatisticDataType.
3+
#
4+
# This message is used in MetricsStatisticsMessage, defined in MetricsStatisticsMessage.msg.
5+
#
6+
# Examples of the value of data point are
7+
# - average size of messages received
8+
# - standard deviation of the period of messages published
9+
# - maximum age of messages published
10+
#
11+
# A value of nan represents no data is available.
12+
# One example is that standard deviation is only available when there are two or more data points but there is only one,
13+
# and in this case the value would be nan.
14+
# +inf and -inf are not allowed.
15+
#
16+
#############################################
17+
18+
# The statistic type of this data point, defined in StatisticDataType.msg
19+
# Default value should be StatisticDataType.STATISTICS_DATA_TYPE_UNINITIALIZED (0).
20+
uint8 data_type
21+
22+
# The value of the data point
23+
float64 data
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#############################################
2+
# This file contains the commonly used constants for the statistics data type.
3+
#
4+
# The value 0 is reserved for unitialized statistic message data type.
5+
# Range of values: [0, 255].
6+
# Unallowed values: any value that is not specified in this file.
7+
#
8+
#############################################
9+
10+
# Constant for uninitialized
11+
uint8 STATISTICS_DATA_TYPE_UNINITIALIZED = 0
12+
13+
# Allowed values
14+
uint8 STATISTICS_DATA_TYPE_AVERAGE = 1
15+
uint8 STATISTICS_DATA_TYPE_MINIMUM = 2
16+
uint8 STATISTICS_DATA_TYPE_MAXIMUM = 3
17+
uint8 STATISTICS_DATA_TYPE_STDDEV = 4
18+
uint8 STATISTICS_DATA_TYPE_SAMPLE_COUNT = 5

statistics_msgs/package.xml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0"?>
2+
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
3+
<package format="3">
4+
<name>statistics_msgs</name>
5+
<version>0.8.0</version>
6+
<description>Message definitions for reporting statistics for topics and system resources.</description>
7+
<maintainer email="[email protected]">ROS Tooling Working Group</maintainer>
8+
<license>Apache License 2.0</license>
9+
10+
<buildtool_depend>ament_cmake</buildtool_depend>
11+
<buildtool_depend>rosidl_default_generators</buildtool_depend>
12+
13+
<build_depend>builtin_interfaces</build_depend>
14+
15+
<build_export_depend>builtin_interfaces</build_export_depend>
16+
17+
<exec_depend>builtin_interfaces</exec_depend>
18+
<exec_depend>rosidl_default_runtime</exec_depend>
19+
20+
<test_depend>ament_lint_common</test_depend>
21+
22+
<member_of_group>rosidl_interface_packages</member_of_group>
23+
24+
<export>
25+
<build_type>ament_cmake</build_type>
26+
</export>
27+
</package>

0 commit comments

Comments
 (0)